2019-12-08 00:32:00 +05:30
|
|
|
|
import supportedLocales from 'app/i18n';
|
2017-12-31 01:14:32 +05:30
|
|
|
|
|
|
|
|
|
const localeToCountryCode = {
|
2019-11-27 14:33:32 +05:30
|
|
|
|
en: 'gb',
|
|
|
|
|
be: 'by',
|
|
|
|
|
pt: 'br',
|
|
|
|
|
uk: 'ua',
|
|
|
|
|
vi: 'vn',
|
|
|
|
|
sl: 'si',
|
|
|
|
|
sr: 'rs',
|
|
|
|
|
zh: 'cn',
|
2017-12-31 01:14:32 +05:30
|
|
|
|
};
|
2019-12-07 16:58:52 +05:30
|
|
|
|
const SUPPORTED_LANGUAGES: string[] = Object.keys(supportedLocales);
|
2017-12-31 01:14:32 +05:30
|
|
|
|
|
|
|
|
|
export default {
|
2019-12-07 16:58:52 +05:30
|
|
|
|
getCountryList(): string[] {
|
2019-11-27 14:33:32 +05:30
|
|
|
|
return SUPPORTED_LANGUAGES.map(
|
|
|
|
|
locale => localeToCountryCode[locale] || locale,
|
|
|
|
|
);
|
|
|
|
|
},
|
2017-12-31 01:14:32 +05:30
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
|
/**
|
|
|
|
|
* Возвращает для указанной локали её флаг с учётом всех нюансов загрузки флага
|
|
|
|
|
* и подбора соответствующего локали флага.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} locale
|
|
|
|
|
*
|
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
getIconUrl(locale: string): string {
|
|
|
|
|
return require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] ||
|
|
|
|
|
locale}.svg`);
|
|
|
|
|
},
|
2017-12-31 01:14:32 +05:30
|
|
|
|
};
|