Fixed join JSON - AlfrescoTranslationLoader

This commit is contained in:
mauriziovitale84
2016-05-12 15:29:58 +01:00
parent 2446f8474e
commit 9143acc759
5 changed files with 31 additions and 25 deletions

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/core', 'angular2/http'], function(exports_1, context_1) {
System.register(['angular2/core', 'angular2/http', 'rxjs/Observable'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -26,7 +26,7 @@ System.register(['angular2/core', 'angular2/http'], function(exports_1, context_
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, http_1;
var core_1, http_1, Observable_1;
var AlfrescoTranslationLoader;
return {
setters:[
@@ -35,6 +35,9 @@ System.register(['angular2/core', 'angular2/http'], function(exports_1, context_
},
function (http_1_1) {
http_1 = http_1_1;
},
function (Observable_1_1) {
Observable_1 = Observable_1_1;
}],
execute: function() {
AlfrescoTranslationLoader = (function () {
@@ -44,10 +47,16 @@ System.register(['angular2/core', 'angular2/http'], function(exports_1, context_
this.suffix = '.json';
}
AlfrescoTranslationLoader.prototype.getTranslation = function (lang) {
return this.http.get('node_modules/ng2-alfresco-login/' + (this.prefix + "/" + lang + this.suffix))
.map(function (res) { return res.json(); })
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + (this.prefix + "/" + lang + this.suffix))
.map(function (res) { return res.json(); }));
var _this = this;
return new Observable_1.Observable.create(function (observer) {
Observable_1.Observable.forkJoin(_this.http.get(_this.prefix + "/" + lang + _this.suffix).map(function (res) { return res.json(); }), _this.http.get('node_modules/ng2-alfresco-upload/' + (_this.prefix + "/" + lang + _this.suffix)).map(function (res) { return res.json(); }), _this.http.get('node_modules/ng2-alfresco-login/' + (_this.prefix + "/" + lang + _this.suffix)).map(function (res) { return res.json(); })).subscribe(function (data) {
var multiLanguage = JSON.parse((JSON.stringify(data[0])
+ JSON.stringify(data[1])
+ JSON.stringify(data[2])).replace(/}{/g, ","));
observer.next(multiLanguage);
observer.complete();
});
});
};
AlfrescoTranslationLoader = __decorate([
core_1.Injectable(),

View File

@@ -1 +1 @@
{"version":3,"file":"AlfrescoTranslationService.js","sourceRoot":"","sources":["AlfrescoTranslationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAQH;gBAKI,mCAAoB,IAAU;oBAAV,SAAI,GAAJ,IAAI,CAAM;oBAHtB,WAAM,GAAW,MAAM,CAAC;oBACxB,WAAM,GAAW,OAAO,CAAC;gBAGjC,CAAC;gBAED,kDAAc,GAAd,UAAe,IAAY;oBACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAkC,GAAG,CAAG,IAAI,CAAC,MAAM,SAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAE,CAAC;yBAC5F,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC;yBAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mCAAmC,GAAG,CAAG,IAAI,CAAC,MAAM,SAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAE,CAAC;yBAC9F,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,CAAC,CAAC;gBACjD,CAAC;gBAdL;oBAAC,iBAAU,EAAE;;6CAAA;gBAeb,gCAAC;YAAD,CAAC,AAdD,IAcC;YAdD,iEAcC,CAAA"}
{"version":3,"file":"AlfrescoTranslationService.js","sourceRoot":"","sources":["AlfrescoTranslationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;YAQH;gBAKI,mCAAoB,IAAU;oBAAV,SAAI,GAAJ,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Q,CAAC,QAAQ,EAAE,CAAC;wBACpB,CAAC,CAAC,CAAC;oBACX,CAAC,CAAC,CAAC;gBACP,CAAC;gBAxBL;oBAAC,iBAAU,EAAE;;6CAAA;gBAyBb,gCAAC;YAAD,CAAC,AAxBD,IAwBC;YAxBD,iEAwBC,CAAA"}

View File

@@ -30,9 +30,19 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
}
getTranslation(lang: string): Observable<any> {
return this.http.get('node_modules/ng2-alfresco-login/' + `${this.prefix}/${lang}${this.suffix}`)
.map((res: Response) => res.json())
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + `${this.prefix}/${lang}${this.suffix}`)
.map((res: Response) => res.json()));
return new Observable.create(observer => {
Observable.forkJoin(
this.http.get(`${this.prefix}/${lang}${this.suffix}`).map((res: Response) => res.json()),
this.http.get('node_modules/ng2-alfresco-upload/' + `${this.prefix}/${lang}${this.suffix}`).map((res: Response) => res.json()),
this.http.get('node_modules/ng2-alfresco-login/' + `${this.prefix}/${lang}${this.suffix}`).map((res: Response) => res.json())
).subscribe(
data => {
let multiLanguage = JSON.parse((JSON.stringify(data[0])
+ JSON.stringify(data[1])
+ JSON.stringify(data[2])).replace(/}{/g, ","));
observer.next(multiLanguage);
observer.complete();
});
});
}
}