From 9771bd2604a6dce86886b5f8b6b9edf4b960240d Mon Sep 17 00:00:00 2001 From: Thibault Date: Fri, 13 Oct 2023 16:53:18 +0200 Subject: [PATCH 1/3] adding missing translation logs --- src/utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 272ce15..d7ec316 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -23,11 +23,15 @@ export const translate: Translations.Translate = ({ let text = (translations[locale] || {})[key]; if (fallbackLocale && text === undefined) { + logger.warn(`No translation provided for '${key}' key in locale '${locale}'. Trying fallback '${fallbackLocale}'`); text = (translations[fallbackLocale] || {})[key]; } - if (rest.hasOwnProperty('fallbackValue') && text === undefined) { - return rest.fallbackValue; + if (text === undefined) { + logger.warn(`No translation provided for '${key}' key in fallback '${fallbackLocale}'.`); + if (rest.hasOwnProperty('fallbackValue') ) { + return rest.fallbackValue; + } } return parser.parse(text, params, locale, key); From 3a62a4a241e04ea40d2fb2ee9e9458144091d7e5 Mon Sep 17 00:00:00 2001 From: Thibault Andreis <36659965+ThibaultAndreis@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:26:36 +0100 Subject: [PATCH 2/3] change log level for missing translations change log level for "missing translations" from warn to debug --- src/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index d7ec316..d977663 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -23,12 +23,12 @@ export const translate: Translations.Translate = ({ let text = (translations[locale] || {})[key]; if (fallbackLocale && text === undefined) { - logger.warn(`No translation provided for '${key}' key in locale '${locale}'. Trying fallback '${fallbackLocale}'`); + logger.debug(`No translation provided for '${key}' key in locale '${locale}'. Trying fallback '${fallbackLocale}'`); text = (translations[fallbackLocale] || {})[key]; } if (text === undefined) { - logger.warn(`No translation provided for '${key}' key in fallback '${fallbackLocale}'.`); + logger.debug(`No translation provided for '${key}' key in fallback '${fallbackLocale}'.`); if (rest.hasOwnProperty('fallbackValue') ) { return rest.fallbackValue; } From 2322acf661d4637c7f1f39a313a503145da4733b Mon Sep 17 00:00:00 2001 From: Thibault Andreis <36659965+ThibaultAndreis@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:21:40 +0100 Subject: [PATCH 3/3] add warn when no translation nor fallback is found --- src/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.ts b/src/utils.ts index d977663..c30d74e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -32,6 +32,7 @@ export const translate: Translations.Translate = ({ if (rest.hasOwnProperty('fallbackValue') ) { return rest.fallbackValue; } + logger.warn(`No translation nor fallback found for '${key}' .`); } return parser.parse(text, params, locale, key);