From 6f598e81bb3278722b995d69daad3f5cdc492284 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 16 Nov 2020 18:11:48 +0100 Subject: [PATCH] fix: locale not present in catalogs warn --- packages/cli/src/api/catalog.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/api/catalog.ts b/packages/cli/src/api/catalog.ts index f316b382d..0a17f4204 100644 --- a/packages/cli/src/api/catalog.ts +++ b/packages/cli/src/api/catalog.ts @@ -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]