Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce some missing translations to warning level #300

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading