From 6f598e81bb3278722b995d69daad3f5cdc492284 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 16 Nov 2020 18:11:48 +0100 Subject: [PATCH 1/2] 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] From a53e12f19cebeb6412debc9dace0b4a45aa17624 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 16 Nov 2020 18:26:22 +0100 Subject: [PATCH 2/2] fix: fallbackLocales overriden if parent found --- packages/conf/src/index.test.ts | 2 +- packages/conf/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/conf/src/index.test.ts b/packages/conf/src/index.test.ts index cbd13c22f..2ec6e15b0 100644 --- a/packages/conf/src/index.test.ts +++ b/packages/conf/src/index.test.ts @@ -173,7 +173,7 @@ describe("@lingui/conf", function () { ), }) expect(config.fallbackLocales).toEqual({ - "en-US": "en", + "en-US": ["en"], default: "en", "es-MX": "es" }) diff --git a/packages/conf/src/index.ts b/packages/conf/src/index.ts index 0692c3ded..9c09082b5 100644 --- a/packages/conf/src/index.ts +++ b/packages/conf/src/index.ts @@ -278,7 +278,7 @@ export function fallbackLanguageMigration( config.locales.forEach((locale) => { const fl = getCldrParentLocale(locale.toLowerCase()) - if (fl) { + if (fl && !config.fallbackLocales[locale]) { config.fallbackLocales = { ...config.fallbackLocales, [locale]: fl