2018-02-09 06:21:00 +01:00
|
|
|
import * as fs from 'fs';
|
2018-01-24 21:22:13 +01:00
|
|
|
import * as path from 'path';
|
|
|
|
|
2018-04-25 14:31:48 +02:00
|
|
|
import { I18nService as BaseI18nService } from 'jslib/services/i18n.service';
|
|
|
|
|
|
|
|
export class I18nService extends BaseI18nService {
|
|
|
|
constructor(systemLanguage: string, localesDirectory: string) {
|
|
|
|
super(systemLanguage, localesDirectory, (formattedLocale: string) => {
|
|
|
|
const filePath = path.join(__dirname, this.localesDirectory + '/' + formattedLocale + '/messages.json');
|
|
|
|
const localesJson = fs.readFileSync(filePath, 'utf8');
|
|
|
|
const locales = JSON.parse(localesJson.replace(/^\uFEFF/, '')); // strip the BOM
|
|
|
|
return Promise.resolve(locales);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.supportedTranslationLocales = [
|
2020-05-23 05:14:22 +02:00
|
|
|
'en', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'es', 'et', 'fa', 'fi', 'fr', 'hr', 'hu', 'id', 'it',
|
|
|
|
'ja', 'ko', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sv', 'th', 'tr', 'uk', 'vi',
|
2018-04-25 14:31:48 +02:00
|
|
|
'zh-CN', 'zh-TW',
|
|
|
|
];
|
2018-01-24 20:59:03 +01:00
|
|
|
}
|
|
|
|
}
|