salix/front/core/module.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-12-27 11:54:16 +00:00
import {ng, ngDeps} from './vendor';
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');
2019-01-25 22:02:29 +00:00
let conf = {urlTemplate: '/locale/{part}/{lang}.json'};
2018-02-10 15:18:01 +00:00
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);