From d24cfe7d06fe0c3d34d751bbee186786fb951bbe Mon Sep 17 00:00:00 2001 From: Tim Weber Date: Thu, 19 Dec 2024 23:38:58 +0000 Subject: [PATCH] Reduce some missing translations to warning level Signed-off-by: Tim Weber --- server/dearmep/cli/check.py | 23 +++++++++++++++++++---- server/dearmep/example-config.yaml | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/dearmep/cli/check.py b/server/dearmep/cli/check.py index 95d5de22..4153adbb 100644 --- a/server/dearmep/cli/check.py +++ b/server/dearmep/cli/check.py @@ -21,6 +21,14 @@ _logger = logging.getLogger(__name__) +# For the following keys, missing translations will output only a warning, not +# an error. +WARNING_KEYS = [ + "maintenance.message", + "verification.enterNumber.policyLinkUrl", +] + + def cmd_translations(ctx: Context) -> None: def check_entries(section: str, entries: Mapping[str, L10nEntry]) -> bool: had_error = False @@ -39,10 +47,14 @@ def check_entries(section: str, entries: Mapping[str, L10nEntry]) -> bool: lang for lang in cfg.l10n.languages if lang not in entry ] if missing: - _logger.error( - f"{prefix} is not translated into {', '.join(missing)}" + _logger.log( + logging.WARNING + if key in WARNING_KEYS + else logging.ERROR, + f"{prefix} is not translated into " + + ", ".join(missing), ) - had_error = True + had_error = key not in WARNING_KEYS return had_error ctx.setup_logging() @@ -79,7 +91,10 @@ def add_parser( translations = subsub.add_parser( "translations", help="ensure all strings are translated", - description="Look for untranslated strings in the configuration.", + description="Look for untranslated strings in the configuration. Will " + "exit with return code 0 if everything is translated, 1 if not. A few " + "translation keys count as optional; they will only emit a warning " + "and not count as an error.", ) translations.set_defaults(func=cmd_translations) diff --git a/server/dearmep/example-config.yaml b/server/dearmep/example-config.yaml index f58f8af6..c73358a0 100644 --- a/server/dearmep/example-config.yaml +++ b/server/dearmep/example-config.yaml @@ -834,9 +834,9 @@ l10n: en: Privacy Policy de: Datenschutzerklärung sv: integritetspolicy + fr: Règles de confidentialité # Danish grammar note: I am using the -ken suffix because of the definite article, # given that it will probably be used in a sentence with a definite meaning. - fr: Règles de confidentialité da: Privatlivspolitikken pt: Política de privacidade