-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement and use initial language switcher component for french
- Loading branch information
Showing
10 changed files
with
278 additions
and
10 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,26 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import Button from './Button'; | ||
|
||
function LanguageSwitcher() { | ||
const { i18n } = useTranslation(); | ||
return ( | ||
<Button.Group> | ||
<Button | ||
active={i18n.language !== 'de'} | ||
disabled={i18n.language === 'de'} | ||
content="deutsch" | ||
onClick={() => i18n.changeLanguage('de')} | ||
/> | ||
<Button | ||
active={i18n.language !== 'fr'} | ||
disabled={i18n.language === 'fr'} | ||
content="français" | ||
onClick={() => i18n.changeLanguage('fr')} | ||
/> | ||
</Button.Group> | ||
); | ||
} | ||
|
||
export default LanguageSwitcher; |
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 |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import i18n from 'i18next'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import resources from './resources'; | ||
|
||
i18n.use(initReactI18next).init({ | ||
lng: 'de', | ||
debug: process.env.NODE_ENV === 'development', | ||
interpolation: { | ||
escapeValue: false, // not needed for React as it escapes by default | ||
}, | ||
resources, | ||
}); | ||
i18n | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
fallbackLng: 'de', | ||
debug: process.env.NODE_ENV === 'development', | ||
interpolation: { | ||
escapeValue: false, // not needed for React as it escapes by default | ||
}, | ||
resources, | ||
}); | ||
|
||
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
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,3 @@ | ||
import translation from './translation.json'; | ||
|
||
export default { translation }; |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import de from './de'; | ||
import fr from './fr'; | ||
|
||
export default { de }; | ||
export default { de, fr }; |
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 |
---|---|---|
|
@@ -6309,6 +6309,13 @@ [email protected]: | |
slash "^3.0.0" | ||
which-pm-runs "^1.0.0" | ||
|
||
i18next-browser-languagedetector@^6.0.1: | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-6.0.1.tgz#83654bc87302be2a6a5a75146ffea97b4ca268cf" | ||
integrity sha512-3H+OsNQn3FciomUU0d4zPFHsvJv4X66lBelXk9hnIDYDsveIgT7dWZ3/VvcSlpKk9lvCK770blRZ/CwHMXZqWw== | ||
dependencies: | ||
"@babel/runtime" "^7.5.5" | ||
|
||
[email protected]: | ||
version "19.7.0" | ||
resolved "https://registry.yarnpkg.com/i18next/-/i18next-19.7.0.tgz#e637bbbf36481d34b7d5e6d3b04e1bb654bf2a26" | ||
|