steveahnahn commented on code in PR #55604:
URL: https://github.com/apache/airflow/pull/55604#discussion_r2364322486
##########
dev/i18n/check_translations_completeness.py:
##########
@@ -454,20 +454,31 @@ def print_translation_progress(console, locale_files,
missing_counts, summary):
"--add-missing",
is_flag=True,
default=False,
- help="Add missing translations for the selected language, prefixed with
'TODO: translate:'.",
+ help="Add missing translations for all languages except English, prefixed
with 'TODO: translate:'.",
)
def cli(language: str | None = None, add_missing: bool = False):
- if add_missing:
- if not language:
- raise ValueError("--language is required when passing
--add_missing")
- locale_path = LOCALES_DIR / language
- locale_path.mkdir(exist_ok=True)
locale_files = get_locale_files()
console = Console(force_terminal=True, color_system="auto")
print_locale_file_table(locale_files, console, language)
found_difference = print_file_set_differences(locale_files, console,
language)
summary, missing_counts = compare_keys(locale_files, console)
console.print("\n[bold underline]Summary of differences by language:[/bold
underline]", style="cyan")
+ if add_missing and language != "en":
+ # Loop through all languages except 'en' and add missing translations
+ if language:
+ language_files = [lf for lf in locale_files if lf.locale ==
language]
+ else:
+ language_files = [lf for lf in locale_files if lf.locale != "en"]
+ for lf in language_files:
+ filtered_summary = {}
+ for filename, diff in summary.items():
+ filtered_summary[filename] = LocaleSummary(
+ missing_keys={lf.locale: diff.missing_keys.get(lf.locale,
[])},
+ extra_keys={lf.locale: diff.extra_keys.get(lf.locale, [])},
+ )
+ add_missing_translations(lf.locale, filtered_summary, console)
+ # After adding, re-run the summary for all languages
+ summary, missing_counts = compare_keys(get_locale_files(), console)
Review Comment:
This addition was from @potiuk in the commit
[2620d20](https://github.com/apache/airflow/pull/55604/commits/2620d20c2e03cc473c1def34f8cbea0a18490140)
I will defer to his thoughts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]