Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #773 from LiskHQ/767-fix-language-switching
Browse files Browse the repository at this point in the history
Fix switching language in Electron - Closes #767
  • Loading branch information
slaweet authored Sep 27, 2017
2 parents 7a9ddd4 + 2cd40e6 commit 122bcb4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/forging/forgingStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ForgingStats extends React.Component {
statCardObjects[0].label = this.props.t('Last 24 hours');
[1, 2, 3].forEach((i) => {
statCardObjects[i].label = this.props.t(
'Last x days', { day: statCardObjects[i].days });
'Last x days', { count: statCardObjects[i].days });
});

return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/forging/forgingStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ describe('ForgingStats', () => {
});

it('should render Card component for Last 7 days', () => {
expect(wrapper.find('Card').at(1).text().trim()).to.equal('Last x days 32.13 LSK');
expect(wrapper.find('Card').at(1).text().trim()).to.equal('Last 7 days 32.13 LSK');
});

it('should render Card component for Last 30 days', () => {
expect(wrapper.find('Card').at(2).text().trim()).to.equal('Last x days 3,213.18 LSK');
expect(wrapper.find('Card').at(2).text().trim()).to.equal('Last 30 days 3,213.18 LSK');
});

it('should render Card component for Last 365 days', () => {
expect(wrapper.find('Card').at(3).text().trim()).to.equal('Last x days 321,317.91 LSK');
expect(wrapper.find('Card').at(3).text().trim()).to.equal('Last 365 days 321,317.91 LSK');
});
});
2 changes: 1 addition & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Header = props => (
className={`${styles.iconButton} ${offlineStyle.disableWhenOffline}`}
icon='language' position='topRight'>
{Object.keys(languages).map(key => (
<MenuItem key={key} value={key} caption={languages[key]}
<MenuItem key={key} value={key} caption={languages[key].name}
onClick={() => i18n.changeLanguage(key)} />
))}
</IconMenu>
Expand Down
10 changes: 8 additions & 2 deletions src/constants/languages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const languages = {
en: 'English',
de: 'Deutsch',
en: {
name: 'English',
common: require('../locales/en/common.json'),
},
de: {
name: 'Deutsch',
common: require('../locales/de/common.json'),
},
};

export default languages;
11 changes: 9 additions & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import languages from './constants/languages';
// import Cache from 'i18next-localstorage-cache';

const resources = Object.keys(languages).reduce((accumulator, key) => {
accumulator[key] = {
common: languages[key].common,
};
return accumulator;
}, {});

i18n
.use(XHR)
// .use(Cache)
.init({
fallbackLng: 'en',
lng: 'en',
resources,
react: {
// wait: true, // globally set to wait for loaded translations in translate hoc
// exposeNamespace: true // exposes namespace on data-i18next-options to be used in eg.
Expand Down

0 comments on commit 122bcb4

Please sign in to comment.