1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
4 'en-US': 'English (US)',
8 const I18N_LOCALE_ALIAS = {
12 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
13 .concat(Object.keys(I18N_LOCALE_ALIAS))
15 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
17 export function getDefaultLocale () {
21 export function isDefaultLocale (locale: string) {
22 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
25 export function is18nPath (path: string) {
26 return possiblePaths.indexOf(path) !== -1
29 export function is18nLocale (locale: string) {
30 return POSSIBLE_LOCALES.indexOf(locale) !== -1
33 export function getCompleteLocale (locale: string) {
34 if (!locale) return locale
36 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
41 export function buildFileLocale (locale: string) {
42 const completeLocale = getCompleteLocale(locale)
44 return completeLocale.replace('-', '_')