fix(i18n): a one-word English copy counts as untranslated

The ratchet excused any value equal to en that held at most one plain
word, so "Settings", "Appearance", "Readability" or "Users" copied into
another locale were never counted, Japanese and Arabic included. Buttons,
tabs and section titles are mostly one word, so a feature could still add
26 English copies of its labels and stay green.

An identical value is now excused only when nothing ordinary is left
after dropping placeholders, markup, addresses, a listed set of product
names (BRAND_NAMES, which now holds one-word names such as Atlas, Immich
and Mapbox) and unit symbols (UNITS). A word that really is the locale's
own, German "Status" or French "Transport", carries a `// same-as-en`
marker on its declaration, which the catalogue reader now reports. The
marker is honoured only in Latin-script locales: a Latin word left in
Japanese or Russian is English whatever it says. Every locale folder
must be on LATIN_LOCALES or NON_LATIN_LOCALES, so a new language cannot
pass the rule unclassified.

The baseline is re-recorded from the narrower rule: the unmarked copies
go from 1252 to 3238, the marked fallbacks stay at 3157, and no entry
went down. This is the measured state under the new rule, not a raised
gate; translating, or marking a word that is genuinely the same, lowers
it with --update as before.
This commit is contained in:
Maurice
2026-10-08 12:17:03 +02:00
parent 8f691bff5a
commit 5f0865a476
12 changed files with 687 additions and 198 deletions
@@ -0,0 +1,5 @@
// Fixture: a canonical table beside a locale on neither script list.
const a = {
'a.title': 'Trip settings',
};
export default a;
@@ -0,0 +1,5 @@
// Fixture: a locale folder the ratchet has not been told the script of.
const a = {
'a.title': 'Trip settings',
};
export default a;
@@ -0,0 +1,9 @@
// Fixture: "Status" is the German word too and says so; the name and the unit need no marker.
const a = {
'a.settings': 'Einstellungen',
'a.appearance': 'Erscheinungsbild',
'a.status': 'Status', // same-as-en
'a.addon': 'Atlas',
'a.distance': '{count} km',
};
export default a;
@@ -0,0 +1,9 @@
// Fixture for the untranslated ratchet's word rule: single words, names and units.
const a = {
'a.settings': 'Settings',
'a.appearance': 'Appearance',
'a.status': 'Status',
'a.addon': 'Atlas',
'a.distance': '{count} km',
};
export default a;
@@ -0,0 +1,9 @@
// Fixture: "Settings" is an English copy; "Status" is one too, with no marker.
const a = {
'a.settings': 'Settings',
'a.appearance': 'Apparence',
'a.status': 'Status',
'a.addon': 'Atlas',
'a.distance': '{count} km',
};
export default a;
@@ -0,0 +1,9 @@
// Fixture: a Latin word in Japanese is English, marker or not.
const a = {
'a.settings': '設定',
'a.appearance': 'Appearance',
'a.status': 'Status', // same-as-en
'a.addon': 'Atlas',
'a.distance': '{count} km',
};
export default a;
+16 -2
View File
@@ -21,6 +21,13 @@ export const I18N_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', 'sr
export const FALLBACK_MARKER = '// en-fallback';
/**
* The marker a translator leaves on a value that is the locale's own word and
* happens to be spelled as in en (German "Status", French "Transport"). The
* untranslated ratchet honours it only in Latin-script locales.
*/
export const SAME_MARKER = '// same-as-en';
/** A root given as a file URL (what a spec can build without node types) or a path. */
export const asPath = (root) => (root instanceof URL ? fileURLToPath(root) : root);
@@ -70,7 +77,8 @@ function readLiteral(text) {
/**
* Every top-level entry of one table's source: key, value, whether the
* declaration carries the fallback marker, and the line it starts on.
* declaration carries the fallback marker (`marked`) or the same-as-en
* marker (`same`), and the line it starts on.
* Throws with file and line on anything it cannot read.
*/
export function parseCatalog(source, label = 'catalogue') {
@@ -91,7 +99,13 @@ export function parseCatalog(source, label = 'catalogue') {
if (!literal || !/^(,|\})?\s*(\/\/.*)?$/.test(tail)) {
throw new Error(`${label}:${i + 1}: '${key}' is not a single string literal`);
}
entries.push({ key, value: literal.value, marked: tail.includes(FALLBACK_MARKER), line: i + 1 });
entries.push({
key,
value: literal.value,
marked: tail.includes(FALLBACK_MARKER),
same: tail.includes(SAME_MARKER),
line: i + 1,
});
i = end;
}
return entries;
+473 -163
View File
@@ -1,275 +1,585 @@
{
"ar": {
"admin.ts": { "marked": 22, "identical": 3 },
"admin.ts": { "marked": 22, "identical": 9 },
"backup.ts": { "marked": 1, "identical": 0 },
"collab.ts": { "marked": 1, "identical": 0 },
"common.ts": { "marked": 13, "identical": 0 },
"dayplan.ts": { "marked": 8, "identical": 0 },
"journey.ts": { "marked": 284, "identical": 1 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 284, "identical": 2 },
"login.ts": { "marked": 1, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 19, "identical": 0 },
"settings.ts": { "marked": 14, "identical": 39 },
"system_notice.ts": { "marked": 3, "identical": 2 },
"settings.ts": { "marked": 14, "identical": 68 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 3, "identical": 3 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"az": {
"admin.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 1 }
"admin.ts": { "marked": 0, "identical": 5 },
"atlas.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 0, "identical": 8 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 3 },
"places.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 4 },
"settings.ts": { "marked": 0, "identical": 6 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 2 }
},
"br": {
"admin.ts": { "marked": 0, "identical": 13 },
"admin.ts": { "marked": 0, "identical": 29 },
"atlas.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 3 },
"collab.ts": { "marked": 0, "identical": 2 },
"collection.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 0 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 2 },
"dayplan.ts": { "marked": 2, "identical": 1 },
"help.ts": { "marked": 0, "identical": 4 },
"journey.ts": { "marked": 115, "identical": 7 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 45 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"map.ts": { "marked": 0, "identical": 1 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"mobileJourney.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 2 },
"places.ts": { "marked": 0, "identical": 3 },
"reservations.ts": { "marked": 0, "identical": 7 },
"roadtrip.ts": { "marked": 0, "identical": 4 },
"settings.ts": { "marked": 0, "identical": 85 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 4 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"trip.ts": { "marked": 0, "identical": 1 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
"vacay.ts": { "marked": 0, "identical": 6 }
},
"ca": {
"admin.ts": { "marked": 0, "identical": 4 },
"journey.ts": { "marked": 110, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 9 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"vacay.ts": { "marked": 0, "identical": 5 }
"admin.ts": { "marked": 0, "identical": 16 },
"atlas.ts": { "marked": 0, "identical": 2 },
"backup.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 4 },
"categories.ts": { "marked": 0, "identical": 2 },
"collab.ts": { "marked": 0, "identical": 3 },
"collection.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 0, "identical": 2 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"dawarich.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 0, "identical": 3 },
"docsync.ts": { "marked": 0, "identical": 2 },
"files.ts": { "marked": 0, "identical": 3 },
"help.ts": { "marked": 0, "identical": 2 },
"inspector.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 110, "identical": 12 },
"map.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 2 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 0, "identical": 1 },
"packing.ts": { "marked": 0, "identical": 1 },
"places.ts": { "marked": 0, "identical": 2 },
"planner.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 6 },
"roadtrip.ts": { "marked": 0, "identical": 3 },
"settings.ts": { "marked": 0, "identical": 20 },
"storage.ts": { "marked": 0, "identical": 4 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"transport.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 7 }
},
"cs": {
"admin.ts": { "marked": 0, "identical": 14 },
"atlas.ts": { "marked": 0, "identical": 1 },
"admin.ts": { "marked": 0, "identical": 26 },
"atlas.ts": { "marked": 0, "identical": 2 },
"backup.ts": { "marked": 0, "identical": 1 },
"collab.ts": { "marked": 0, "identical": 1 },
"collection.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 12, "identical": 0 },
"day.ts": { "marked": 0, "identical": 2 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 1 },
"docsync.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 115, "identical": 6 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 1 },
"places.ts": { "marked": 0, "identical": 2 },
"reservations.ts": { "marked": 0, "identical": 3 },
"roadtrip.ts": { "marked": 0, "identical": 3 },
"settings.ts": { "marked": 0, "identical": 83 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 3 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"tours.ts": { "marked": 0, "identical": 1 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"de": {
"admin.ts": { "marked": 0, "identical": 12 },
"journey.ts": { "marked": 9, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 11 },
"system_notice.ts": { "marked": 0, "identical": 4 }
"admin.ts": { "marked": 0, "identical": 42 },
"atlas.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 7 },
"collab.ts": { "marked": 0, "identical": 5 },
"collection.ts": { "marked": 0, "identical": 4 },
"common.ts": { "marked": 0, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"dawarich.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 3 },
"dayplan.ts": { "marked": 0, "identical": 4 },
"docsync.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 10 },
"inspector.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 9, "identical": 25 },
"map.ts": { "marked": 0, "identical": 2 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"mobileJourney.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 3 },
"notifications.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 4 },
"packing.ts": { "marked": 0, "identical": 1 },
"places.ts": { "marked": 0, "identical": 5 },
"planner.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 13 },
"roadtrip.ts": { "marked": 0, "identical": 5 },
"settings.ts": { "marked": 0, "identical": 28 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 2 },
"storage.ts": { "marked": 0, "identical": 5 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"tours.ts": { "marked": 0, "identical": 1 },
"transport.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 2 },
"vacay.ts": { "marked": 0, "identical": 1 }
},
"es": {
"admin.ts": { "marked": 0, "identical": 12 },
"common.ts": { "marked": 12, "identical": 0 },
"admin.ts": { "marked": 0, "identical": 28 },
"atlas.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 2 },
"categories.ts": { "marked": 0, "identical": 1 },
"collab.ts": { "marked": 0, "identical": 1 },
"collection.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 12, "identical": 2 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 0 },
"docsync.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 115, "identical": 7 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 45 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"map.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 2 },
"oauth.ts": { "marked": 17, "identical": 1 },
"packing.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 3 },
"roadtrip.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 84 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 2 },
"storage.ts": { "marked": 0, "identical": 3 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"trip.ts": { "marked": 0, "identical": 4 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
"vacay.ts": { "marked": 0, "identical": 6 }
},
"et": {
"admin.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 1 }
"admin.ts": { "marked": 0, "identical": 3 },
"budget.ts": { "marked": 0, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 0, "identical": 2 },
"mobileTrip.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 1 },
"transport.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 1 }
},
"fr": {
"admin.ts": { "marked": 0, "identical": 14 },
"atlas.ts": { "marked": 0, "identical": 1 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"help.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 115, "identical": 1 },
"admin.ts": { "marked": 0, "identical": 48 },
"atlas.ts": { "marked": 0, "identical": 2 },
"budget.ts": { "marked": 0, "identical": 9 },
"collab.ts": { "marked": 0, "identical": 8 },
"collection.ts": { "marked": 0, "identical": 4 },
"common.ts": { "marked": 12, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 3 },
"dawarich.ts": { "marked": 0, "identical": 3 },
"day.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 2, "identical": 5 },
"docsync.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 5 },
"help.ts": { "marked": 0, "identical": 13 },
"inspector.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 115, "identical": 32 },
"login.ts": { "marked": 0, "identical": 3 },
"notif.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 0 },
"places.ts": { "marked": 0, "identical": 1 },
"planner.ts": { "marked": 0, "identical": 1 },
"roadtrip.ts": { "marked": 0, "identical": 2 },
"settings.ts": { "marked": 0, "identical": 45 },
"map.ts": { "marked": 0, "identical": 3 },
"memories.ts": { "marked": 0, "identical": 3 },
"mobileJourney.ts": { "marked": 0, "identical": 3 },
"mobileTrip.ts": { "marked": 0, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 3 },
"notif.ts": { "marked": 0, "identical": 2 },
"notifications.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 4 },
"packing.ts": { "marked": 0, "identical": 1 },
"pdf.ts": { "marked": 0, "identical": 1 },
"photos.ts": { "marked": 0, "identical": 1 },
"places.ts": { "marked": 0, "identical": 8 },
"planner.ts": { "marked": 0, "identical": 3 },
"reservations.ts": { "marked": 0, "identical": 16 },
"roadtrip.ts": { "marked": 0, "identical": 6 },
"settings.ts": { "marked": 0, "identical": 89 },
"share.ts": { "marked": 0, "identical": 2 },
"shared.ts": { "marked": 0, "identical": 3 },
"storage.ts": { "marked": 0, "identical": 4 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"todo.ts": { "marked": 0, "identical": 1 },
"tours.ts": { "marked": 0, "identical": 3 },
"transport.ts": { "marked": 0, "identical": 2 },
"trip.ts": { "marked": 0, "identical": 7 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"gr": {
"admin.ts": { "marked": 0, "identical": 4 },
"common.ts": { "marked": 12, "identical": 0 },
"admin.ts": { "marked": 0, "identical": 21 },
"common.ts": { "marked": 12, "identical": 1 },
"dashboard.ts": { "marked": 36, "identical": 0 },
"journey.ts": { "marked": 110, "identical": 1 },
"day.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 110, "identical": 2 },
"login.ts": { "marked": 0, "identical": 3 },
"memories.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 42 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"places.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 2 },
"roadtrip.ts": { "marked": 0, "identical": 3 },
"settings.ts": { "marked": 0, "identical": 86 },
"storage.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"hu": {
"admin.ts": { "marked": 0, "identical": 15 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 0 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"id": {
"admin.ts": { "marked": 0, "identical": 7 },
"admin.ts": { "marked": 0, "identical": 26 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 115, "identical": 2 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"packing.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"it": {
"admin.ts": { "marked": 0, "identical": 12 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 1 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 45 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"ja": {
"admin.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 12, "identical": 0 },
"journey.ts": { "marked": 110, "identical": 1 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 41 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"ko": {
"admin.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 12, "identical": 0 },
"journey.ts": { "marked": 110, "identical": 0 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 39 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"nl": {
"admin.ts": { "marked": 0, "identical": 3 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 1 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"nav.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 1 },
"places.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 48 },
"reservations.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 79 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"pl": {
"admin.ts": { "marked": 0, "identical": 14 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 1 },
"id": {
"admin.ts": { "marked": 0, "identical": 29 },
"atlas.ts": { "marked": 0, "identical": 1 },
"backup.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 3 },
"collab.ts": { "marked": 0, "identical": 3 },
"collection.ts": { "marked": 0, "identical": 3 },
"common.ts": { "marked": 12, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 2 },
"dayplan.ts": { "marked": 2, "identical": 1 },
"docsync.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 7 },
"journey.ts": { "marked": 115, "identical": 13 },
"login.ts": { "marked": 0, "identical": 3 },
"memories.ts": { "marked": 0, "identical": 1 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 4 },
"oauth.ts": { "marked": 17, "identical": 2 },
"packing.ts": { "marked": 0, "identical": 2 },
"places.ts": { "marked": 0, "identical": 3 },
"reservations.ts": { "marked": 0, "identical": 7 },
"roadtrip.ts": { "marked": 0, "identical": 5 },
"settings.ts": { "marked": 0, "identical": 90 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"trip.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"it": {
"admin.ts": { "marked": 0, "identical": 30 },
"atlas.ts": { "marked": 0, "identical": 3 },
"budget.ts": { "marked": 0, "identical": 3 },
"collab.ts": { "marked": 0, "identical": 1 },
"collection.ts": { "marked": 0, "identical": 2 },
"common.ts": { "marked": 0, "identical": 3 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 2 },
"dayplan.ts": { "marked": 2, "identical": 1 },
"docsync.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 6 },
"inspector.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 115, "identical": 4 },
"login.ts": { "marked": 0, "identical": 3 },
"map.ts": { "marked": 0, "identical": 1 },
"memories.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 2 },
"oauth.ts": { "marked": 17, "identical": 2 },
"places.ts": { "marked": 0, "identical": 2 },
"reservations.ts": { "marked": 0, "identical": 6 },
"roadtrip.ts": { "marked": 0, "identical": 5 },
"settings.ts": { "marked": 0, "identical": 90 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 3 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"trip.ts": { "marked": 0, "identical": 1 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 6 }
},
"ja": {
"admin.ts": { "marked": 0, "identical": 9 },
"budget.ts": { "marked": 0, "identical": 1 },
"common.ts": { "marked": 12, "identical": 0 },
"help.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 110, "identical": 2 },
"login.ts": { "marked": 0, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"settings.ts": { "marked": 0, "identical": 71 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"ko": {
"admin.ts": { "marked": 0, "identical": 10 },
"common.ts": { "marked": 12, "identical": 0 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 110, "identical": 3 },
"login.ts": { "marked": 0, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 69 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"nl": {
"admin.ts": { "marked": 0, "identical": 28 },
"atlas.ts": { "marked": 0, "identical": 1 },
"backup.ts": { "marked": 0, "identical": 1 },
"budget.ts": { "marked": 0, "identical": 4 },
"collab.ts": { "marked": 0, "identical": 6 },
"collection.ts": { "marked": 0, "identical": 5 },
"common.ts": { "marked": 12, "identical": 0 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 2, "identical": 5 },
"docsync.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 6 },
"journey.ts": { "marked": 115, "identical": 17 },
"login.ts": { "marked": 0, "identical": 3 },
"map.ts": { "marked": 0, "identical": 2 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"mobileJourney.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 4 },
"nav.ts": { "marked": 0, "identical": 2 },
"oauth.ts": { "marked": 17, "identical": 2 },
"packing.ts": { "marked": 0, "identical": 1 },
"places.ts": { "marked": 0, "identical": 7 },
"planner.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 15 },
"roadtrip.ts": { "marked": 0, "identical": 5 },
"settings.ts": { "marked": 0, "identical": 92 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 2 },
"storage.ts": { "marked": 0, "identical": 5 },
"system_notice.ts": { "marked": 0, "identical": 6 },
"tours.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 5 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 6 }
},
"pl": {
"admin.ts": { "marked": 0, "identical": 25 },
"atlas.ts": { "marked": 0, "identical": 2 },
"budget.ts": { "marked": 0, "identical": 3 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 1 },
"docsync.ts": { "marked": 0, "identical": 1 },
"files.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 115, "identical": 5 },
"login.ts": { "marked": 0, "identical": 3 },
"memories.ts": { "marked": 0, "identical": 1 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 3 },
"notifications.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 1 },
"places.ts": { "marked": 0, "identical": 2 },
"reservations.ts": { "marked": 0, "identical": 6 },
"settings.ts": { "marked": 0, "identical": 81 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 3 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"transport.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"ru": {
"admin.ts": { "marked": 0, "identical": 13 },
"admin.ts": { "marked": 0, "identical": 21 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 0 },
"help.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 115, "identical": 1 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 10 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"oauth.ts": { "marked": 17, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 15 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"sk": {
"admin.ts": { "marked": 0, "identical": 4 },
"admin.ts": { "marked": 0, "identical": 8 },
"atlas.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 5 },
"system_notice.ts": { "marked": 0, "identical": 2 }
"backup.ts": { "marked": 0, "identical": 1 },
"collab.ts": { "marked": 0, "identical": 1 },
"collection.ts": { "marked": 0, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"day.ts": { "marked": 0, "identical": 2 },
"docsync.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 0, "identical": 9 },
"oauth.ts": { "marked": 0, "identical": 1 },
"places.ts": { "marked": 0, "identical": 2 },
"reservations.ts": { "marked": 0, "identical": 3 },
"roadtrip.ts": { "marked": 0, "identical": 3 },
"settings.ts": { "marked": 0, "identical": 12 },
"share.ts": { "marked": 0, "identical": 1 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 3 }
},
"sv": {
"admin.ts": { "marked": 0, "identical": 8 },
"budget.ts": { "marked": 0, "identical": 4 },
"journey.ts": { "marked": 110, "identical": 0 },
"admin.ts": { "marked": 0, "identical": 24 },
"atlas.ts": { "marked": 0, "identical": 2 },
"budget.ts": { "marked": 0, "identical": 9 },
"collection.ts": { "marked": 0, "identical": 1 },
"dashboard.ts": { "marked": 0, "identical": 1 },
"dayplan.ts": { "marked": 0, "identical": 2 },
"files.ts": { "marked": 0, "identical": 2 },
"help.ts": { "marked": 0, "identical": 6 },
"inspector.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 110, "identical": 18 },
"login.ts": { "marked": 0, "identical": 3 },
"members.ts": { "marked": 0, "identical": 1 },
"memories.ts": { "marked": 0, "identical": 1 },
"mobileCollections.ts": { "marked": 0, "identical": 1 },
"mobileTrip.ts": { "marked": 0, "identical": 3 },
"nav.ts": { "marked": 0, "identical": 3 },
"notifications.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 0, "identical": 3 },
"packing.ts": { "marked": 0, "identical": 1 },
"reservations.ts": { "marked": 0, "identical": 7 },
"roadtrip.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 38 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"settings.ts": { "marked": 0, "identical": 76 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 2 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"tours.ts": { "marked": 0, "identical": 1 },
"transport.ts": { "marked": 0, "identical": 1 },
"trip.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
"vacay.ts": { "marked": 0, "identical": 6 }
},
"th": {
"admin.ts": { "marked": 0, "identical": 1 }
"admin.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 1 }
},
"tr": {
"admin.ts": { "marked": 0, "identical": 4 },
"admin.ts": { "marked": 0, "identical": 11 },
"collab.ts": { "marked": 0, "identical": 1 },
"common.ts": { "marked": 12, "identical": 0 },
"journey.ts": { "marked": 110, "identical": 2 },
"help.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 110, "identical": 5 },
"login.ts": { "marked": 0, "identical": 6 },
"memories.ts": { "marked": 0, "identical": 1 },
"nav.ts": { "marked": 0, "identical": 1 },
"notifications.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 40 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"places.ts": { "marked": 0, "identical": 1 },
"roadtrip.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 71 },
"shared.ts": { "marked": 0, "identical": 1 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"trip.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 3 }
},
"uk": {
"admin.ts": { "marked": 0, "identical": 4 },
"admin.ts": { "marked": 0, "identical": 12 },
"common.ts": { "marked": 12, "identical": 0 },
"journey.ts": { "marked": 110, "identical": 0 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 110, "identical": 3 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 78 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"vi": {
"admin.ts": { "marked": 0, "identical": 4 },
"journey.ts": { "marked": 110, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 3 },
"system_notice.ts": { "marked": 0, "identical": 1 },
"admin.ts": { "marked": 0, "identical": 13 },
"common.ts": { "marked": 0, "identical": 1 },
"help.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 110, "identical": 3 },
"reservations.ts": { "marked": 0, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 8 },
"storage.ts": { "marked": 0, "identical": 1 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"zh": {
"admin.ts": { "marked": 0, "identical": 2 },
"journey.ts": { "marked": 110, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 8 },
"system_notice.ts": { "marked": 0, "identical": 2 },
"admin.ts": { "marked": 0, "identical": 3 },
"help.ts": { "marked": 0, "identical": 1 },
"journey.ts": { "marked": 110, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 9 },
"system_notice.ts": { "marked": 0, "identical": 3 },
"vacay.ts": { "marked": 0, "identical": 5 }
},
"zh-TW": {
"admin.ts": { "marked": 0, "identical": 11 },
"admin.ts": { "marked": 0, "identical": 18 },
"common.ts": { "marked": 12, "identical": 0 },
"dayplan.ts": { "marked": 2, "identical": 0 },
"journey.ts": { "marked": 115, "identical": 0 },
"help.ts": { "marked": 0, "identical": 3 },
"journey.ts": { "marked": 115, "identical": 1 },
"login.ts": { "marked": 0, "identical": 3 },
"oauth.ts": { "marked": 17, "identical": 0 },
"settings.ts": { "marked": 0, "identical": 44 },
"system_notice.ts": { "marked": 0, "identical": 4 },
"nav.ts": { "marked": 0, "identical": 1 },
"oauth.ts": { "marked": 17, "identical": 1 },
"settings.ts": { "marked": 0, "identical": 76 },
"system_notice.ts": { "marked": 0, "identical": 5 },
"undo.ts": { "marked": 0, "identical": 1 },
"vacay.ts": { "marked": 0, "identical": 5 }
}
+109 -20
View File
@@ -9,7 +9,9 @@
* marked a declaration carrying `// en-fallback`, the marker a
* translator leaves on a string they could not translate yet
* identical an unmarked value equal to en's, unless the rule in
* `isInvariant` says the text reads the same in every language
* `isInvariant` says the text reads the same in every language,
* or a translator confirmed it with `// same-as-en` in a
* Latin-script locale (`isExcused`)
*
* Both counts are held at scripts/i18n-untranslated-baseline.json. The check
* fails when either grows past its entry (a file without one may hold none),
@@ -28,19 +30,76 @@
* files, or a value the catalogue reader cannot parse is an error, never a
* pass.
*/
import { asPath, I18N_ROOT, listDomainFiles, listLocales, readCatalog } from './i18n-catalog.mjs';
import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { asPath, I18N_ROOT, listDomainFiles, listLocales, readCatalog } from './i18n-catalog.mjs';
export const BASELINE = join(dirname(fileURLToPath(import.meta.url)), 'i18n-untranslated-baseline.json');
/**
* Names of two or more plain words that read the same in every language.
* One-word names (Mapbox, Immich) and names with an inner capital (MapLibre,
* OpenStreetMap) are already covered by the word rule below.
* Product and service names, which read the same in every language. A value
* is excused for them, never for an ordinary word: German "Status" or French
* "Transport" are the locale's own words only by coincidence, and a one-word
* label copied from en ("Appearance", "Settings") is the commonest untranslated
* string there is. Names with an inner capital (MapLibre, OpenStreetMap) and
* acronyms need no entry, the word rule below already skips them.
*/
export const BRAND_NAMES = ['Apple Maps', 'Google Maps', 'Google Places', 'Home Assistant', 'Organic Maps', 'Synology Photos'];
export const BRAND_NAMES = [
'Amap',
'Anthropic',
'Apple Maps',
'Atlas',
'Dawarich',
'Discord',
'Docker',
'Google',
'Google Maps',
'Google Places',
'Home Assistant',
'Immich',
'Mapbox',
'Ntfy',
'Organic Maps',
'Polaroid',
'Synology',
'Synology Photos',
'Vacay',
'Webhook',
'wanderer',
];
/** Unit symbols, short codes rather than words: "{count} km", "{minutes} min". */
export const UNITS = ['km', 'mi', 'ft', 'min'];
/**
* Locales written in a script other than Latin. A Latin word left in one of
* them is English whatever the word, so `// same-as-en` is not honoured
* there. Every locale folder must be listed in exactly one of the two lists,
* so a new locale cannot slip past this rule unclassified.
*/
export const NON_LATIN_LOCALES = ['ar', 'gr', 'ja', 'ko', 'ru', 'th', 'uk', 'zh', 'zh-TW'];
export const LATIN_LOCALES = [
'az',
'br',
'ca',
'cs',
'de',
'en',
'es',
'et',
'fr',
'hu',
'id',
'it',
'nl',
'pl',
'sk',
'sv',
'tr',
'vi',
];
const PLACEHOLDER_RE = /\{[a-zA-Z0-9_]+\}/g;
const TAG_RE = /<\/?[a-zA-Z][^>]*>/g;
@@ -48,6 +107,15 @@ const TAG_RE = /<\/?[a-zA-Z][^>]*>/g;
const ADDRESS_RE = /\S*[/@]\S*/g;
// Hyphens join a word: "Check-in", "Wi-Fi" and "Auto-Backup" are one each.
const WORD_RE = /\p{L}[\p{L}\p{M}'’-]*/gu;
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// Longest first, so "Google Maps" goes as one name before "Google" could split it.
const NAME_RE = new RegExp(
`(?<![\\p{L}\\p{N}])(?:${[...BRAND_NAMES, ...UNITS]
.sort((a, b) => b.length - a.length)
.map(escapeRe)
.join('|')})(?![\\p{L}\\p{N}])`,
'gu',
);
/**
* A word in the sense of the rule: two letters or more and no capital after
@@ -58,22 +126,37 @@ const WORD_RE = /\p{L}[\p{L}\p{M}'’-]*/gu;
export const isPlainWord = (word) => word.length >= 2 && !/\p{Lu}/u.test(word.slice(1));
/**
* Whether a value equal to en's is legitimately the same text. True when,
* after dropping placeholders, markup, addresses and the brand names above,
* at most one plain word is left: "{count} km", "OAuth", "GPX", "Google Maps",
* "PDF · {size}", "Budget", the sort label "Name (A to Z)". Two plain words or
* more are a phrase, and phrases differ between languages.
* Whether a value equal to en's is legitimately the same text in every
* language. True when, after dropping placeholders, markup, addresses, the
* names in BRAND_NAMES and the UNITS, no plain word is left: "{count} km",
* "OAuth", "GPX", "Google Maps", "Atlas", "PDF · {size}". A single plain word
* is counted like a phrase: "Budget" and "Status" may be the locale's word too,
* and that is for a translator to confirm, not for the rule to assume.
*/
export function isInvariant(value) {
let text = value.replace(PLACEHOLDER_RE, ' ').replace(TAG_RE, ' ').replace(ADDRESS_RE, ' ');
for (const name of BRAND_NAMES) text = text.split(name).join(' ');
return (text.match(WORD_RE) ?? []).filter(isPlainWord).length <= 1;
const text = value.replace(PLACEHOLDER_RE, ' ').replace(TAG_RE, ' ').replace(ADDRESS_RE, ' ').replace(NAME_RE, ' ');
return !(text.match(WORD_RE) ?? []).some(isPlainWord);
}
/** Whether `locale` is written in Latin script. Throws for a locale on neither list. */
export function isLatinLocale(locale) {
if (LATIN_LOCALES.includes(locale)) return true;
if (NON_LATIN_LOCALES.includes(locale)) return false;
throw new Error(
`locale ${locale} is on neither LATIN_LOCALES nor NON_LATIN_LOCALES in scripts/i18n-untranslated.mjs`,
);
}
/**
* Whether an unmarked value equal to en's is excused: it is invariant, or a
* translator marked it `// same-as-en` in a Latin-script locale.
*/
export const isExcused = (value, same, locale) => isInvariant(value) || (same && isLatinLocale(locale));
/**
* Today's counts: `{ [locale]: { [file]: { marked, identical } } }`, only
* non-zero entries. Throws on a locale missing one of en's files or a value
* the reader cannot parse.
* non-zero entries. Throws on a locale missing one of en's files, a locale
* on neither script list or a value the reader cannot parse.
*/
export function countUntranslated(root = I18N_ROOT) {
const locales = listLocales(root);
@@ -82,6 +165,8 @@ export function countUntranslated(root = I18N_ROOT) {
const enValues = new Map(enFiles.map((f) => [f, new Map(readCatalog('en', f, root).map((e) => [e.key, e.value]))]));
const counts = {};
for (const locale of locales) {
// Classify every folder first: an unlisted locale is an error, not a pass.
isLatinLocale(locale);
if (locale === 'en') continue;
const files = new Set(listDomainFiles(locale, root));
for (const file of enFiles) {
@@ -89,9 +174,9 @@ export function countUntranslated(root = I18N_ROOT) {
const en = enValues.get(file);
let marked = 0;
let identical = 0;
for (const { key, value, marked: isMarked } of readCatalog(locale, file, root)) {
for (const { key, value, marked: isMarked, same } of readCatalog(locale, file, root)) {
if (isMarked) marked++;
else if (en.get(key) === value && !isInvariant(value)) identical++;
else if (en.get(key) === value && !isExcused(value, same, locale)) identical++;
}
if (marked || identical) (counts[locale] ??= {})[file] = { marked, identical };
}
@@ -191,7 +276,9 @@ const total = (map, kind) =>
// Compared by real path, so the check still runs when the script is started through a symlink.
const isCli =
Boolean(process.argv[1]) && existsSync(process.argv[1]) && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
Boolean(process.argv[1]) &&
existsSync(process.argv[1]) &&
realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
if (isCli) {
try {
const counts = countUntranslated();
@@ -207,7 +294,9 @@ if (isCli) {
console.error('Translate the new strings (shared/CLAUDE.md: an English placeholder is not acceptable).');
}
if (lowerable && !process.argv.includes('--update')) {
console.log(`${lowerable} baseline entr${lowerable === 1 ? 'y is' : 'ies are'} above today's count: run with --update to lower.`);
console.log(
`${lowerable} baseline entr${lowerable === 1 ? 'y is' : 'ies are'} above today's count: run with --update to lower.`,
);
}
console.log(
`untranslated: ${total(counts, 'marked')} marked en-fallback, ${total(counts, 'identical')} unmarked English copies`,