Skip to content

Commit

Permalink
Automatic language detection and save (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel-Therrien-Beslogic authored Nov 26, 2024
1 parent 4774c39 commit 8311875
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 10 additions & 0 deletions canopeum_frontend/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 canopeum_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bootstrap": "^5.3.3",
"browser-image-compression": "^2.0.2",
"i18next": "^23.10.1",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.5.0",
"jwt-decode": "4.0.0",
"maplibre-gl": "^4.1.1",
Expand Down
13 changes: 9 additions & 4 deletions canopeum_frontend/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { default as i18n } from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'

import resources from './locale'

void i18n.use(initReactI18next).init({
resources,
lng: 'en',
})
void i18n
.use(initReactI18next)
.use(LanguageDetector)
.init({
supportedLngs: Object.keys(resources),
resources,
detection: { convertDetectedLanguage: lng => lng.split('-')[0] }, // fr-CA -> fr
})

0 comments on commit 8311875

Please sign in to comment.