feat(i18n): add Brazilian Portuguese UI

This commit is contained in:
mzspicoli committed 2026-08-24 18:01:31 +02:00
1 parent f8024d344d
commit 00ba71d4df
7 files changed
+216 -8

No files matched your search

+2 -2
View File
@@ -4,12 +4,12 @@
export const LANGS = {
en: 'English', de: 'Deutsch', es: 'Español', fr: 'Français', it: 'Italiano',
pt: 'Português', pl: 'Polski', tr: 'Türkçe', ru: 'Русский', zh: '中文',
pt: 'Português (Portugal)', 'pt-BR': 'Português (Brasil)', pl: 'Polski', tr: 'Türkçe', ru: 'Русский', zh: '中文',
ko: '한국어', hi: 'हिन्दी'
}
export const INSTR_LANGS = ['en', 'es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko']
export const DATE_LOCALES = {
en: 'en-GB', de: 'de-DE', es: 'es-ES', fr: 'fr-FR', it: 'it-IT', pt: 'pt-PT',
en: 'en-GB', de: 'de-DE', es: 'es-ES', fr: 'fr-FR', it: 'it-IT', pt: 'pt-PT', 'pt-BR': 'pt-BR',
pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN'
}
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, test } from 'vitest'
import pt from '../locales/pt.js'
import ptBR from '../locales/pt-BR.js'
import { DATE_LOCALES, LANGS } from './i18n-core.js'
const placeholders = value => [...String(value).matchAll(/\{\d+\}/g)].map(match => match[0]).sort()
describe('Brazilian Portuguese locale', () => {
test('is a separately selectable locale with Brazilian date formatting', () => {
expect(LANGS.pt).toBe('Português (Portugal)')
expect(LANGS['pt-BR']).toBe('Português (Brasil)')
expect(DATE_LOCALES['pt-BR']).toBe('pt-BR')
})
test('has the complete key set and preserves interpolation placeholders', () => {
expect(Object.keys(ptBR).sort()).toEqual(Object.keys(pt).sort())
for (const [source, translated] of Object.entries(ptBR)) {
expect(placeholders(translated), source).toEqual(placeholders(source))
}
})
test('does not leak the most visible European Portuguese UI terms', () => {
const text = Object.values(ptBR).join('\n')
expect(text).not.toMatch(/\b(ficheiro\w*|telemóvel\w*|ecrã\w*|regist(?:ar|ado|ada|ados|adas|o|os)|eliminar|definições)\b/i)
expect(ptBR.Save).toBe('Salvar')
expect(ptBR.Settings).toBe('Configurações')
expect(ptBR['Delete workout']).toBe('Excluir treino')
})
})