2018-12-27 11:54:16 +00:00
|
|
|
import {ng, ngDeps} from './vendor';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-12-27 11:54:16 +00:00
|
|
|
const ngModule = ng.module('vnCore', ngDeps);
|
2018-02-10 15:18:01 +00:00
|
|
|
export default ngModule;
|
|
|
|
|
|
|
|
config.$inject = ['$translateProvider', '$translatePartialLoaderProvider'];
|
|
|
|
export function config($translateProvider, $translatePartialLoaderProvider) {
|
|
|
|
$translatePartialLoaderProvider.addPart('core');
|
|
|
|
|
|
|
|
let conf = {urlTemplate: '/static/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);
|