Skip to content

Commit

Permalink
Reduce some missing translations to warning level
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Weber <scy@scy.name>
  • Loading branch information
scy committed Dec 19, 2024
1 parent 40e1e94 commit d24cfe7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions server/dearmep/cli/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion server/dearmep/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d24cfe7

Please sign in to comment.