Skip to content

Add System Language Detection and Extension Locale Metadata#205

Draft
prem-k-r wants to merge 3 commits into
mainfrom
system-language
Draft

Add System Language Detection and Extension Locale Metadata#205
prem-k-r wants to merge 3 commits into
mainfrom
system-language

Conversation

@prem-k-r

@prem-k-r prem-k-r commented May 4, 2026

Copy link
Copy Markdown
Owner

What I’ve done:

  1. Added a new option in the language selector: System
    • Detects the browser language and automatically switches to it.
  2. Added translations only for the extension name and description.
    • Why? Benefits:
      • In the Chrome Web Store, the extension will show as available in 32+ languages.
      • Users will see the extension name and description in their browser language.

What is NOT done, and currently not planned:

  • Translating all strings and switching fully to chrome.i18n/browser.i18n.
    Switching completely to chrome.i18n would 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.


@prem-k-r prem-k-r added enhancement New feature or request i18n/l10n Related to Internationalization or Localization labels May 4, 2026
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b8f71c3-4b97-422c-913e-ef3542165c4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@prem-k-r prem-k-r added the work-in-progress Under active development or being worked on by the assignee. Not ready to close or merge yet label May 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (5)
_locales/uk/messages.json (1)

2-4: 💤 Low value

Consider 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 value

Verify 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 value

Verify 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 value

Consider 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 win

Consider navigator.languages over navigator.language for better polyglot coverage.

navigator.language returns only the single top-preference language. If that language has no translation (e.g., mi for Māori), the function falls back to "en" even when the user has a supported language listed second (e.g., de). Iterating navigator.languages would 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf4e03 and 6397f2c.

📒 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.json
  • index.html
  • manifest(firefox).json
  • manifest.json
  • scripts/languages.js

Comment thread _locales/el/messages.json
Comment on lines +2 to +4
"extensionName": {
"message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ"
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
"extensionName": {
"message": "MYNT: Μάτεριαλ Γιου Νιου Ταμπ"
},
"extensionName": {
"message": "MYNT: Material You Νέα Καρτέλα"
},
Suggested change
"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.

Comment thread _locales/id/messages.json
@@ -0,0 +1,8 @@
{
"extensionName": {
"message": "MYNT: Material You New Tab"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Comment thread manifest.json
Comment thread manifest(firefox).json
Comment thread scripts/languages.js
const supported = Object.keys(translations);
const raw = typeof navigator !== "undefined" ? navigator.language : "en";
const mapped = langMap[raw] || raw;
const normalized = mapped.replace("-", "_");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@itz-rj-here

Copy link
Copy Markdown
Collaborator

Yay.... I will help you too.

@prem-k-r

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request i18n/l10n Related to Internationalization or Localization work-in-progress Under active development or being worked on by the assignee. Not ready to close or merge yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants