Repository navigation
fix: untranslated messages - #326
Conversation
Reviewer's GuideImplementationExtend the i18n checker to detect identical translations, missing native-script text, and untranslated text in nested ICU branches, while allowing known exceptions.
UITranslate and align common and wardrobe messages across locales, including queue, image-tool, upload, rotation, and background wording.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="frontend/scripts/i18n-check.mjs" line_range="131-132" />
<code_context>
+ // Argument names are stripped first so that a format-only pattern like '{time} - {occasion}'
+ // does not count as words.
+ if (SAME_IN_EVERY_LOCALE.has(key) || !/\p{L}/u.test(words(source[key]))) continue;
+ if (translations.length > 1 && new Set(translations.map((t) => t[key])).size === 1) {
+ problems.push(`every locale: '${key}' is identical in every translation, so it is untranslated or stale`);
+ }
+}
</code_context>
<issue_to_address>
**Valid shared strings fail parity**
When the parity check evaluates an intentionally shared key such as `nav.brandName` or `notifications.channels.placeholders.emailAddress`, the identical-translation check reports the key as untranslated or stale, including when the source and every translation use `wardrowbe`, so `i18n:parity` and `i18n:check` fail on valid locale data.
Exclude intentionally shared keys from the identical-translation check.
</issue_to_address>
### Comment 2
<location path="frontend/scripts/i18n-check.mjs" line_range="64" />
<code_context>
+ if (depth % 2 === 0) open.pop();
+ depth--;
+ } else if (depth > 0 && depth % 2 === 0) {
+ texts[open[open.length - 1]] += ch;
+ }
+ }
</code_context>
<issue_to_address>
**CJK plural translations fail validation**
When the parity check runs on the existing CJK ICU plural messages, `branchTexts` includes ICU selectors such as `one` and `other` in each branch’s text, so the CJK Latin-script check treats these required selector tokens as untranslated copy and fails the parity check on valid translations.
Exclude ICU branch selectors from the text returned by `branchTexts` before checking for Latin-script copy.
</issue_to_address>
### Comment 3
<location path="frontend/scripts/i18n-check.mjs" line_range="124" />
<code_context>
for (const key of targetKeys) if (!sourceKeys.has(key)) problems.push(`${locale}: extra key '${key}' not in ${SOURCE_LOCALE}`);
}
+const words = (value) => (typeof value === 'string' ? value.replace(/\{\w+\}/g, '') : '');
+
+const translations = locales.filter((l) => l !== SOURCE_LOCALE).map(loadLocale);
</code_context>
<issue_to_address>
**Numeric-only plurals fail checks**
When a message consists only of a number-only ICU plural or another ICU-formatted argument with no translatable literal text, `words()` strips only simple `{name}` arguments, so a valid count-only ICU message such as `{count, plural, one {#} other {#}}` still contains Latin syntax words. The CJK check then rejects a translation that correctly renders only a number, causing `i18n:check` to fail.
Parse ICU messages and apply script checks only to their literal text, excluding argument syntax and format keywords.
Also at `frontend/scripts/i18n-check.mjs:164-166`.
</issue_to_address>
### Comment 4
<location path="frontend/scripts/i18n-check.mjs" line_range="165-168" />
<code_context>
+ for (const key of sourceKeys) {
+ if (SAME_IN_EVERY_LOCALE.has(key) || LATIN_IN_CJK.has(key)) continue;
+ if (!/\p{Script=Latin}/u.test(words(source[key]))) continue;
+ if (!script.test(words(target[key]))) {
+ problems.push(`${locale}: '${key}' has no ${locale} text, so it is untranslated or stale`);
+ } else if (branchTexts(target[key]).some((t) => /\p{Script=Latin}/u.test(t) && !script.test(t))) {
+ problems.push(`${locale}: '${key}' has a plural or select branch with no ${locale} text`);
+ }
+ }
</code_context>
<issue_to_address>
**English copy passes CJK checks**
When a CJK message mixes English with native-script text inside a branch or outside an ICU branch, `branchTexts` checks branch bodies but misses ordinary text outside branches, and the script checks pass when a segment contains any native-script character. English copy therefore remains undetected and `i18n:check` accepts the mixed-language message.
Check all literal text segments, both inside and outside ICU branches, for untranslated English copy even when they also contain native-script text.
</issue_to_address>Sourcery assessment
Approval pending. 4 findings to address first.
Blocking findings: frontend/scripts/i18n-check.mjs:132, frontend/scripts/i18n-check.mjs:64, frontend/scripts/i18n-check.mjs:124, frontend/scripts/i18n-check.mjs:168
| if (translations.length > 1 && new Set(translations.map((t) => t[key])).size === 1) { | ||
| problems.push(`every locale: '${key}' is identical in every translation, so it is untranslated or stale`); |
There was a problem hiding this comment.
🔴 Critical · Valid shared strings fail parity
When the parity check evaluates an intentionally shared key such as nav.brandName or notifications.channels.placeholders.emailAddress, the identical-translation check reports the key as untranslated or stale, including when the source and every translation use wardrowbe, so i18n:parity and i18n:check fail on valid locale data.
Exclude intentionally shared keys from the identical-translation check.
Prompt for AI agents
In `frontend/scripts/i18n-check.mjs` at lines 131-132:
**Valid shared strings fail parity**
When the parity check evaluates an intentionally shared key such as `nav.brandName` or `notifications.channels.placeholders.emailAddress`, the identical-translation check reports the key as untranslated or stale, including when the source and every translation use `wardrowbe`, so `i18n:parity` and `i18n:check` fail on valid locale data.
Exclude intentionally shared keys from the identical-translation check.| if (depth % 2 === 0) open.pop(); | ||
| depth--; | ||
| } else if (depth > 0 && depth % 2 === 0) { | ||
| texts[open[open.length - 1]] += ch; |
There was a problem hiding this comment.
🔴 Critical · CJK plural translations fail validation
When the parity check runs on the existing CJK ICU plural messages, branchTexts includes ICU selectors such as one and other in each branch’s text, so the CJK Latin-script check treats these required selector tokens as untranslated copy and fails the parity check on valid translations.
Exclude ICU branch selectors from the text returned by branchTexts before checking for Latin-script copy.
Prompt for AI agents
In `frontend/scripts/i18n-check.mjs` at line 64:
**CJK plural translations fail validation**
When the parity check runs on the existing CJK ICU plural messages, `branchTexts` includes ICU selectors such as `one` and `other` in each branch’s text, so the CJK Latin-script check treats these required selector tokens as untranslated copy and fails the parity check on valid translations.
Exclude ICU branch selectors from the text returned by `branchTexts` before checking for Latin-script copy.| for (const key of targetKeys) if (!sourceKeys.has(key)) problems.push(`${locale}: extra key '${key}' not in ${SOURCE_LOCALE}`); | ||
| } | ||
|
|
||
| const words = (value) => (typeof value === 'string' ? value.replace(/\{\w+\}/g, '') : ''); |
There was a problem hiding this comment.
🟡 Medium · Numeric-only plurals fail checks
When a message consists only of a number-only ICU plural or another ICU-formatted argument with no translatable literal text, words() strips only simple {name} arguments, so a valid count-only ICU message such as {count, plural, one {#} other {#}} still contains Latin syntax words. The CJK check then rejects a translation that correctly renders only a number, causing i18n:check to fail.
Parse ICU messages and apply script checks only to their literal text, excluding argument syntax and format keywords.
Also at frontend/scripts/i18n-check.mjs:164-166.
Prompt for AI agents
In `frontend/scripts/i18n-check.mjs` at line 124:
**Numeric-only plurals fail checks**
When a message consists only of a number-only ICU plural or another ICU-formatted argument with no translatable literal text, `words()` strips only simple `{name}` arguments, so a valid count-only ICU message such as `{count, plural, one {#} other {#}}` still contains Latin syntax words. The CJK check then rejects a translation that correctly renders only a number, causing `i18n:check` to fail.
Parse ICU messages and apply script checks only to their literal text, excluding argument syntax and format keywords.
Also at `frontend/scripts/i18n-check.mjs:164-166`.| if (!script.test(words(target[key]))) { | ||
| problems.push(`${locale}: '${key}' has no ${locale} text, so it is untranslated or stale`); | ||
| } else if (branchTexts(target[key]).some((t) => /\p{Script=Latin}/u.test(t) && !script.test(t))) { | ||
| problems.push(`${locale}: '${key}' has a plural or select branch with no ${locale} text`); |
There was a problem hiding this comment.
🟡 Medium · English copy passes CJK checks
When a CJK message mixes English with native-script text inside a branch or outside an ICU branch, branchTexts checks branch bodies but misses ordinary text outside branches, and the script checks pass when a segment contains any native-script character. English copy therefore remains undetected and i18n:check accepts the mixed-language message.
Check all literal text segments, both inside and outside ICU branches, for untranslated English copy even when they also contain native-script text.
Prompt for AI agents
In `frontend/scripts/i18n-check.mjs` at lines 165-168:
**English copy passes CJK checks**
When a CJK message mixes English with native-script text inside a branch or outside an ICU branch, `branchTexts` checks branch bodies but misses ordinary text outside branches, and the script checks pass when a segment contains any native-script character. English copy therefore remains undetected and `i18n:check` accepts the mixed-language message.
Check all literal text segments, both inside and outside ICU branches, for untranslated English copy even when they also contain native-script text.
Description
Related Issue
Type of Change
Checklist
Testing
Test Environment
Tests Performed
Screenshots (if applicable)
Additional Notes
Summary by Sourcery
Prevent untranslated messages from reaching the application by correcting locale data and expanding internationalization checks.
Bug Fixes:
Enhancements: