diff --git a/client/core/src/config.js b/client/core/src/config.js index 2b5358839..2687e2c1f 100644 --- a/client/core/src/config.js +++ b/client/core/src/config.js @@ -5,17 +5,29 @@ export function config($translateProvider, $translatePartialLoaderProvider) { $translatePartialLoaderProvider.addPart('core'); let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'}; + + let fallbackLang = 'es'; let langs = ['en', 'es']; - let localLangs = { + let langAliases = { en_US: 'en', en_UK: 'en', es_ES: 'es', es_AR: 'es' }; + $translateProvider .useSanitizeValueStrategy('escape') .useLoader('$translatePartialLoader', conf) - .registerAvailableLanguageKeys(langs, localLangs) - .determinePreferredLanguage(); + .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; + }); } module.config(config); diff --git a/client/core/src/lib/moduleLoader.js b/client/core/src/lib/moduleLoader.js index 82d671454..42723ff0a 100644 --- a/client/core/src/lib/moduleLoader.js +++ b/client/core/src/lib/moduleLoader.js @@ -10,10 +10,15 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t load(moduleName, validations) { let loaded = this._loaded; - if (loaded[moduleName]) + if (loaded[moduleName] === true) + return Promise.resolve(true); + if (loaded[moduleName] instanceof Promise) 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 depPromises = []; @@ -29,13 +34,18 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t // FIXME: https://github.com/angular-translate/angular-translate/pull/1674 $translatePartialLoader.addPart(moduleName); - promises.push($translate.refresh()); + promises.push(new Promise(resolve => { + $translate.refresh().then( + () => resolve(), + () => resolve() + ); + })); if (validations) promises.push(new Promise(resolve => { $http.get(`/${moduleName}/validations`).then( json => this.onValidationsReady(json, resolve), - json => resolve() + () => resolve() ); })); @@ -45,7 +55,7 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t Promise.all(promises) .then(() => { - this._loaded[moduleName] = true; + loaded[moduleName] = true; resolve($ocLazyLoad.load({name: moduleName})); }) .catch(reject); diff --git a/services/loopback/server/datasources.json b/services/loopback/server/datasources.json index 2752ca7b7..1ff4df590 100644 --- a/services/loopback/server/datasources.json +++ b/services/loopback/server/datasources.json @@ -1,10 +1,8 @@ { "db": { - "name": "db", "connector": "memory" }, "vn": { - "name": "mysql", "connector": "mysql", "database": "vn", "debug": false, @@ -16,7 +14,6 @@ "acquireTimeout": 20000 }, "salix": { - "name": "mysql", "connector": "mysql", "database": "salix", "debug": false, @@ -28,7 +25,6 @@ "acquireTimeout": 20000 }, "account": { - "name": "mysql", "connector": "mysql", "database": "account", "debug": false,