application-amicale/utils/LocaleManager.js

27 lines
545 B
JavaScript
Raw Normal View History

// @flow
2019-06-25 22:20:24 +02:00
import i18n from 'i18n-js';
import * as Localization from 'expo-localization';
import en from '../translations/en';
import fr from '../translations/fr';
/**
* Static class used to manage locales
*/
2019-06-25 22:20:24 +02:00
export default class LocaleManager {
/**
* Initialize translations using language files
*/
static initTranslations() {
2019-06-25 22:20:24 +02:00
i18n.fallbacks = true;
i18n.translations = {fr, en};
i18n.locale = Localization.locale;
}
static getCurrentLocale() {
return Localization.locale;
}
2019-06-25 22:20:24 +02:00
}