andreahlert commented on code in PR #62983:
URL: https://github.com/apache/airflow/pull/62983#discussion_r2895068243
##########
dev/breeze/src/airflow_breeze/commands/ui_commands.py:
##########
@@ -355,91 +391,93 @@ def print_translation_progress(locale_files,
missing_counts, summary):
table = tables[lang]
table.title = f"Translation Progress: {lang}"
table.add_column("File", style="bold cyan")
- table.add_column("Missing", style="red")
- table.add_column("Extra", style="yellow")
- table.add_column("TODOs", style="magenta")
+ table.add_column("Required (base EN)", style="dim")
+ table.add_column("Required (plural)", style="dim")
+ table.add_column("Total required", style="bold")
table.add_column("Translated", style="green")
- table.add_column("Total", style="bold")
+ table.add_column("Missing", style="red")
table.add_column("Coverage", style="bold")
- table.add_column("Completed", style="bold")
+ table.add_column("TODOs", style="magenta")
+ table.add_column("Unused", style="yellow")
+ total_required_base = 0
+ total_required_plural = 0
+ total_required = 0
+ total_translated = 0
total_missing = 0
- total_extra = 0
total_todos = 0
- total_translated = 0
- total_total = 0
+ total_unused = 0
for filename in sorted(all_files):
- file_path = Path(LOCALES_DIR / lang / filename)
- # Always get total from English version
en_path = Path(LOCALES_DIR / "en" / filename)
- if en_path.exists():
- with open(en_path) as f:
- en_data = json.load(f)
- file_total = sum(1 for _ in flatten_keys(en_data))
- else:
- file_total = 0
+ file_path = Path(LOCALES_DIR / lang / filename)
+ diff = summary.get(filename, LocaleSummary({}, {}))
+ if not en_path.exists():
+ continue
+ with open(en_path) as f:
+ en_data = json.load(f)
+ en_keys = set(flatten_keys(en_data))
+ en_key_to_value = flatten_keys_to_values(en_data)
+ required_keys = expand_plural_keys(en_keys, lang, en_key_to_value)
+ required_base_en = len(en_keys)
+ required_plural = len(required_keys) - required_base_en
+ total_req = len(required_keys)
+ file_missing = len(diff.missing_keys.get(lang, []))
+ file_unused = len(diff.unused_keys.get(lang, []))
if file_path.exists():
with open(file_path) as f:
- data = json.load(f)
- file_missing = missing_counts.get(filename, {}).get(lang, 0)
- file_extra = len(summary.get(filename, LocaleSummary({},
{})).extra_keys.get(lang, []))
-
- file_todos = count_todos(data)
+ lang_data = json.load(f)
+ lang_key_to_value = flatten_keys_to_values(lang_data)
+ file_translated = sum(
+ 1
+ for k in required_keys
+ if k in lang_key_to_value and not
is_todo_value(lang_key_to_value[k])
+ )
+ file_todos = sum(
+ 1 for k in required_keys if k in lang_key_to_value and
is_todo_value(lang_key_to_value[k])
+ )
if file_todos > 0:
has_todos = True
- file_translated = file_total - file_missing
- # Coverage: translated / total
- file_coverage_percent = 100 * file_translated / file_total if
file_total else 100
- # Complete percent: (translated - todos) / translated
- file_actual_translated = file_translated - file_todos
- complete_percent = 100 * file_actual_translated /
file_translated if file_translated else 100
- style = (
- "bold green"
- if file_missing == 0 and file_extra == 0 and file_todos == 0
- else (
- "yellow" if file_missing < file_total or file_extra >
0 or file_todos > 0 else "red"
- )
- )
else:
- file_missing = file_total
- file_extra = len(summary.get(filename, LocaleSummary({},
{})).extra_keys.get(lang, []))
- file_todos = 0
file_translated = 0
- file_coverage_percent = 0
- complete_percent = 0
- style = "red"
+ file_todos = 0
+ file_coverage = 100 * file_translated / total_req if total_req
else 100.0
+ style = (
+ "bold green"
+ if file_missing == 0 and file_unused == 0 and file_todos == 0
+ else ("yellow" if file_missing > 0 or file_todos > 0 or
file_unused > 0 else "red")
+ )
Review Comment:
Updated.
file_missing > 0 -> red, file_todos > 0 or file_unused > 0 -> yellow, else
bold green.
--
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]