generated from nimblehq/git-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#38] Add a small language switcher component
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"base_alert": { | ||
"error_title": "Erreur", | ||
"error_icon_alt": "Icone indiquant une erreur" | ||
}, | ||
"language_switch": { | ||
"en": "Anglais", | ||
"fr": "Français" | ||
}, | ||
"login": { | ||
"title": "Se connecter à Nimble", | ||
"email": "Email", | ||
"password": "Mot de passe", | ||
"submit": "Se connecter", | ||
"errors": { | ||
"email_required": "Veuillez saisir votre email.", | ||
"email_invalid": "L'email saisi n'est pas valid.", | ||
"password_required": "Veuillez saisir votre mot de passe.", | ||
"password_too_long": "Le mot de passe ne doit pas dépasser les 32 caractères.", | ||
"password_too_short": "Le mot de passe doit faire au minimum 8 caractères." | ||
}, | ||
"nimble_logo_alt": "Logo de Nimble" | ||
} | ||
} |
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,30 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const LanguageSwitch = () => { | ||
const { t, i18n } = useTranslation(); | ||
|
||
const changeLanguage = (language: string): void => { | ||
i18n.changeLanguage(language); | ||
}; | ||
|
||
return ( | ||
<ul className="language-switch"> | ||
{i18n.languages.map((language) => { | ||
return ( | ||
<li key={language}> | ||
<a | ||
onClick={() => { | ||
changeLanguage(language); | ||
}} | ||
data-lang={language} | ||
> | ||
{t(`language_switch.${language}`)} | ||
</a> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default LanguageSwitch; |
713b0a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report
❌ An unexpected error occurred. For more details, check console
Test suite run failed
Failed tests: 17/27. Failed suites: 5/7.
Report generated by 🧪jest coverage report action from 713b0a6