Skip to content

feat(i18n): add Brazilian and European Portuguese locales (pt-BR, pt-PT)#579

Open
prenansantana wants to merge 4 commits into666ghj:mainfrom
prenansantana:prenansantana/i18n-pt
Open

feat(i18n): add Brazilian and European Portuguese locales (pt-BR, pt-PT)#579
prenansantana wants to merge 4 commits into666ghj:mainfrom
prenansantana:prenansantana/i18n-pt

Conversation

@prenansantana
Copy link
Copy Markdown

Summary

Adds Brazilian Portuguese (pt-br) and European Portuguese (pt-pt) as separate locales, expanding language coverage to ~260M Portuguese speakers across Brazil, Portugal, and Lusophone Africa.

This also fixes a silent bug: locales/languages.json had a "pt" entry with no matching translation file, so it never appeared in the language dropdown — frontend/src/i18n/index.js only registers locales whose JSON file exists. This PR replaces the orphan entry with two functional ones.

Why two variants instead of one generic pt?

The two Portuguese variants have meaningful differences in vocabulary, spelling, and idiomatic forms:

English pt-BR pt-PT
files arquivos ficheiros
user usuário utilizador
rounds rodadas rondas
survey pesquisa inquérito
Loading… Carregando… A carregar…
facts fatos factos

A single generic pt.json would feel awkward to roughly half of users. Keeping them separate matches how vue-i18n projects typically handle this. If maintainers prefer a single locale, happy to consolidate.

Changes

  • locales/pt-br.json — 633 strings (Brazilian Portuguese)
  • locales/pt-pt.json — 633 strings (European Portuguese, AO90 spelling where applicable)
  • locales/languages.json — replace orphan pt with pt-br and pt-pt, both with localized label and llmInstruction fields
  • README-PT-BR.md and README-PT-PT.md — translated READMEs
  • README.md and README-ZH.md — language navigation bar updated to include the new variants

How it works

Zero code changes:

  • Frontend auto-discovers via import.meta.glob('../../../locales/!(languages).json') in frontend/src/i18n/index.js
  • Backend auto-discovers via os.listdir(_locales_dir) in backend/app/utils/locale.py
  • LanguageSwitcher.vue renders from availableLocales, no hardcoded list

The new locales appear in the dropdown automatically and the backend resolves them via the Accept-Language header.

Validation

  • All 3 translation files (en, pt-br, pt-pt) have exactly 633 strings and identical key structure (verified programmatically)
  • No hardcoded language lists in the codebase
  • Technical terms preserved (GraphRAG, Zep, ReACT, ReportAgent, InsightForge, etc.)

Notes for maintenance

When new keys are added to en.json, both pt-br.json and pt-pt.json will need the corresponding translations. Consider documenting this in CONTRIBUTING.md if i18n contributions become regular.

Add pt-br and pt-pt as separate locales to cover both Portuguese variants
(~260M speakers combined). Replaces the orphan generic 'pt' entry in
languages.json that had no matching translation file.

- locales/pt-br.json: Brazilian Portuguese (633 strings)
- locales/pt-pt.json: European Portuguese with PT vocabulary
  (ficheiros, utilizador, rondas, inquérito, factos) and infinitive
  constructions ("A carregar", "A gerar")
- locales/languages.json: register pt-br and pt-pt with localized labels
  and llmInstruction values for backend prompts
Add README-PT-BR.md and README-PT-PT.md alongside the existing English
and Chinese versions. Update navigation links across all 4 README files
so users can switch between language variants.
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 25, 2026
Users who previously selected Portuguese have 'pt' stored in localStorage.
Without this guard, they would silently fall back to Chinese after the
'pt' key was replaced by 'pt-br'/'pt-pt'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant