diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-10-07 17:25:43 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-10-07 17:25:50 -0700 |
| commit | d7b5b81b5d6ec55d0847b5171c3800a8f7b5c001 (patch) | |
| tree | d646d8339602599eee64910cd252de0df595bcfe /site/src/i18n.ts | |
| parent | 014443ef502eee0c337a5feb2aa0aeebb8d51557 (diff) | |
feat: add i18n translation (initial JP and EN)
Diffstat (limited to 'site/src/i18n.ts')
| -rw-r--r-- | site/src/i18n.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/site/src/i18n.ts b/site/src/i18n.ts new file mode 100644 index 0000000..9bf1aee --- /dev/null +++ b/site/src/i18n.ts @@ -0,0 +1,30 @@ +import i18n from 'i18next'; +import { initReactI18next } from 'react-i18next'; +import LanguageDetector from 'i18next-browser-languagedetector'; +import Backend from 'i18next-http-backend'; +import { updateHtmlLang } from './utils'; + +i18n + .use(Backend) + .use(LanguageDetector) + .use(initReactI18next) + .init({ + fallbackLng: 'en', + backend: { + loadPath: '/locales/{{lng}}/{{ns}}.json', + }, + + interpolation: { + escapeValue: false, + } + }); + +// Set the HTML lang attribute when language changes +i18n.on('languageChanged', (lng) => { + updateHtmlLang(lng); +}); + +// Initialize HTML lang with the current language +updateHtmlLang(i18n.language); + +export default i18n; |
