From d7b5b81b5d6ec55d0847b5171c3800a8f7b5c001 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 7 Oct 2025 17:25:43 -0700 Subject: feat: add i18n translation (initial JP and EN) --- site/src/i18n.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 site/src/i18n.ts (limited to 'site/src/i18n.ts') 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; -- cgit v1.2.3