MyCrypto/common/translations/index.js

58 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-05-25 00:06:30 +00:00
// @flow
2017-05-25 22:05:11 +00:00
import { markupToReact } from './markup';
2017-07-05 23:28:54 +00:00
import { store } from '../store';
2017-05-25 00:06:30 +00:00
let fallbackLanguage = 'en';
let repository = {};
const languages = [
2017-07-04 03:21:19 +00:00
require('./de'),
require('./el'),
require('./en'),
require('./es'),
require('./fi'),
require('./fr'),
require('./hu'),
require('./id'),
require('./it'),
require('./ja'),
require('./nl'),
require('./no'),
require('./pl'),
require('./pt'),
require('./ru') /*sk, sl, sv */,
require('./ko'),
require('./tr'),
require('./vi'),
require('./zhcn'),
require('./zhtw')
2017-05-25 00:06:30 +00:00
];
languages.forEach(l => {
2017-07-04 03:21:19 +00:00
repository[l.code] = l.data;
2017-05-25 00:06:30 +00:00
});
export default function translate(key: string) {
2017-07-05 23:28:54 +00:00
let activeLanguage = store.getState().config.languageSelection;
2017-07-04 03:21:19 +00:00
return markupToReact(
(repository[activeLanguage] && repository[activeLanguage][key]) ||
repository[fallbackLanguage][key] ||
key
);
2017-05-25 00:06:30 +00:00
}
2017-06-01 20:45:00 +00:00
export function getTranslators() {
2017-07-04 03:21:19 +00:00
return [
'TranslatorName_1',
'TranslatorName_2',
'TranslatorName_3',
'TranslatorName_4',
'TranslatorName_5'
].filter(x => {
const translated = translate(x);
if (typeof translated === 'string') {
return !!translated.trim();
}
return !!translated;
});
2017-06-01 20:45:00 +00:00
}