Skip to content

Commit

Permalink
fix: locale not present in catalogs warn
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio committed Nov 16, 2020
1 parent 2bf9ebf commit 6f598e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/cli/src/api/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,21 @@ export class Catalog {
console.error(`Message with key ${key} is missing in locale ${locale}`)
}

const getTranslation = (locale) => catalogs[locale][key].translation
const getTranslation = (locale) => {
const configLocales = this.config.locales.join('", "')
if (catalogs[locale]) {
return catalogs[locale][key].translation
}

console.warn(`
Catalog "${locale}" isn't present in locales config parameter
Add "${locale}" to your lingui.config.js:
{
locales: ["${configLocales}", "${locale}"]
}
`)
return null
}

const getMultipleFallbacks = (locale) => {
const fL = fallbackLocales[locale]
Expand Down

0 comments on commit 6f598e8

Please sign in to comment.