mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-01 14:39:24 +02:00
Implementa infraestrutura de i18n com suporte inicial a English e Português (Brasil). Seletor de idioma em Settings > System > Preferences. - Instala react-i18next e i18next - Cria arquivos de tradução (en, pt-BR) para common, home, settings, layout - Traduz layout (sidebar, header, footer), home e settings/system - Persiste idioma via localStorage + KVStore (ui.language) - DiskAlertBanner integrado com i18n Closes #486
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import i18n from 'i18next'
|
|
import { initReactI18next } from 'react-i18next'
|
|
|
|
// Import all translation files
|
|
import enCommon from '~/locales/en/common.json'
|
|
import enHome from '~/locales/en/home.json'
|
|
import enSettings from '~/locales/en/settings.json'
|
|
import enLayout from '~/locales/en/layout.json'
|
|
|
|
import ptBRCommon from '~/locales/pt-BR/common.json'
|
|
import ptBRHome from '~/locales/pt-BR/home.json'
|
|
import ptBRSettings from '~/locales/pt-BR/settings.json'
|
|
import ptBRLayout from '~/locales/pt-BR/layout.json'
|
|
|
|
const savedLanguage = (() => {
|
|
try {
|
|
return localStorage.getItem('nomad:language') || 'en'
|
|
} catch {
|
|
return 'en'
|
|
}
|
|
})()
|
|
|
|
i18n.use(initReactI18next).init({
|
|
resources: {
|
|
en: {
|
|
common: enCommon,
|
|
home: enHome,
|
|
settings: enSettings,
|
|
layout: enLayout,
|
|
},
|
|
'pt-BR': {
|
|
common: ptBRCommon,
|
|
home: ptBRHome,
|
|
settings: ptBRSettings,
|
|
layout: ptBRLayout,
|
|
},
|
|
},
|
|
lng: savedLanguage,
|
|
fallbackLng: 'en',
|
|
defaultNS: 'common',
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
})
|
|
|
|
export default i18n
|