mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 07:26:30 +00:00
fix(i18n): the untranslated ratchet sees plural copies and copied phrases
Two holes let English through the ratchet unseen.
A plural form en has no key for (Russian .few and .many, Arabic .two)
was compared with en's value for that same key, which never exists, so a
locale could copy en's text into exactly the forms a new plural group
needs and the count stayed put. Such a form is now compared with every
form en spells out for the group. A form en does declare keeps the exact
comparison: Italian "{count} file" is the Italian plural, not a copy of
en's "{count} file".
The // same-as-en marker excused any value in a Latin-script locale, so
one comment waved a whole copied sentence through. It is honoured only
on a value holding a single plain word, the case shared/CLAUDE.md
already describes. No locale carries the marker today, so nothing that
passed before fails now; the counts are unchanged.
This commit is contained in:
@@ -61,6 +61,9 @@ describe('i18n untranslated ratchet', () => {
|
||||
|
||||
it('honours // same-as-en in a Latin-script locale only, and refuses an unlisted locale', () => {
|
||||
expect(isExcused('Status', true, 'de')).toBe(true);
|
||||
expect(isExcused('Status: {state}', true, 'de')).toBe(true);
|
||||
expect(isExcused('Delete this trip and all its places permanently', true, 'de')).toBe(false);
|
||||
expect(isExcused('Source code', true, 'de')).toBe(false);
|
||||
expect(isExcused('Status', false, 'de')).toBe(false);
|
||||
expect(isExcused('Status', true, 'ja')).toBe(false);
|
||||
expect(isExcused('GPX', false, 'ja')).toBe(true);
|
||||
@@ -69,11 +72,20 @@ describe('i18n untranslated ratchet', () => {
|
||||
|
||||
it('counts a one-word English copy: Settings in fr, Appearance in ja', () => {
|
||||
expect(countUntranslated(new URL('i18n-words/', FIXTURES))).toEqual({
|
||||
// The copied sentence carries // same-as-en, which only a single word earns.
|
||||
de: { 'a.ts': { marked: 0, identical: 1 } },
|
||||
fr: { 'a.ts': { marked: 0, identical: 2 } },
|
||||
ja: { 'a.ts': { marked: 0, identical: 2 } },
|
||||
});
|
||||
});
|
||||
|
||||
it('counts a plural form en has no key for when it holds any of en’s forms', () => {
|
||||
// ru copies en's general form into the base and `few`, and en's `one` into `many`.
|
||||
expect(countUntranslated(new URL('i18n-plural/', FIXTURES))).toEqual({
|
||||
ru: { 'a.ts': { marked: 0, identical: 3 } },
|
||||
});
|
||||
});
|
||||
|
||||
it('fails closed on a locale folder on neither script list', () => {
|
||||
expect(() => countUntranslated(new URL('i18n-unlisted/', FIXTURES))).toThrow(/locale xx is on neither/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user