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

@@ -1,12 +1,5 @@
{ {
"title": "Welcome", "title": "Welcome",
"login": "Login",
"username": "Username",
"input-required-message": "Required",
"input-min-message": "Your username needs to be at least 4 characters.",
"login-button": "Login",
"login-error-message": "You have entered an invalid username or password",
"DOCUMENT_LIST": { "DOCUMENT_LIST": {
"COLUMNS": { "COLUMNS": {

View File

@@ -1,9 +1,3 @@
{ {
"title" : "Benvenuto", "title" : "Benvenuto"
"login" : "Autenticazione",
"username" : "Nome utente",
"input-required-message": "Campo obbligatorio",
"input-min-message": "Inserire un nome utente di 4 caratteri minimo.",
"login-button": "Accedi",
"login-error-message": "Nome utente o password non validi"
} }

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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"; "use strict";
var __moduleName = context_1 && context_1.id; var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 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) { var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(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; var AlfrescoTranslationLoader;
return { return {
setters:[ setters:[
@@ -35,6 +35,9 @@ System.register(['angular2/core', 'angular2/http'], function(exports_1, context_
}, },
function (http_1_1) { function (http_1_1) {
http_1 = http_1_1; http_1 = http_1_1;
},
function (Observable_1_1) {
Observable_1 = Observable_1_1;
}], }],
execute: function() { execute: function() {
AlfrescoTranslationLoader = (function () { AlfrescoTranslationLoader = (function () {
@@ -44,10 +47,16 @@ System.register(['angular2/core', 'angular2/http'], function(exports_1, context_
this.suffix = '.json'; this.suffix = '.json';
} }
AlfrescoTranslationLoader.prototype.getTranslation = function (lang) { AlfrescoTranslationLoader.prototype.getTranslation = function (lang) {
return this.http.get('node_modules/ng2-alfresco-login/' + (this.prefix + "/" + lang + this.suffix)) var _this = this;
.map(function (res) { return res.json(); }) return new Observable_1.Observable.create(function (observer) {
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + (this.prefix + "/" + lang + this.suffix)) 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) {
.map(function (res) { return res.json(); })); 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([ AlfrescoTranslationLoader = __decorate([
core_1.Injectable(), 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,CA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AAC,MAAM,SAAI,IAAI,GAAG,KAAI,CAAC,MAAM,CAAE,CAAC,CAAC,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,EAC9H,KAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAkC,GAAG,CAAG,KAAI,CAAC,MAAM,SAAI,IAAI,GAAG,KAAI,CAAC,MAAM,CAAE,CAAC,CAAC,GAAG,CAAC,UAAC,GAAa,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,CAChI,CAAC,SAAS,CACP,UAAA,IAAI;4BACJ,IAAI,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;kCACjD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;kCACvB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;4BACpD,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;4BAC7B,QAAQ,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> { getTranslation(lang: string): Observable<any> {
return this.http.get('node_modules/ng2-alfresco-login/' + `${this.prefix}/${lang}${this.suffix}`) return new Observable.create(observer => {
.map((res: Response) => res.json()) Observable.forkJoin(
.concat(this.http.get('node_modules/ng2-alfresco-upload/' + `${this.prefix}/${lang}${this.suffix}`) this.http.get(`${this.prefix}/${lang}${this.suffix}`).map((res: Response) => res.json()),
.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();
});
});
} }
} }