From faabe1f845d14d23b74905bd88eee1fc887c9f32 Mon Sep 17 00:00:00 2001 From: uvtqt Date: Sun, 15 Nov 2026 11:48:41 +0100 Subject: [PATCH 1/2] l10n: translate three strings es, fr and th still held in English, and guard against copies Co-Authored-By: Claude Opus 5.5 --- lib/l10n/app_es.arb | 4 +- lib/l10n/app_fr.arb | 4 +- lib/l10n/app_th.arb | 2 +- test/l10n_no_english_copies_test.dart | 68 +++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 test/l10n_no_english_copies_test.dart diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index add8dee42..640574813 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -2253,7 +2253,7 @@ "activityLiveRouteFootnoteWithDistance": "{distance} según las ubicaciones registradas hasta ahora.", "activityLiveRouteSoFarTitle": "RUTA HASTA AHORA", "activityLiveSetNumber": "Set {n}", - "activityLiveSetsCountSubtitle": "{n, plural, one{{n} SET} other{{n} SETS}}", + "activityLiveSetsCountSubtitle": "{n, plural, one{{n} SERIE} other{{n} SERIES}}", "activityLiveSetsListHeader": "SETS", "activityLiveSetsUnit": "sets", "activityLiveStepsUnit": "pasos", @@ -2267,7 +2267,7 @@ "activityLiveTimeUnit": "tiempo", "activityLiveTryAgain": "Reintentar", "activityLiveTurnOnLocation": "Activar ubicación", - "activityLiveVolumeSetsSubtitle": "{kg} KG · {n, plural, one{{n} SET} other{{n} SETS}}", + "activityLiveVolumeSetsSubtitle": "{kg} KG · {n, plural, one{{n} SERIE} other{{n} SERIES}}", "activityLiveWeightLabel": "PESO", "activityLiveWeightRepsLogged": "{kg} kg × {n} registrado", "activityLiveWorkWord": "Trabajo", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 64765d824..78f1a0c91 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -2241,7 +2241,7 @@ "activityLiveRouteFootnoteWithDistance": "{distance} d'après les positions enregistrées jusqu'ici.", "activityLiveRouteSoFarTitle": "ITINÉRAIRE JUSQU'ICI", "activityLiveSetNumber": "Set {n}", - "activityLiveSetsCountSubtitle": "{n, plural, one{{n} SET} other{{n} SETS}}", + "activityLiveSetsCountSubtitle": "{n, plural, one{{n} SÉRIE} other{{n} SÉRIES}}", "activityLiveSetsListHeader": "SETS", "activityLiveSetsUnit": "sets", "activityLiveStepsUnit": "pas", @@ -2255,7 +2255,7 @@ "activityLiveTimeUnit": "temps", "activityLiveTryAgain": "Réessayer", "activityLiveTurnOnLocation": "Activer la localisation", - "activityLiveVolumeSetsSubtitle": "{kg} KG · {n, plural, one{{n} SET} other{{n} SETS}}", + "activityLiveVolumeSetsSubtitle": "{kg} KG · {n, plural, one{{n} SÉRIE} other{{n} SÉRIES}}", "activityLiveWeightLabel": "POIDS", "activityLiveWeightRepsLogged": "{kg} kg × {n} enregistré", "activityLiveWorkWord": "Travail", diff --git a/lib/l10n/app_th.arb b/lib/l10n/app_th.arb index a083fd8b7..decc1f4fb 100644 --- a/lib/l10n/app_th.arb +++ b/lib/l10n/app_th.arb @@ -12507,7 +12507,7 @@ "@ecgTitle": { "description": "WHOOP MG ECG: ECG" }, - "ecgHeartScreener": "Heart Screener", + "ecgHeartScreener": "ตรวจคัดกรองหัวใจ", "@ecgHeartScreener": { "description": "WHOOP MG ECG: Heart Screener" }, diff --git a/test/l10n_no_english_copies_test.dart b/test/l10n_no_english_copies_test.dart new file mode 100644 index 000000000..00fc8f3e6 --- /dev/null +++ b/test/l10n_no_english_copies_test.dart @@ -0,0 +1,68 @@ +// A translated catalogue that holds the English text word for word shows +// English on an otherwise translated screen, and the coverage tests can't see +// it because the key is present. Spanish and French said "3 SETS" on the live +// strength screen, and Thai titled the ECG screen "Heart Screener". +// +// Only phrases are checked (longer than 12 characters, with a space): short +// labels such as "REM", "kg" or "OK" are legitimately the same in many +// languages. A phrase that really is the same in a language goes in +// [_sameOnPurpose] with its locale. +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +/// (locale, key) pairs whose value is identical to English on purpose: +/// placeholder-only patterns, brand names, units and abbreviations, or words +/// that are spelled the same in that language. +final _sameOnPurpose = { + for (final code in ['de', 'es', 'fr', 'hi', 'ru', 'th', 'zh']) + '$code:logFoodPillOpenFoodFacts', // a product name + // Placeholder-only patterns: no words of their own. + for (final code in ['de', 'es', 'fr', 'hi', 'ru']) + '$code:metricDetailSlotWithValue', + for (final code in ['de', 'es', 'fr', 'hi', 'ru']) '$code:sleepDetailScrubAt', + for (final code in ['de', 'es', 'fr', 'hi', 'th', 'zh']) + '$code:exerciseCatalogueName', + 'th:activityCatalogueName', + for (final code in ['de', 'es', 'hi', 'ru', 'th']) '$code:slotColumnReason', + for (final code in ['de', 'es', 'hi', 'ru', 'th']) + '$code:slotCapabilityStatus', + 'es:flashFileInfo', + // Units and abbreviations. + for (final code in ['de', 'fr', 'hi', 'th']) '$code:zoneRowsRange', + for (final code in ['es', 'fr']) '$code:zoneRowsMinutes', + for (final code in ['es', 'fr']) '$code:activityLengthMinutes', + for (final code in ['es', 'fr']) '$code:activityPickerKcalPer30', + for (final code in ['es', 'fr']) '$code:investigateSd1Sd224h', + 'de:supplementVitaminD25OHacb2ca', + 'fr:supplementVO2maxEst25e886', + // Spelled the same in French. + 'fr:investigateStressScore', + 'fr:calmBreathingMinutesSemantic', + 'fr:sleepDetailSolRange', +}; + +Map _arb(String code) => + jsonDecode(File('lib/l10n/app_$code.arb').readAsStringSync()) + as Map; + +void main() { + test('no translated catalogue copies an English phrase by accident', () { + final en = _arb('en'); + final copies = []; + for (final code in ['de', 'es', 'fr', 'hi', 'ru', 'th', 'zh']) { + final arb = _arb(code); + for (final key in en.keys) { + if (key.startsWith('@')) continue; + final english = en[key]; + if (english is! String || english.length <= 12) continue; + if (!english.contains(' ')) continue; + if (arb[key] != english) continue; + if (_sameOnPurpose.contains('$code:$key')) continue; + copies.add('$code:$key = $english'); + } + } + expect(copies, isEmpty); + }); +} From 71fb04db3b13c4e1b77b80609adf8e949ef18922 Mon Sep 17 00:00:00 2001 From: uvtqt Date: Sun, 15 Nov 2026 12:16:31 +0100 Subject: [PATCH 2/2] test(l10n): check every catalogue on disk for English copies, not a fixed list A locale added later would otherwise go unchecked until someone remembered to extend the list. The seven current locales are still asserted present. Co-Authored-By: Claude Opus 5.5 --- test/l10n_no_english_copies_test.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/l10n_no_english_copies_test.dart b/test/l10n_no_english_copies_test.dart index 00fc8f3e6..ee43a26c2 100644 --- a/test/l10n_no_english_copies_test.dart +++ b/test/l10n_no_english_copies_test.dart @@ -50,8 +50,16 @@ Map _arb(String code) => void main() { test('no translated catalogue copies an English phrase by accident', () { final en = _arb('en'); + // Every catalogue on disk, so a new locale is checked without editing + // this test. + final codes = [ + for (final f in Directory('lib/l10n').listSync()) + if (RegExp(r'app_(\w+)\.arb$').firstMatch(f.path) case final m?) + if (m[1] != 'en') m[1]!, + ]..sort(); + expect(codes, containsAll(['de', 'es', 'fr', 'hi', 'ru', 'th', 'zh'])); final copies = []; - for (final code in ['de', 'es', 'fr', 'hi', 'ru', 'th', 'zh']) { + for (final code in codes) { final arb = _arb(code); for (final key in en.keys) { if (key.startsWith('@')) continue;