Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
7f08796828
|
@ -5,17 +5,29 @@ export function config($translateProvider, $translatePartialLoaderProvider) {
|
||||||
$translatePartialLoaderProvider.addPart('core');
|
$translatePartialLoaderProvider.addPart('core');
|
||||||
|
|
||||||
let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'};
|
let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'};
|
||||||
|
|
||||||
|
let fallbackLang = 'es';
|
||||||
let langs = ['en', 'es'];
|
let langs = ['en', 'es'];
|
||||||
let localLangs = {
|
let langAliases = {
|
||||||
en_US: 'en',
|
en_US: 'en',
|
||||||
en_UK: 'en',
|
en_UK: 'en',
|
||||||
es_ES: 'es',
|
es_ES: 'es',
|
||||||
es_AR: 'es'
|
es_AR: 'es'
|
||||||
};
|
};
|
||||||
|
|
||||||
$translateProvider
|
$translateProvider
|
||||||
.useSanitizeValueStrategy('escape')
|
.useSanitizeValueStrategy('escape')
|
||||||
.useLoader('$translatePartialLoader', conf)
|
.useLoader('$translatePartialLoader', conf)
|
||||||
.registerAvailableLanguageKeys(langs, localLangs)
|
.registerAvailableLanguageKeys(langs, langAliases)
|
||||||
.determinePreferredLanguage();
|
// 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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
module.config(config);
|
module.config(config);
|
||||||
|
|
|
@ -10,10 +10,15 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
|
||||||
load(moduleName, validations) {
|
load(moduleName, validations) {
|
||||||
let loaded = this._loaded;
|
let loaded = this._loaded;
|
||||||
|
|
||||||
if (loaded[moduleName])
|
if (loaded[moduleName] === true)
|
||||||
|
return Promise.resolve(true);
|
||||||
|
if (loaded[moduleName] instanceof Promise)
|
||||||
return loaded[moduleName];
|
return loaded[moduleName];
|
||||||
|
if (loaded[moduleName] === false)
|
||||||
|
return Promise.reject(
|
||||||
|
new Error(`Module dependency loop detected: ${moduleName}`));
|
||||||
|
|
||||||
loaded[moduleName] = Promise.resolve(true);
|
loaded[moduleName] = false;
|
||||||
|
|
||||||
let deps = splitingRegister.getDependencies(moduleName);
|
let deps = splitingRegister.getDependencies(moduleName);
|
||||||
let depPromises = [];
|
let depPromises = [];
|
||||||
|
@ -29,13 +34,18 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
|
||||||
|
|
||||||
// FIXME: https://github.com/angular-translate/angular-translate/pull/1674
|
// FIXME: https://github.com/angular-translate/angular-translate/pull/1674
|
||||||
$translatePartialLoader.addPart(moduleName);
|
$translatePartialLoader.addPart(moduleName);
|
||||||
promises.push($translate.refresh());
|
promises.push(new Promise(resolve => {
|
||||||
|
$translate.refresh().then(
|
||||||
|
() => resolve(),
|
||||||
|
() => resolve()
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
|
||||||
if (validations)
|
if (validations)
|
||||||
promises.push(new Promise(resolve => {
|
promises.push(new Promise(resolve => {
|
||||||
$http.get(`/${moduleName}/validations`).then(
|
$http.get(`/${moduleName}/validations`).then(
|
||||||
json => this.onValidationsReady(json, resolve),
|
json => this.onValidationsReady(json, resolve),
|
||||||
json => resolve()
|
() => resolve()
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -45,7 +55,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this._loaded[moduleName] = true;
|
loaded[moduleName] = true;
|
||||||
resolve($ocLazyLoad.load({name: moduleName}));
|
resolve($ocLazyLoad.load({name: moduleName}));
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
{
|
{
|
||||||
"db": {
|
"db": {
|
||||||
"name": "db",
|
|
||||||
"connector": "memory"
|
"connector": "memory"
|
||||||
},
|
},
|
||||||
"vn": {
|
"vn": {
|
||||||
"name": "mysql",
|
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "vn",
|
"database": "vn",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
|
@ -16,7 +14,6 @@
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
"salix": {
|
"salix": {
|
||||||
"name": "mysql",
|
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "salix",
|
"database": "salix",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
|
@ -28,7 +25,6 @@
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
"account": {
|
"account": {
|
||||||
"name": "mysql",
|
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "account",
|
"database": "account",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
|
|
Loading…
Reference in New Issue