File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ import detector from 'i18next-browser-languagedetector';
33import { initReactI18next } from 'react-i18next' ;
44
55import en from './en/translation' ;
6+ import fr from './fr/translation' ;
67
78let 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} ;
You can’t perform that action at this time.
0 commit comments