Repository navigation
feat(i18n): add Brazilian Portuguese (pt) translation #5245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
giovannimnz
wants to merge
15
commits into
QuantumNous:main
from
giovannimnz:feat/portuguese-translation-clean
Closed
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4b2799b
feat(i18n): add Brazilian Portuguese (pt) translation
giovannimnz cfd4894
chore(deps): add vitest + testing-library for i18n tests
giovannimnz d669877
test(i18n): add normalizeInterfaceLanguage + pt fallback tests
giovannimnz 9a7fa32
feat(podman): native rootless Podman support + migration path
giovannimnz 5f0453f
docs(i18n): TRANSLATION-PT-BR guide — how the pt translation was made…
giovannimnz a1d5298
docs(audit): phase 7 SSO/docs/favicon audit + integration/middleware …
giovannimnz 1436a5e
feat(podman): add podman-validate.sh — pre-flight check without bring…
giovannimnz cf5d317
docs(podman): link podman-validate.sh in the verification checklist +…
giovannimnz 3c6ead0
chore(release): bump version to v2.11.0-rebrand.20260602
giovannimnz a21d740
chore(rebrand): v2.11.0-rebrand — new-api → router-ai-atius
giovannimnz ba45380
fix(docs): catch-all /docs/* subpath → redirect /docs/
giovannimnz 3a596ac
feat(frontend): add /login route as canonical alias for /sign-in
giovannimnz 2872449
chore(rebrand): v2.11.1 — port 3030 + network atius-ai-router_internal
giovannimnz 99163ec
fix(docs): SSO working end-to-end via Go helper for cookie decoding
giovannimnz 9012a9e
docs: map codebase — add .planning/codebase/ (ARCHITECTURE, STACK, ST…
giovannimnz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
web/default/src/features/profile/__tests__/language-preferences-card-integration.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| Copyright (C) 2023-2026 QuantumNous | ||
|
|
||
| Integration regression test for the bug: | ||
| - User selects "Português" in the top nav menu | ||
| - i18next stores "pt" (the canonical code) in localStorage | ||
| - User navigates to /profile | ||
| - The <Select> showed "English" because normalizeInterfaceLanguage | ||
| was case-sensitive: it lowercased the input to "pt" and then compared | ||
| against option codes case-sensitively, but the options array uses | ||
| mixed-case canonical codes. Fixed: the function now matches | ||
| case-insensitively and returns the canonical mixed-case code. | ||
| */ | ||
| import { describe, expect, test, vi } from 'vitest' | ||
| import { render, screen } from '@testing-library/react' | ||
| import { I18nextProvider } from 'react-i18next' | ||
| import { LanguagePreferencesCard } from '../components/language-preferences-card' | ||
| import { loadI18n } from '../../../test/setup' | ||
|
|
||
| vi.mock('@/stores/auth-store', () => ({ | ||
| useAuthStore: () => ({ auth: { user: { id: 1, username: 'giovanni' } } }), | ||
| })) | ||
| vi.mock('../api', () => ({ | ||
| updateUserLanguage: vi.fn(async () => ({ success: true })), | ||
| })) | ||
| vi.mock('../lib', () => ({ | ||
| parseUserSettings: (s?: Record<string, unknown> | null) => s ?? {}, | ||
| })) | ||
|
|
||
| describe('LanguagePreferencesCard integration: case-insensitive normalize', () => { | ||
| test('Select trigger shows "Português" when i18n.language is "pt"', async () => { | ||
| // Simulate the user state: i18n.language is "pt" (the canonical code) | ||
| const i18n = await loadI18n('pt') | ||
| expect(i18n.language).toBe('pt') | ||
|
|
||
| // Render the card. props.profile is null so the savedLanguage | ||
| // falls back to i18n.language. | ||
| render( | ||
| <I18nextProvider i18n={i18n}> | ||
| <LanguagePreferencesCard profile={null} onProfileUpdate={() => {}} /> | ||
| </I18nextProvider>, | ||
| ) | ||
|
|
||
| // The select trigger should display the Portuguese option label, | ||
| // NOT fall back to "English". Base UI's <Select.Trigger> renders | ||
| // a <button role="combobox"> without an accessible name; query | ||
| // by role and assert its visible text content. | ||
| const selectTrigger = screen.getByRole('combobox') | ||
| expect(selectTrigger).toHaveTextContent('Português') | ||
| }) | ||
| }) |
38 changes: 38 additions & 0 deletions
38
web/default/src/i18n/__tests__/normalize-interface-language.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| Copyright (C) 2023-2026 QuantumNous | ||
| */ | ||
| import { describe, expect, test } from 'vitest' | ||
| import { normalizeInterfaceLanguage } from '../languages' | ||
|
|
||
| describe('normalizeInterfaceLanguage (case-insensitive matching)', () => { | ||
| test('returns canonical code for exact matches', () => { | ||
| expect(normalizeInterfaceLanguage('en')).toBe('en') | ||
| expect(normalizeInterfaceLanguage('pt')).toBe('pt') | ||
| expect(normalizeInterfaceLanguage('zh')).toBe('zh') | ||
| }) | ||
|
|
||
| test('returns canonical code for case-insensitive matches (i18next-style)', () => { | ||
| // i18next's browser-languagedetector may store the language in mixed | ||
| // case (e.g. 'Pt' or 'PT'); the function must resolve to the canonical | ||
| // option code regardless of input casing. | ||
| expect(normalizeInterfaceLanguage('PT')).toBe('pt') | ||
| expect(normalizeInterfaceLanguage('Pt')).toBe('pt') | ||
| }) | ||
|
|
||
| test('handles zh variants', () => { | ||
| expect(normalizeInterfaceLanguage('zh-CN')).toBe('zh') | ||
| expect(normalizeInterfaceLanguage('zh-TW')).toBe('zh') | ||
| expect(normalizeInterfaceLanguage('ZH')).toBe('zh') | ||
| }) | ||
|
|
||
| test('falls back to "en" for unknown languages', () => { | ||
| expect(normalizeInterfaceLanguage('xx')).toBe('en') | ||
| expect(normalizeInterfaceLanguage('klingon')).toBe('en') | ||
| }) | ||
|
|
||
| test('handles empty / null / undefined', () => { | ||
| expect(normalizeInterfaceLanguage()).toBe('en') | ||
| expect(normalizeInterfaceLanguage(null)).toBe('en') | ||
| expect(normalizeInterfaceLanguage(undefined)).toBe('en') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| Copyright (C) 2023-2026 QuantumNous | ||
|
|
||
| Verifies that i18next's region-less fallback resolves to the canonical | ||
| 'pt' entry. This is the explicit test of the fallback machinery described | ||
| in src/i18n/config.ts (supportedLngs includes 'pt'). | ||
| */ | ||
| import { describe, expect, test } from 'vitest' | ||
| import { loadI18n } from '../../test/setup' | ||
|
|
||
| describe('i18next fallback resolves region-less codes to canonical', () => { | ||
| test('changeLanguage("pt") lands on "pt" exactly (no lowercasing)', async () => { | ||
| const i18n = await loadI18n('en') | ||
| await i18n.changeLanguage('pt') | ||
| expect(i18n.language).toBe('pt') | ||
| }) | ||
|
|
||
| test('loadI18n("pt") lands on "pt" exactly', async () => { | ||
| const i18n = await loadI18n('pt') | ||
| expect(i18n.language).toBe('pt') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.