-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Language feature Implementation (#137)
* feat: Added language menu item on side nav * file: added package-lock json file * packages: Added packages for language translation * package: added new yarn package * feat: remove commented links * file: Added translation file * feat: Added translation for loading screen. * feat: added radio button for switching languages * feat: added translation for links data item * file: Added json file for english translation * file: Added json file for french translation * feat: added translation feature * feat: Make used of translation file * feat: make used of translation file * feat: added language selector * feat: Added translation for pages
- Loading branch information
Showing
19 changed files
with
1,607 additions
and
47 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
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,20 +1,22 @@ | ||
import i18n from "../../i18n"; | ||
|
||
export const LINKS = [ | ||
{ | ||
title: "Que faire en cas de panne de courant ", | ||
title: i18n.t("adviceTitle2"), | ||
content: [ | ||
"S'agit-il d'une panne de courant qui n'affecte que les appareils individuels ? Vos voisins ont également eu une coupure de courant ? Il est possible qu'un seul fusible ait grillé et que vous puissiez résoudre le problème vous-même.", | ||
i18n.t("adviceContent"), | ||
] | ||
}, | ||
{ | ||
title: "Comportement après une panne de courant ", | ||
title:i18n.t( "adviceTitle3"), | ||
content: [ | ||
"Dès que le courant est rétabli, dans la plupart des cas, il y a d'abord un soulagement. Mais il y a certaines choses que vous devez garder à l'esprit même après une panne de courant.", | ||
i18n.t("adviceContent1"), | ||
] | ||
}, | ||
{ | ||
title: "Raisons d'une panne de courant ", | ||
title: i18n.t("adviceTitle4"), | ||
content: [ | ||
"En cas de panne de courant, le plus important est de rétablir l'alimentation. Pour la plupart des personnes touchées par une panne de courant, cela peut être réalisé au moyen de mesures de commutation dans le réseau électrique. L'opérateur du réseau ne connaît souvent la raison exacte de la panne de courant qu'un certain temps plus tard.", | ||
i18n.t("adviceContent2"), | ||
] | ||
} | ||
] |
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,34 @@ | ||
{ | ||
"select_language": "Select Language", | ||
"hello_welcome_to_react": "Hello, Welcome to React", | ||
"this_is_an_example": "This is an example", | ||
"please_enter_name": "Please enter your name", | ||
"loading": "loading...", | ||
"panel":"Electrical failure", | ||
"reportOutage" :"Report a power outage", | ||
"accept" : "accept", | ||
"notification" : "This site uses cookies to make your visit to our site as pleasant as possible. We use your location to show you reports for your area.", | ||
"info" : "Official Information on Network Operator Interference", | ||
"title" : "Where is the current power outage? Network operators map", | ||
"search" : "Enter the region", | ||
"home" : "Home page", | ||
"info1" : "Advice and information", | ||
"view" : "List view", | ||
"city" : "Enter your neighborhood", | ||
"empty" : "No alerts for this region", | ||
"location" : "show on map", | ||
"notAvailable" : "This content is not available at the moment", | ||
"warning" : "This problem usually stems from the owner only sharing it with a small group of people, changing who can see it, or deleting it.", | ||
"homePage" : "Go to the home page", | ||
"title1" : "Power outage, now what?", | ||
"contents" : "A power outage is a sudden and rare event. However, in the event of a power outage, it is advisable to remain calm at first. In addition, you must pay attention to a few elements of your household and notify us of the power outage.", | ||
"link" : "Quick links:", | ||
"adviceContent" : "Is it a power outage that only affects individual devices? Have your neighbors also had a power outage? It is possible that only one fuse has blown and you can fix the problem yourself.", | ||
"adviceContent1" : "As soon as the power is restored, in most cases there is relief first. But there are some things you need to keep in mind even after a power outage.", | ||
"adviceContent2" : "In the event of a power outage, the most important thing is to restore power. For most people affected by a power outage, this can be achieved through switching measures in the power grid. The network operator often does not know the exact reason for the power failure until some time later.", | ||
"adviceTitle2" : "What to do in the event of a power outage", | ||
"adviceTitle3" : "Behavior after a power failure", | ||
"adviceTitle4" : "Reasons for a power outage" | ||
|
||
} | ||
|
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,33 @@ | ||
{ | ||
"select_language": "Choisir la langue", | ||
"hello_welcome_to_react": "Bonjour, Bienvenue chez React", | ||
"this_is_an_example": "Ceci est un exemple", | ||
"please_enter_name": "Veuillez saisir le nom", | ||
"loading" : "Chargement.....", | ||
"panel":"Panne électrique", | ||
"reportOutage" :"Signaler une panne de courant", | ||
"accept" : "J'accepte", | ||
"notification" : "Ce site utilise des cookies pour rendre votre visite sur notre site aussi agréable que possible. Nous utilisons votre emplacement pour vous montrer les rapports de votre région.", | ||
"info" : "Informations officielles sur Interférences des opérateurs de réseau", | ||
"title" : "Où est la panne de courant actuelle? Carte des opérateurs de réseau", | ||
"search" : "Entrez la region", | ||
"home" : "Page d'accueil", | ||
"info1" : "Conseils et informations", | ||
"view" : "Vue liste", | ||
"city" : "Entrer votre quartier", | ||
"empty" : "Aucune alerte pour cette region", | ||
"location" : "afficher sur la carte", | ||
"notAvailable" : "Ce contenu n’est pas disponible pour le moment", | ||
"warning" : "Ce problème vient généralement du fait que le propriétaire ne l’a partagé qu’avec un petit groupe de personnes, a modifié qui pouvait le voir ou l’a supprimé.", | ||
"homePage" : "Acceder a la page d'accueil", | ||
"title1" : "Panne de courant, et maintenant ? ", | ||
"contents" : "Une panne de courant est un événement soudain et rare. Cependant, en cas de panne de courant, il est conseillé de rester calme dans un premier temps. De plus, vous devez faire attention à quelques éléments de votre foyer et nous signaler la panne de courant. ", | ||
"link" : "Liens rapides:", | ||
"adviceContent" : "S'agit-il d'une panne de courant qui n'affecte que les appareils individuels ? Vos voisins ont également eu une coupure de courant ? Il est possible qu'un seul fusible ait grillé et que vous puissiez résoudre le problème vous-même.", | ||
"adviceContent1" : "Dès que le courant est rétabli, dans la plupart des cas, il y a d'abord un soulagement. Mais il y a certaines choses que vous devez garder à l'esprit même après une panne de courant.", | ||
"adviceContent2" : "En cas de panne de courant, le plus important est de rétablir l'alimentation. Pour la plupart des personnes touchées par une panne de courant, cela peut être réalisé au moyen de mesures de commutation dans le réseau électrique. L'opérateur du réseau ne connaît souvent la raison exacte de la panne de courant qu'un certain temps plus tard.", | ||
"advicetitle2" : "Que faire en cas de panne de courant ", | ||
"advicetitle3" : "Comportement après une panne de courant ", | ||
"advicetitle4" : "Raisons d'une panne de courant " | ||
} | ||
|
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
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,38 @@ | ||
import i18n from "i18next"; | ||
import { initReactI18next } from "react-i18next"; | ||
|
||
// Importing translation files | ||
|
||
import translationEN from "./assets/translation/en/en.json"; | ||
import translationFR from "./assets/translation/fr/fr.json"; | ||
|
||
//Creating object with the variables of imported translation files | ||
const resources = { | ||
en: { | ||
translation: translationEN, | ||
}, | ||
fr: { | ||
translation: translationFR, | ||
}, | ||
}; | ||
|
||
//i18N Initialization | ||
|
||
i18n.use(initReactI18next).init({ | ||
resources, | ||
lng: "en", //default language | ||
keySeparator: false, | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
}); | ||
i18n.init({ | ||
// ... other config | ||
|
||
react: { | ||
// Turn off the use of React Suspense | ||
useSuspense: false | ||
} | ||
}); | ||
|
||
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,18 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
const LanguageSelector = () => { | ||
|
||
const { i18n } = useTranslation(); | ||
|
||
const changeLanguage = (event) => { | ||
i18n.changeLanguage(event.target.value); | ||
}; | ||
return ( | ||
<div onChange={changeLanguage}> | ||
<input type="radio" value="en" name="language" defaultChecked /> English | ||
<input type="radio" value="fr" name="language" /> French | ||
</div> | ||
); | ||
}; | ||
export default LanguageSelector; |
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
Oops, something went wrong.