Add System Language Detection and Extension Locale Metadata#205
Add System Language Detection and Extension Locale Metadata#205prem-k-r wants to merge 3 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (5)
_locales/uk/messages.json (1)
2-4: 💤 Low valueConsider keeping "Material You" in English for consistency.
The extension name transliterates "Material You New Tab" to Cyrillic ("Матеріал Ю Нью Таб"), but the description keeps "Material You" in English. For consistency and brand recognition, consider keeping the product name in English in both fields (e.g., "MYNT: Material You New Tab").
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@_locales/uk/messages.json` around lines 2 - 4, The extensionName value in _locales/uk/messages.json currently transliterates "Material You New Tab" to Cyrillic; update the "extensionName" message to keep the product name "Material You" in English for consistency (e.g., set "message" to "MYNT: Material You New Tab") so it matches the description and preserves brand recognition._locales/th/messages.json (1)
1-8: 💤 Low valueVerify transliteration approach for product name.
The extension name transliterates "Material You New Tab" into Thai script ("แมทีเรียล ยู นิว แท็บ"). Consider whether "Material You" should remain in English as a Google product name (e.g., "MYNT: Material You นิว แท็บ" or "MYNT: Material You New Tab").
Please verify with a native Thai speaker that the current transliteration approach aligns with localization best practices and user expectations.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@_locales/th/messages.json` around lines 1 - 8, Review the Thai strings in the localization keys extensionName and extensionDescription and confirm the transliteration choice for the product name "Material You": consult a native Thai speaker or localization guideline and either keep "Material You" in English (e.g., "MYNT: Material You นิว แท็บ" or "MYNT: Material You New Tab") or provide an approved Thai rendering; then update the values for extensionName and extensionDescription accordingly to use the chosen form consistently (ensure "Material You" appears identically in both keys if kept in English, and spell-check the surrounding Thai text)._locales/mr/messages.json (1)
1-8: 💤 Low valueVerify Marathi translation accuracy.
The JSON structure is valid and uses the correct Devanagari script. Please verify with a native Marathi speaker that the translation is natural and accurate, particularly the consistency of keeping "Material You" in English in the description while transliterating it in the extension name.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@_locales/mr/messages.json` around lines 1 - 8, Confirm the Marathi translations for extensionName and extensionDescription with a native Marathi speaker: validate natural phrasing, idiomatic use of Devanagari, and consistency in how "Material You" is represented (extensionName currently transliterates it as "मटेरियल यू" while extensionDescription keeps it in English); if inconsistent, choose one representation (either transliterate in both or use English in both) and update the messages for extensionName and extensionDescription accordingly to ensure fluent, native-sounding text._locales/ru/messages.json (1)
2-4: 💤 Low valueConsider keeping "Material You" in English for consistency.
The extension name transliterates "Material You New Tab" to Cyrillic ("Материал Ю Нью Таб"), but the description keeps "Material You" in English. For consistency and brand recognition, consider keeping the product name in English in both fields (e.g., "MYNT: Material You New Tab").
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@_locales/ru/messages.json` around lines 2 - 4, The "extensionName" localization entry currently transliterates the product name to Cyrillic ("Материал Ю Нью Таб"); update the "extensionName" message value to keep the brand in English (e.g., "MYNT: Material You New Tab") so it matches the description and preserves consistency/brand recognition — edit the "extensionName" key in _locales/ru/messages.json (and scan other ru keys like any description entries) to use the English product name.scripts/languages.js (1)
137-151: ⚡ Quick winConsider
navigator.languagesovernavigator.languagefor better polyglot coverage.
navigator.languagereturns only the single top-preference language. If that language has no translation (e.g.,mifor Māori), the function falls back to"en"even when the user has a supported language listed second (e.g.,de). Iteratingnavigator.languageswould find the best supported match across the user's full preference list.♻️ Proposed refactor
function getDetectedLanguage(translations) { const supported = Object.keys(translations); - const raw = typeof navigator !== "undefined" ? navigator.language : "en"; - const mapped = langMap[raw] || raw; - const normalized = mapped.replace(/-/g, "_"); - const base = mapped.split(/[-_]/)[0]; - - return supported.includes(mapped) - ? mapped - : supported.includes(normalized) - ? normalized - : supported.includes(base) - ? base - : "en"; + const langs = typeof navigator !== "undefined" + ? Array.from(navigator.languages || [navigator.language]) + : ["en"]; + + for (const raw of langs) { + const mapped = langMap[raw] || raw; + const normalized = mapped.replace(/-/g, "_"); + const base = mapped.split(/[-_]/)[0]; + if (supported.includes(mapped)) return mapped; + if (supported.includes(normalized)) return normalized; + if (supported.includes(base)) return base; + } + return "en"; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/languages.js` around lines 137 - 151, Update getDetectedLanguage to consult the user's full preference list (navigator.languages) instead of only navigator.language: build an array of candidate language tags using navigator.languages when available (fallback to [navigator.language] or ["en"]), then for each candidate apply the same langMap lookup, normalization (replace "-" with "_"), and base extraction logic and return the first match that exists in Object.keys(translations); if none match, fall back to "en". Keep references to getDetectedLanguage, langMap and translations to locate where to implement the iteration and matching logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@_locales/el/messages.json`:
- Around line 2-4: The Greek locale currently transliterates the brand name
("extensionName" message) into Greek script; update the "message" value for
extensionName to keep the brand "Material You" in English and translate only the
generic part (e.g., "New Tab") or leave the rest in English to match other
locales. Locate the extensionName entry in _locales/.../messages.json and change
the string to something like "MYNT: Material You - Νέα Καρτέλα" or "MYNT:
Material You New Tab" so the brand stays in English while the descriptive term
is idiomatic Greek.
In `@_locales/id/messages.json`:
- Line 3: The extensionName localization is inconsistent: update the
"extensionName" entry (the JSON key that currently has "message": "MYNT:
Material You New Tab" in _locales/id/messages.json) across all locale files to
follow a single strategy—preferably set the "message" value to the English brand
string "MYNT: Material You New Tab" in every locale file for consistency (Option
1), or alternatively provide translated strings for every locale (Option 2);
modify each locale's messages.json so the "extensionName" key is standardized
accordingly.
In `@manifest.json`:
- Line 4: manifest.json currently has a mismatched/downgraded "version" value;
update the "version" key in manifest.json to match the intended version used in
manifest(firefox).json so both manifests share the same version string, ensuring
consistency across "version" entries.
In `@manifest`(firefox).json:
- Line 4: The manifest version was accidentally decremented to "3.3.503" which
will block store submissions and prevent auto-updates; update the version fields
in both manifest(firefox).json and manifest.json to a higher patch than the
currently published "3.3.504" (e.g., "3.3.505" or your release-next version) so
the new i18n feature is treated as an upgrade and allowed by the stores.
In `@scripts/languages.js`:
- Line 141: The normalization currently assigns normalized from
mapped.replace("-", "_"), which only substitutes the first hyphen; update the
normalized computation in scripts/languages.js (the mapped → normalized logic)
to replace all hyphens (e.g., use String.prototype.replaceAll or a
global-regex-based replace) so values like "en-Latn-US" become "en_Latn_US"
consistently.
---
Nitpick comments:
In `@_locales/mr/messages.json`:
- Around line 1-8: Confirm the Marathi translations for extensionName and
extensionDescription with a native Marathi speaker: validate natural phrasing,
idiomatic use of Devanagari, and consistency in how "Material You" is
represented (extensionName currently transliterates it as "मटेरियल यू" while
extensionDescription keeps it in English); if inconsistent, choose one
representation (either transliterate in both or use English in both) and update
the messages for extensionName and extensionDescription accordingly to ensure
fluent, native-sounding text.
In `@_locales/ru/messages.json`:
- Around line 2-4: The "extensionName" localization entry currently
transliterates the product name to Cyrillic ("Материал Ю Нью Таб"); update the
"extensionName" message value to keep the brand in English (e.g., "MYNT:
Material You New Tab") so it matches the description and preserves
consistency/brand recognition — edit the "extensionName" key in
_locales/ru/messages.json (and scan other ru keys like any description entries)
to use the English product name.
In `@_locales/th/messages.json`:
- Around line 1-8: Review the Thai strings in the localization keys
extensionName and extensionDescription and confirm the transliteration choice
for the product name "Material You": consult a native Thai speaker or
localization guideline and either keep "Material You" in English (e.g., "MYNT:
Material You นิว แท็บ" or "MYNT: Material You New Tab") or provide an approved
Thai rendering; then update the values for extensionName and
extensionDescription accordingly to use the chosen form consistently (ensure
"Material You" appears identically in both keys if kept in English, and
spell-check the surrounding Thai text).
In `@_locales/uk/messages.json`:
- Around line 2-4: The extensionName value in _locales/uk/messages.json
currently transliterates "Material You New Tab" to Cyrillic; update the
"extensionName" message to keep the product name "Material You" in English for
consistency (e.g., set "message" to "MYNT: Material You New Tab") so it matches
the description and preserves brand recognition.
In `@scripts/languages.js`:
- Around line 137-151: Update getDetectedLanguage to consult the user's full
preference list (navigator.languages) instead of only navigator.language: build
an array of candidate language tags using navigator.languages when available
(fallback to [navigator.language] or ["en"]), then for each candidate apply the
same langMap lookup, normalization (replace "-" with "_"), and base extraction
logic and return the first match that exists in Object.keys(translations); if
none match, fall back to "en". Keep references to getDetectedLanguage, langMap
and translations to locate where to implement the iteration and matching logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 717cafa7-f7a5-4fb4-a4dc-0fd76862ca62
📒 Files selected for processing (38)
.gitattributes_locales/README.md_locales/ar/messages.json_locales/az/messages.json_locales/bn/messages.json_locales/cs/messages.json_locales/de/messages.json_locales/el/messages.json_locales/en/messages.json_locales/es/messages.json_locales/fa/messages.json_locales/fr/messages.json_locales/hi/messages.json_locales/hu/messages.json_locales/id/messages.json_locales/it/messages.json_locales/ja/messages.json_locales/ko/messages.json_locales/mr/messages.json_locales/ne/messages.json_locales/pl/messages.json_locales/pt_BR/messages.json_locales/ru/messages.json_locales/sl/messages.json_locales/sv/messages.json_locales/ta/messages.json_locales/th/messages.json_locales/tr/messages.json_locales/uk/messages.json_locales/ur/messages.json_locales/uz/messages.json_locales/vi/messages.json_locales/zh_CN/messages.json_locales/zh_TW/messages.jsonindex.htmlmanifest(firefox).jsonmanifest.jsonscripts/languages.js
| "extensionName": { | ||
| "message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ" | ||
| }, |
There was a problem hiding this comment.
Consider keeping the "Material You" brand name in English for the Greek extension name.
"Μάτεριαλ Γιου Νιου Ταμπ" is a full phonetic transliteration of an English brand name, which is unusual and looks unnatural to Greek tech users — Google itself does not transliterate "Material You" to Greek script. The French locale keeps the full English name; the Chinese locale keeps "Material You" in English and only translates "New Tab". Either of those patterns would be more idiomatic:
- "message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ"
+ "message": "MYNT: Material You Νέα Καρτέλα"or simply:
- "message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ"
+ "message": "MYNT: Material You New Tab"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "extensionName": { | |
| "message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ" | |
| }, | |
| "extensionName": { | |
| "message": "MYNT: Material You Νέα Καρτέλα" | |
| }, |
| "extensionName": { | |
| "message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ" | |
| }, | |
| "extensionName": { | |
| "message": "MYNT: Material You New Tab" | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@_locales/el/messages.json` around lines 2 - 4, The Greek locale currently
transliterates the brand name ("extensionName" message) into Greek script;
update the "message" value for extensionName to keep the brand "Material You" in
English and translate only the generic part (e.g., "New Tab") or leave the rest
in English to match other locales. Locate the extensionName entry in
_locales/.../messages.json and change the string to something like "MYNT:
Material You - Νέα Καρτέλα" or "MYNT: Material You New Tab" so the brand stays
in English while the descriptive term is idiomatic Greek.
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "extensionName": { | |||
| "message": "MYNT: Material You New Tab" | |||
There was a problem hiding this comment.
Inconsistent extensionName localization across locale files.
The extensionName field is translated in only 2 out of 8 locale files (Nepali and Japanese), while the other 6 locales (Azerbaijani, German, Swedish, Czech, Italian, Indonesian) keep it in English. This creates an inconsistent localization strategy.
For a cohesive i18n implementation, standardize the approach:
- Option 1 (recommended): Keep "MYNT: Material You New Tab" in English across all locales to maintain brand consistency
- Option 2: Translate the extensionName in all locales for complete localization
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@_locales/id/messages.json` at line 3, The extensionName localization is
inconsistent: update the "extensionName" entry (the JSON key that currently has
"message": "MYNT: Material You New Tab" in _locales/id/messages.json) across all
locale files to follow a single strategy—preferably set the "message" value to
the English brand string "MYNT: Material You New Tab" in every locale file for
consistency (Option 1), or alternatively provide translated strings for every
locale (Option 2); modify each locale's messages.json so the "extensionName" key
is standardized accordingly.
| const supported = Object.keys(translations); | ||
| const raw = typeof navigator !== "undefined" ? navigator.language : "en"; | ||
| const mapped = langMap[raw] || raw; | ||
| const normalized = mapped.replace("-", "_"); |
There was a problem hiding this comment.
replace("-", "_") only replaces the first hyphen — use replaceAll or a regex.
String.prototype.replace with a string argument is single-occurrence. For a mapped value containing multiple hyphens (e.g., en-Latn-US not in langMap), normalized becomes en_Latn-US instead of en_Latn_US. The base fallback typically rescues this in practice, but the logic is technically incorrect.
🐛 Proposed fix
- const normalized = mapped.replace("-", "_");
+ const normalized = mapped.replace(/-/g, "_");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/languages.js` at line 141, The normalization currently assigns
normalized from mapped.replace("-", "_"), which only substitutes the first
hyphen; update the normalized computation in scripts/languages.js (the mapped →
normalized logic) to replace all hyphens (e.g., use String.prototype.replaceAll
or a global-regex-based replace) so values like "en-Latn-US" become "en_Latn_US"
consistently.
|
Yay.... I will help you too. |
What I’ve done:
What is NOT done, and currently not planned:
chrome.i18n/browser.i18n.Switching completely to
chrome.i18nwould also mean losing the custom language selector. Users would no longer be able to change the extension language manually, since the extension language would always follow the browser language.Note: AI assisted, I still need to review, refine, and enhance parts of the code before finalizing the PR.