diff --git a/Makefile b/Makefile index 76575acb8..19f2f662f 100644 --- a/Makefile +++ b/Makefile @@ -1341,6 +1341,12 @@ locale-used-keys-test: test: locale-used-keys-test +.PHONY: locale-translated-test +locale-translated-test: + @python3 tests/locale_translated_test.py + +test: locale-translated-test + .PHONY: music-library-zi-test music-library-zi-test: $(ZI2C_BIN) @env -u DISPLAY -u WAYLAND_DISPLAY \ diff --git a/locales/de.txt b/locales/de.txt index 83e24ac1f..049277915 100644 --- a/locales/de.txt +++ b/locales/de.txt @@ -848,7 +848,7 @@ Stimmung nach der Übung Durchschnittliche Stimmung --- [habit_stats_mood_checkins] -Check-ins +Stimmungs-Check-ins --- [habit_stats_best_hold] Beste Atemhaltezeit diff --git a/locales/fr.txt b/locales/fr.txt index 577afdf30..e6ef4cc0b 100644 --- a/locales/fr.txt +++ b/locales/fr.txt @@ -143,7 +143,7 @@ Méditation Salutation au soleil --- [sun_salutation_repetitions_label] -Repetitions +Répétitions --- [sun_salutation_start_speed_label] Tempo initial @@ -987,10 +987,10 @@ Modifier change le nom, la couleur et les liens. Les données viennent des pratiques terminées. --- [session_count_singular] -%d session +%d séance --- [session_count_plural] -%d sessions +%d séances --- [results_rounds] %d cycles @@ -999,7 +999,7 @@ Les données viennent des pratiques terminées. %d min --- [practice_home_repetitions] -%d reps +%d rép. --- [practice_home_wim_hof_metadata] %d cycles | %d respirations diff --git a/locales/id.txt b/locales/id.txt index 1bedd4212..5b100c523 100644 --- a/locales/id.txt +++ b/locales/id.txt @@ -1639,7 +1639,7 @@ Langit Gaya --- [theme_style_default] -Default +Bawaan --- [theme_style_classic] Klasik diff --git a/locales/it.txt b/locales/it.txt index 6881ea37a..368f802d6 100644 --- a/locales/it.txt +++ b/locales/it.txt @@ -371,7 +371,7 @@ Finestra Riproduzione --- [settings_section_layout] -Layout +Disposizione --- [settings_section_sounds] Suoni @@ -1146,13 +1146,13 @@ Media %ds --- [round_result_label] -Round %d %ds +Giro %d %ds --- [session_round_label] -ROUND %d +GIRO %d --- [round_number_label] -Round %d +Giro %d --- [notification_starting_seconds] Avvio: %ds diff --git a/locales/pt.txt b/locales/pt.txt index 1d507f87c..4aa4fc0b6 100644 --- a/locales/pt.txt +++ b/locales/pt.txt @@ -380,7 +380,7 @@ Janela Reprodução --- [settings_section_layout] -Layout +Disposição --- [settings_section_sounds] Sons @@ -857,7 +857,7 @@ Humor após a prática Humor médio --- [habit_stats_mood_checkins] -Check-ins +Registros de humor --- [habit_stats_best_hold] Melhor retenção @@ -1008,7 +1008,7 @@ Os dados vêm de práticas concluídas. %d min --- [practice_home_repetitions] -%d reps +%d rep. --- [practice_home_wim_hof_metadata] %d rodadas | %d respirações diff --git a/tests/locale_same_as_english.txt b/tests/locale_same_as_english.txt new file mode 100644 index 000000000..30fd4b6c8 --- /dev/null +++ b/tests/locale_same_as_english.txt @@ -0,0 +1,137 @@ +# Strings that are correctly identical to English in a locale (brand names, +# shared loanwords, format strings). Enforced by tests/locale_translated_test.py. +# Format: +cs app_title +cs import_data_only_button +cs practice_home_minutes +cs practice_home_patterns_metadata +cs profile_data +cs profile_data_management_title +cs results_metric_seconds +cs sync_alias_button +cs theme_app +cs theme_mono +cs trocador_button +de app_title +de exercise_meditation +de habit_default_meditation_name +de habit_default_yoga_name +de habit_details_title +de meditation_manual_title +de meditation_title +de open_wallet_button +de orientation_sensor +de orientation_system +de patterns_pause_button +de patterns_preset_box +de pause_button +de practice_home_title_meditation +de profile_name_label +de results_metric_seconds +de settings_breaks_mode_normal +de settings_section_layout +de settings_tab_audio +de sync_alias_button +de theme_app +de theme_mono +de theme_sepia +de theme_style_system +de theme_system +de trocador_button +es app_title +es break_hud_micro +es habit_color_label +es habit_day_total_count_suffix +es habit_default_yoga_name +es orientation_sensor +es practice_home_minutes +es practice_home_patterns_metadata +es results_metric_seconds +es settings_breaks_mode_normal +es settings_tab_audio +es sync_alias_button +es theme_app +es theme_mono +es theme_sepia +es trocador_button +fr app_title +fr appearance_style_label +fr break_hud_micro +fr habit_day_total_count_suffix +fr habit_default_yoga_name +fr notifications_section +fr orientation_label +fr orientation_portrait +fr patterns_cycle_label +fr patterns_pause_button +fr pause_button +fr practice_home_minutes +fr practice_home_patterns_metadata +fr results_cycles +fr results_metric_seconds +fr settings_breaks_mode +fr settings_breaks_mode_normal +fr settings_tab_audio +fr settings_tab_notifications +fr sync_alias_button +fr theme_app +fr theme_cobalt +fr theme_mode_label +fr theme_mono +fr theme_style_label +fr trocador_button +id app_title +id habit_day_total_count_suffix +id habit_default_yoga_name +id import_data_only_button +id orientation_sensor +id profile_data +id profile_data_management_title +id results_metric_seconds +id settings_breaks_mode +id settings_breaks_mode_normal +id settings_tab_audio +id sync_alias_button +id theme_app +id theme_lavender +id theme_mint +id theme_mode_label +id theme_mono +id theme_sage +id theme_sepia +id trocador_button +it app_title +it break_hud_micro +it habit_default_yoga_name +it patterns_preset_box +it practice_home_minutes +it practice_home_patterns_metadata +it results_metric_seconds +it settings_tab_audio +it sync_alias_button +it theme_app +it theme_mono +it trocador_button +ja theme_app +ja trocador_button +ko app_title +ko theme_app +ko trocador_button +pt app_title +pt break_hud_micro +pt habit_day_total_count_suffix +pt habit_default_yoga_name +pt orientation_sensor +pt practice_home_minutes +pt practice_home_patterns_metadata +pt results_metric_seconds +pt settings_breaks_mode_normal +pt sync_alias_button +pt theme_app +pt theme_mono +pt trocador_button +ru app_title +ru theme_app +ru trocador_button +zh theme_app +zh trocador_button diff --git a/tests/locale_translated_test.py b/tests/locale_translated_test.py new file mode 100644 index 000000000..de7416d92 --- /dev/null +++ b/tests/locale_translated_test.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +"""Law: no locale keeps English text by accident. + +A string identical to its English source in another locale must be listed in +tests/locale_same_as_english.txt (brand names, loanwords, format strings). Any new +untranslated string fails here, and an allowlist entry that has since been +translated must be removed.""" + +from pathlib import Path +import re +import sys + +root = Path(__file__).resolve().parent.parent +locales = root / "locales" + + +def entries(path): + values, key, lines = {}, None, [] + for line in path.read_text(encoding="utf-8").split("\n"): + header = re.fullmatch(r"\[([a-z0-9_]+)\]", line) + if header: + key, lines = header.group(1), [] + elif line == "---" and key is not None: + values[key] = "\n".join(lines) + key = None + else: + lines.append(line) + return values + + +allowed = set() +for line in (root / "tests/locale_same_as_english.txt").read_text(encoding="utf-8").splitlines(): + if line.strip() and not line.startswith("#"): + allowed.add(tuple(line.split())) + +english = entries(locales / "en.txt") +found = set() +for path in sorted(locales.glob("*.txt")): + code = path.stem + if code in ("en", "index"): + continue + for key, value in entries(path).items(): + if english.get(key) == value and any(c.isalpha() for c in value) and len(value) > 2: + found.add((code, key)) + +untranslated = sorted(found - allowed) +stale = sorted(allowed - found) +for code, key in untranslated: + print(f"{code}: {key} is still English: {english[key]!r}") +for code, key in stale: + print(f"{code}: {key} is translated now; remove it from same_as_english.txt") +if untranslated or stale: + sys.exit(1) +print("Locales: every string is translated or explicitly allowed to match English") diff --git a/ziran.lock b/ziran.lock index d188e3e3a..1c6fec83a 100644 --- a/ziran.lock +++ b/ziran.lock @@ -85,7 +85,7 @@ "name": "Inbe" }, "toolchain": { - "commit": "8bbde6bce930c8824f5d8d5b29731b717d80b6c7", + "commit": "72d35377a3b07b70998ef6c12a1b76d09c343989", "ref": "master", "url": "https://github.com/ziranlang/ziran.git" }