Skip to content

Commit 6f598e8

Browse files
author
Sergio
committed
fix: locale not present in catalogs warn
1 parent 2bf9ebf commit 6f598e8

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/cli/src/api/catalog.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,21 @@ export class Catalog {
252252
console.error(`Message with key ${key} is missing in locale ${locale}`)
253253
}
254254

255-
const getTranslation = (locale) => catalogs[locale][key].translation
255+
const getTranslation = (locale) => {
256+
const configLocales = this.config.locales.join('", "')
257+
if (catalogs[locale]) {
258+
return catalogs[locale][key].translation
259+
}
260+
261+
console.warn(`
262+
Catalog "${locale}" isn't present in locales config parameter
263+
Add "${locale}" to your lingui.config.js:
264+
{
265+
locales: ["${configLocales}", "${locale}"]
266+
}
267+
`)
268+
return null
269+
}
256270

257271
const getMultipleFallbacks = (locale) => {
258272
const fL = fallbackLocales[locale]

0 commit comments

Comments
 (0)