Skip to content

feat(T-29): add UI localization with PT/EN support#65

Open
raschmitt wants to merge 10 commits into
mainfrom
feat/ui-localization
Open

feat(T-29): add UI localization with PT/EN support#65
raschmitt wants to merge 10 commits into
mainfrom
feat/ui-localization

Conversation

@raschmitt
Copy link
Copy Markdown
Owner

Task/Issue

T-29 · UI localization (PT / EN)

What?

  • Add i18n object in app.js with Portuguese and English string maps covering all user-visible text
  • Add detectLanguage() that reads navigator.language on page load
  • Add applyLocale(lang) function exposed on globalThis to apply localized strings
  • Add element IDs (open-wa-text, about-blurb) in index.html for localization targeting
  • Add playwright as a test dependency for browser-level JS testing
  • Add BDD feature file with 5 scenarios covering Portuguese, English, fallback, and unset language
  • Add BDD step definitions using Playwright to stub navigator.language and verify string mapping
  • Add init-path tests that stub navigator.language via addInitScript and verify locale is applied on page load

Why?

  • Users in Portuguese-speaking regions should see the UI in their language
  • Adding new locales later requires only a new key in the i18n object
  • BDD scenarios ensure all acceptance criteria are covered by automated tests

- Add i18n object in app.js with Portuguese and English string maps
- Add applyLocale() function to localise all user-visible text
- Add detectLanguage() that reads navigator.language on page load
- Add playwright for browser-level JS testing
- Add BDD feature file and step definitions for localization scenarios
- Add init path tests verifying locale is applied on startup

Co-authored-by: claude <claude@anthropic.com>
@raschmitt
Copy link
Copy Markdown
Owner Author

🤖 This PR was automatically generated by the auto-implement workflow using OpenCode CLI with the big-pickle model.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions
Copy link
Copy Markdown
Contributor

raschmitt and others added 7 commits May 10, 2026 18:31
The test job runs Playwright-based tests but never installs the
Chromium browsers, causing all UI localization tests to fail.
Add 'playwright install chromium' step before running pytest.

Co-authored-by: opencode <noreply@opencode.ai>
The mutation job runs pytest through check_mutation_score.py,
which now includes Playwright-based tests. Add browser install
so mutation tests don't fail with missing executable.

Co-authored-by: opencode <noreply@opencode.ai>
Add a globe+text language toggle to cycle between PT and EN,
matching the theme toggle style. Toggle preference is persisted
in localStorage, and detectLanguage() checks saved preference
before falling back to navigator.language.

Co-authored-by: opencode <noreply@opencode.ai>
Append git commit hash as query parameter to app.js URL in
preview builds so browsers fetch the latest version instead
of serving a stale cached copy.

Co-authored-by: opencode <noreply@opencode.ai>
Remove the globe SVG from the language toggle and use just
the language code (EN/PT) so the button matches the theme
toggle size.

Co-authored-by: opencode <noreply@opencode.ai>
Move Portuguese and English string maps from a single i18n
object in app.js to dedicated files under app/static/js/i18n/:

  i18n/en.js    — English strings
  i18n/pt.js    — Portuguese strings
  i18n/loader.js — detectLanguage() and applyLocale()
                   (exposed on globalThis)

Update index.html to load the three scripts before app.js.
Update preview.yml build step to copy the i18n subdirectory.

Co-authored-by: opencode <noreply@opencode.ai>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

💡 AI Code Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98cb270e30

ℹ️ About this review

This review was generated automatically by the AI Code Review workflow using OpenCode CLI with the Minimax M2.5 Free model.

Reviews are triggered on every pull request push.

@sonarqubecloud
Copy link
Copy Markdown

(function () {
const i18n = globalThis.__i18n || {};

function detectLanguage() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge localStorage overrides navigator.language on page load

The task says detection should use navigator.language on page load. detectLanguage() checks localStorage.getItem('lang') first — meaning if a user previously toggled language, the saved value takes priority on every subsequent load, not just on explicit toggle. This is fine for the toggle feature but violates the stated detection logic for initial page load.

Comment thread app/static/js/app.js
if (langText) langText.textContent = globalThis.__currentLang.toUpperCase();
if (langToggle) {
langToggle.addEventListener('click', () => {
const next = globalThis.__currentLang === 'pt' ? 'en' : 'pt';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Toggle uses __currentLang set by a side effect

The toggle derives next from globalThis.__currentLang, which is set as a side effect inside applyLocale(). This works but is implicit — a dedicated getter (e.g. getCurrentLang()) would be cleaner and easier to test.

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