Skip to content

Commit

Permalink
feat: init for language changeed
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 24, 2023
1 parent 69370f9 commit 303e01b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"ai": "^2.2.25",
"handlebars": "^4.7.8",
"i18next": "^23.7.6",
"i18next-browser-languagedetector": "^7.2.0",
"markdown-it": "^13.0.2",
"next": "latest",
"openai": "^4.20.0",
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import LanguageDetector from 'i18next-browser-languagedetector';

// the translations
// (tip move them in a JSON file and import them,
Expand Down Expand Up @@ -29,15 +30,21 @@ const resources = {

i18n
.use(initReactI18next) // passes i18n down to react-i18next
.use(LanguageDetector)
.init({
resources,
fallbackLng: 'en',
debug: true,
// lng: 'zh', // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
// if you're using a language detector, do not define the lng option

interpolation: {
escapeValue: false // react already safes from xss
}
}, (err, t) => {
if (err) return console.log('something went wrong loading', err)
console.log('i18n loaded successfully')
})

export default i18n

0 comments on commit 303e01b

Please sign in to comment.