Skip to content

Commit 45f20e3

Browse files
committed
WIP translate translations.json
1 parent 7f6e95e commit 45f20e3

File tree

3 files changed

+609
-4
lines changed

3 files changed

+609
-4
lines changed

client/components/Nav.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,16 @@ class Nav extends React.PureComponent {
582582
Español
583583
</button>
584584
</li>
585+
<li className="nav__dropdown-item">
586+
<button
587+
onFocus={this.handleFocusForLang}
588+
onBlur={this.handleBlur}
589+
value="ja"
590+
onClick={e => this.handleLangSelection(e)}
591+
>
592+
日本語
593+
</button>
594+
</li>
585595
</ul>
586596
</li>
587597
</React.Fragment>

client/i18n.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ import i18n from 'i18next';
22
import { initReactI18next } from 'react-i18next';
33
import LanguageDetector from 'i18next-browser-languagedetector';
44
import Backend from 'i18next-http-backend';
5-
import { enUS, es } from 'date-fns/locale';
5+
import { enUS, es, ja } from 'date-fns/locale';
66

77
const fallbackLng = ['en-US'];
8-
const availableLanguages = ['en-US', 'es-419'];
8+
const availableLanguages = ['en-US', 'es-419', 'ja'];
99

1010
export function languageKeyToLabel(lang) {
1111
const languageMap = {
1212
'en-US': 'English',
13-
'es-419': 'Español'
13+
'es-419': 'Español',
14+
'ja': 'Japanese'
1415
};
1516
return languageMap[lang];
1617
}
1718

1819
export function languageKeyToDateLocale(lang) {
1920
const languageMap = {
2021
'en-US': enUS,
21-
'es-419': es
22+
'es-419': es,
23+
'ja': ja
2224
};
2325
return languageMap[lang];
2426
}
@@ -35,6 +37,8 @@ const options = {
3537
allowMultiLoading: false, // set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading
3638
};
3739

40+
console.log('options', options);
41+
3842
i18n
3943
.use(initReactI18next) // pass the i18n instance to react-i18next.
4044
// .use(LanguageDetector)// to detect the language from currentBrowser

0 commit comments

Comments
 (0)