Skip to content

Commit

Permalink
feat: Detect browsere language (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhea-so committed May 1, 2024
2 parents 6b4dea7 + be9c281 commit 914aa39
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.56",
"version": "0.4.57",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
26 changes: 15 additions & 11 deletions web/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import ko from './translations/ko.json';
import en from './translations/en.json';
import ja from './translations/ja.json';
import { initReactI18next } from 'react-i18next';
import { useStore } from '../store';

i18n.use(initReactI18next).init({
lng: useStore.getState().language,
debug: false,
resources: {
en: { translation: en },
ja: { translation: ja },
ko: { translation: ko },
},
});
import LanguageDetector from 'i18next-browser-languagedetector';

const supportLanguages = ['en', 'ja', 'ko'];

export { supportLanguages };

i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
lng: localStorage.getItem('language') || undefined,
supportedLngs: supportLanguages,
debug: false,
resources: {
en: { translation: en },
ja: { translation: ja },
ko: { translation: ko },
},
});

0 comments on commit 914aa39

Please sign in to comment.