demo20230512/Browser_Local/js/MultiLanguageService.js
2023-05-12 10:20:28 +08:00

31 lines
958 B
JavaScript

/*
Logic Solution
WeeeCarbonFootprint
service to get multilanguage resource
*/
angular.module('Services')
.service('MultiLanguageService', function ($cookies, $q) {
this.getResourceAsync = function () {
var deferred = $q.defer();
var cultureFolder = 'root'
if ($cookies._culture === 'zh-cn') cultureFolder = 'zh';
if ($cookies._culture === 'en-us') cultureFolder = 'en';
var arr = window.location.href.split("/");
if (arr[3].indexOf('app') == 0)
baseUrl = '';
else
baseUrl = '/' + arr[3];
require([baseUrl+'/Scripts/Nls/' + cultureFolder + '/app-resx.js'],
function requrieSuccess(resource) {
deferred.resolve(resource)
},
function requireError(error) {
}
);
return deferred.promise;
}
})