Skip to content

Commit b9286e7

Browse files
authored
Merge pull request #170 from WildAid/add_localization_info
Adding Localization instructions...
2 parents ae6e760 + c65a69d commit b9286e7

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

LOCALIZATION.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Localization information for the o-fish-web project
2+
3+
Localization is in src/helpers/i18n/
4+
5+
Every translation has a directory with its language code, and a translation.json file. e.g.:
6+
src/helpers/i18n/en/translation.json
7+
src/helpers/i18n/es-419/translation.json
8+
src/helpers/i18n/fr/translation.json
9+
10+
When adding a NEW language, you will need to add it in 3 places in src/helpers/i18n/index.js:
11+
1. Import it, e.g.:
12+
` import en from './en/translation';`
13+
` import fr from './fr/translation';`
14+
15+
2. Update the "default to en" to NOT include the new language:
16+
`if (!(lang.includes('fr') || lang.includes('es'))) {`
17+
` lang = 'en';`
18+
`}`
19+
20+
3. You will need to add it into the resources, e.g.:
21+
`const i18nOptions = {`
22+
` resources: {`
23+
` en: {`
24+
` translation: en`
25+
` },`
26+
` fr: {`
27+
` translation: fr`
28+
` }`
29+
` }`
30+
` };`
31+
32+
33+
34+
The format is a json document where the variable name is in ALL CAPS and in quotes, e.g.:
35+
`{`
36+
` "LOGIN_PAGE": {`
37+
` "LOGIN": "Connexion",`
38+
` "FORGOT_PASSWORD": "Mot de passe oublié?",`
39+
` "EMAIL_USERNAME": "Email/Identifiant:",`
40+
` "PASSWORD": "Mot de passe"`
41+

src/helpers/i18n/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import detector from 'i18next-browser-languagedetector';
33
import { initReactI18next } from 'react-i18next';
44

55
import en from './en/translation';
6+
import fr from './fr/translation';
67

78
let lang = navigator.language || navigator.userLanguage;
89

9-
if (!(lang.includes('en') || lang.includes('fr') || lang.includes('es'))) {
10+
if (!(lang.includes('fr') || lang.includes('es'))) {
1011
lang = 'en';
1112
}
1213

@@ -17,6 +18,9 @@ const i18nOptions = {
1718
resources: {
1819
en: {
1920
translation: en
21+
},
22+
fr: {
23+
translation: fr
2024
}
2125
}
2226
};

0 commit comments

Comments
 (0)