Skip to content

Feature/add japanese translation #1664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client/components/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,16 @@ class Nav extends React.PureComponent {
Español
</button>
</li>
<li className="nav__dropdown-item">
<button
onFocus={this.handleFocusForLang}
onBlur={this.handleBlur}
value="ja"
onClick={e => this.handleLangSelection(e)}
>
日本語
</button>
</li>
</ul>
</li>
</React.Fragment>
Expand Down
12 changes: 8 additions & 4 deletions client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend';
import { enUS, es } from 'date-fns/locale';
import { enUS, es, ja } from 'date-fns/locale';

const fallbackLng = ['en-US'];
const availableLanguages = ['en-US', 'es-419'];
const availableLanguages = ['en-US', 'es-419', 'ja'];

export function languageKeyToLabel(lang) {
const languageMap = {
'en-US': 'English',
'es-419': 'Español'
'es-419': 'Español',
'ja': '日本語'
};
return languageMap[lang];
}

export function languageKeyToDateLocale(lang) {
const languageMap = {
'en-US': enUS,
'es-419': es
'es-419': es,
'ja': ja
};
return languageMap[lang];
}
Expand All @@ -35,6 +37,8 @@ const options = {
allowMultiLoading: false, // set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading
};

console.log('options', options);

i18n
.use(initReactI18next) // pass the i18n instance to react-i18next.
// .use(LanguageDetector)// to detect the language from currentBrowser
Expand Down
Loading