37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import {ng, ngDeps} from './vendor';
|
|
|
|
const ngModule = ng.module('vnCore', ngDeps);
|
|
export default ngModule;
|
|
|
|
config.$inject = ['$translateProvider', '$translatePartialLoaderProvider'];
|
|
export function config($translateProvider, $translatePartialLoaderProvider) {
|
|
$translatePartialLoaderProvider.addPart('core');
|
|
|
|
let conf = {urlTemplate: '/locale/{part}/{lang}.json'};
|
|
|
|
let fallbackLang = 'es';
|
|
let langs = ['en', 'es'];
|
|
let langAliases = {
|
|
en_US: 'en',
|
|
en_UK: 'en',
|
|
es_ES: 'es',
|
|
es_AR: 'es'
|
|
};
|
|
|
|
$translateProvider
|
|
.useSanitizeValueStrategy('escape')
|
|
.useLoader('$translatePartialLoader', conf)
|
|
.registerAvailableLanguageKeys(langs, langAliases)
|
|
// FIXME: Circular dependency due to vnInterceptor
|
|
// .fallbackLanguage(fallbackLang)
|
|
.determinePreferredLanguage(() => {
|
|
let locale = $translateProvider.resolveClientLocale();
|
|
if (langs.indexOf(locale) !== -1)
|
|
return locale;
|
|
if (langAliases[locale])
|
|
return langAliases[locale];
|
|
return fallbackLang;
|
|
});
|
|
}
|
|
ngModule.config(config);
|