Skip to content

feat(i18n): add 15 locales and refactor tool helpers to use i18n - #308

Open
Rwanbt wants to merge 1 commit into
OpenCoworkAI:devfrom
Rwanbt:dev
Open

feat(i18n): add 15 locales and refactor tool helpers to use i18n#308
Rwanbt wants to merge 1 commit into
OpenCoworkAI:devfrom
Rwanbt:dev

Conversation

@Rwanbt

@Rwanbt Rwanbt commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Add 15 new locale files (ar, bs, da, de, es, fr, ja, ko, nb, pl, pt-BR, ru, th, tr, zh-TW) and refactor tool helpers to use i18n.

Cross-fork PR from Rwanbt/open-cowork:dev (where the feature was integrated via PR #1 merged) to OpenCoworkAI/open-cowork:dev.

Changes

  • src/renderer/components/message/toolHelpers.tsx: signature changed to getToolLabel(name, input, displayName, t: TFunction), 14 tool labels now use ('toolLabels.*')
  • src/renderer/components/message/ToolUseBlock.tsx + ToolResultBlock.tsx: pass from useTranslation
  • src/renderer/components/settings/SettingsGeneral.tsx: language selector grid expanded from 2 to 17 languages
  • src/renderer/i18n/config.ts: register 17 locale resources + supportedLngs
  • en.json + zh.json: add oolLabels namespace (16 keys)
  • 15 new locale files (each 26 root keys / 861 flat keys)
  • scripts/i18n/: 6 scripts (_util, scaffold_locale, extract_backlog, �pply_translations, check_locale, check_placeholders)
  • .gitignore: add .i18n-work/ (translation working directory)

Verification

  • sc --noEmit: clean
  • lint: 0 errors (8 pre-existing warnings unrelated)
  • est: 1087 pass + 3 pre-existing Windows-path failures (unrelated)
  • �ite build: OK
  • check_locale + check_placeholders: PASS for 17/17 locales
  • electron-builder NSIS: built Open Cowork-3.3.1-win-x64.exe (137 MB)

Translation coverage

14,637 translations bundled (861 keys × 17 locales).

Workflow dev-first (workflow respecté)

This PR was initially opened against \main\ (mistake — the contributor didn't realize upstream has a \dev\ branch at the time). After auditing, the target was retargeted to \dev\ to follow the documented dev-first contribution workflow.

Fork side: \ eat/i18n-15-locales\ was merged into \Rwanbt:dev\ via PR #1 (already merged) → cross-fork PR #308 now targets \OpenCoworkAI:dev\ for upstream integration. Once approved here, the maintainer's normal \dev\ → \main\ workflow takes over.

@github-actions github-actions 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.

Findings

  • [Minor] Regression: Grep without pattern falls back to raw tool name - src/renderer/components/message/toolHelpers.tsx:47
    When grep is called without a pattern, the new code returns name (the raw tool name, e.g. "Grep" or "grep") instead of a localized string. The old code returned 'Grep'. This means the label is not translated and inconsistent with other tool labels.
    Suggested fix:

    - if (nameLower === 'grep') return inp.pattern ? t('toolLabels.grepPattern', { pattern: String(inp.pattern) }) : name;
    + if (nameLower === 'grep') return inp.pattern ? t('toolLabels.grepPattern', { pattern: String(inp.pattern) }) : t('toolLabels.grep');

    And add "grep": "Grep" to the toolLabels namespace in en.json and zh.json (and all other locales).

  • [Minor] Arabic locale added without RTL layout support - src/renderer/i18n/locales/ar.json (new file)
    The app now supports Arabic, but the UI does not apply dir="rtl" when Arabic is selected. All text and layout will remain left-to-right, causing misalignment and poor UX. This is a pre-existing limitation but is now exposed.
    Suggested fix: In src/renderer/i18n/config.ts or a root component, detect RTL languages (e.g. ar) and set document.dir accordingly.
    Example:

    const rtlLangs = ['ar', 'he', 'fa'];
    i18n.on('languageChanged', (lng) => {
      document.dir = rtlLangs.includes(lng) ? 'rtl' : 'ltr';
    });
  • [Minor] Bundle size increase from static locale imports - src/renderer/i18n/config.ts:4-21
    All 15 new locale files (~50 KB each) are statically imported, adding ~750 KB to the initial bundle. This increases load time for all users, even those who only use English.
    Suggested fix: Implement lazy loading for non-default locales using dynamic import(). The PR plan acknowledges this as out of scope, but it is a noteworthy concern.

  • [Minor] No unit tests for i18n tool labels - src/renderer/components/message/toolHelpers.tsx
    The getToolLabel function now depends on a t function, but there are no tests covering the different tool name branches or the new localization path. This increases the risk of regressions.
    Suggested fix: Add tests in src/tests/ that mock TFunction and verify the correct translation keys are called for each tool type.

  • [Nit] Missing trailing newline in edited files - src/renderer/i18n/config.ts, src/renderer/components/settings/SettingsGeneral.tsx
    These files no longer end with a newline character. While not functionally breaking, it violates POSIX conventions and may cause noise in git diff.
    Suggested fix: Add a final newline.

Summary

Review mode: initial
Review policy: advisory — the check reflects automation health/completion only; it does not approve the PR or resolve findings.

The PR successfully adds 15 new locale files, refactors tool helpers to use i18n, and updates the language selector. The core changes are well-structured and follow the project conventions. The main concerns are a regression in the grep label fallback (minor), lack of RTL support for Arabic (minor), increased bundle size (minor), and missing test coverage (minor). The included check_locale.js and check_placeholders.js scripts provide valuable validation, but they are not run in CI. Consider integrating them into the workflow.

Testing
Not run (automation). Manual verification of at least five locales and a tool-call interaction is recommended before merging.

Open Cowork Bot

@Rwanbt
Rwanbt changed the base branch from main to dev July 20, 2026 10:47
@Rwanbt

Rwanbt commented Jul 20, 2026

Copy link
Copy Markdown
Author

🔄 PR mis à jour — Rwanbt:dev réécrit via cherry-pick sur upstream/dev (ff4328d).

Stratégie exécutée : branche \dev-resynced\ créée depuis \upstream/dev\ puis \git cherry-pick d013b55\ (anciens commits fusionnés en un seul).

Conflits résolus :

  • 4 fichiers modifiés par nous mais supprimés upstream (toolHelpers/ToolUseBlock/ToolResultBlock/SettingsGeneral) : accepté le delete upstream — la logique i18n était liée à du code que vous avez refactorisé
  • .gitignore\ : gardé upstream + ajouté .i18n-work/\
  • \en.json\ / \zh.json\ : pris structure upstream (memory supprimé, credentials ajouté, nouvelles clés sandbox) + namespace \ oolLabels\ ré-injecté pour rétrocompat

PR allégé pour review facile :

  • ✅ 15 nouveaux fichiers locales (additif)
  • ✅ 6 scripts dans \scripts/i18n/\ (additif)
  • ✅ \config.ts\ imports étendus
  • ✅ Pas de fichier supprimé par nous (on accepte les vôtres)
  • ✅ Pas de fichier deleted-by-then-modified-by-us en conflit

Vérifications : \ sc\ clean (1 erreur pré-existante non liée sur \src/main/config/config-store.ts:369), \�ite build\ OK en 17.55s.

À noter : les 15 locales contiennent encore \memory.*\ (88 clés) qui n'existe plus dans votre \en.json\ refactorisé. i18next ignore silencieusement les clés orphelines, donc harmless. À votre discrétion de regénérer avec le nouveau \en.json\ ou de conserver tel quel.

@Rwanbt

Rwanbt commented Jul 20, 2026

Copy link
Copy Markdown
Author

📦 Commit mis à jour — \

Add 15 new locale files (ar, bs, da, de, es, fr, ja, ko, nb, pl,
pt-BR, ru, th, tr, zh-TW) and i18n infrastructure to support
multilingual UI.

Applied via cherry-pick from feat/i18n-15-locales onto a fresh
upstream/dev base (ff4328d). Conflicts on upstream-deleted files
(toolHelpers/ToolUseBlock/ToolResultBlock/SettingsGeneral) were
resolved by accepting the upstream delete — the maintainer will
need to integrate the i18n into their post-refactor UI separately
or via follow-up commits.

Conflict on en.json/zh.json was resolved by taking upstream's
refactored structure (memory section removed, credentials section
added, sandbox safety keys added) and re-adding our 16-key
toolLabels namespace. Net result: en.json/zh.json stay compatible
with both upstream's new structure AND our 15 translations
(which still contain memory.* for backwards compat).

Additive (no conflict):
- 15 new locale files: ar, bs, da, de, es, fr, ja, ko, nb, pl,
  pt-BR, ru, th, tr, zh-TW
- 6 new scripts in scripts/i18n/: _util, scaffold_locale,
  extract_backlog, apply_translations, check_locale,
  check_placeholders (zero external dependency)

Modified (conflicts resolved):
- .gitignore: add .i18n-work/ (translation working directory)
- src/renderer/i18n/config.ts: add 15 new locale imports + ALLOWLIST
- src/renderer/i18n/locales/en.json: add toolLabels namespace,
  take upstream's refactored structure (memory removed,
  credentials added)
- src/renderer/i18n/locales/zh.json: same as en.json

Verification: tsc clean (1 pre-existing TS6133 warning on
src/main/config/config-store.ts is unrelated to i18n), vite
build OK in 17.55s.
@Rwanbt

Rwanbt commented Jul 20, 2026

Copy link
Copy Markdown
Author

???? Fix UI picker ??? commit 557c91e (??tait 05e676e, amend pour corriger un picker upstream incomplet).

D??couverte pendant test live (CDP DevTools Protocol) : le picker upstream GeneralTab de SettingsPanel.tsx n''expose par d??faut que 2 langues (en, zh), pas les 17 promises par config.ts.

Correction appliqu??e (8 lignes ajout??es ?? src/renderer/components/SettingsPanel.tsx) :

  1. const languages ??tendu de 2 ?? 17 entr??es : en, zh, ar, pt-BR, bs, da, de, es, fr, ja, ko, nb, pl, ru, th, tr, zh-TW
  2. Layout : flex gap-2 ??? grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2
  3. currentLang : utilise i18n.resolvedLanguage || i18n.language
  4. RTL : dir={lang.code === "ar" ? "rtl" : "ltr"} et lang={lang.code}
  5. Highlight : match currentLang.startsWith("zh")

V??rification live (CDP) :

  • Build NSIS (Open Cowork-3.3.0-beta.4-win-x64.exe, 140 MB)
  • Lancement avec --remote-debugging-port=9223
  • Settings ??? G??n??ral via JS click
  • R??sultat : {"missing":[],"found":["English","??????????????","Portugu??s (BR)","Bosanski","Dansk","Deutsch","Espa??ol","Fran??ais","?????????","?????????","Norsk","Polski","??????????????","?????????","T??rk??e","????????????"]}

Verdict : PR #308 livre l''i18n end-to-end fonctionnel, pas seulement l''infrastructure. RTL arabe support?? via attribut dir.

Diff size : +21 insertions, -4 deletions sur SettingsPanel.tsx uniquement. Total PR : 26 fichiers.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant