-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from DANS-KNAW/development
Development
- Loading branch information
Showing
30 changed files
with
984 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import i18n from "i18next"; | ||
import { initReactI18next } from "react-i18next"; | ||
import languages from "./languages"; | ||
import LanguageDetector from "i18next-browser-languagedetector"; | ||
import { i18n as i18nLayout } from "@dans-framework/layout"; | ||
import { i18n as i18nDeposit } from "@dans-framework/deposit"; | ||
import { i18n as i18nAuth } from "@dans-framework/user-auth"; | ||
import { i18n as i18nRepo } from "@dans-framework/repo-advisor"; | ||
|
||
// this is the main language provider for all subcomponents/libraries | ||
i18n | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
debug: import.meta.env.DEV, | ||
supportedLngs: languages, | ||
detection: { | ||
order: ["cookie", "localStorage"], | ||
lookupCookie: "i18next", | ||
lookupLocalStorage: "i18nextLng", | ||
caches: ["localStorage", "cookie"], | ||
}, | ||
fallbackLng: "en", | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
react: { | ||
useSuspense: true, | ||
}, | ||
}); | ||
|
||
// make sure to import languages for the components that need it | ||
i18n.on("languageChanged", (lng) => { | ||
i18nLayout.changeLanguage(lng); | ||
i18nDeposit.changeLanguage(lng); | ||
i18nAuth.changeLanguage(lng); | ||
i18nRepo.changeLanguage(lng); | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Language } from "@dans-framework/utils"; | ||
|
||
const languages: Language[] = ["en", "nl"]; | ||
|
||
export default languages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.