#163 Fixed with empty Observable value

This commit is contained in:
mauriziovitale84 2016-06-10 15:45:27 +01:00
parent 7e6616d053
commit 0028f91fd4
2 changed files with 15 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "ng2-alfresco-core", "name": "ng2-alfresco-core",
"description": "Alfresco Angular 2 Components core", "description": "Alfresco Angular 2 Components core",
"version": "0.1.29", "version": "0.1.30",
"author": "Alfresco Software, Ltd.", "author": "Alfresco Software, Ltd.",
"scripts": { "scripts": {
"typings": "typings install", "typings": "typings install",

View File

@ -43,7 +43,11 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
let observableBatch = []; let observableBatch = [];
this._componentList.forEach((component) => { this._componentList.forEach((component) => {
observableBatch.push(this.http.get(`${component}/${self.prefix}/${lang}${self.suffix}`) observableBatch.push(this.http.get(`${component}/${self.prefix}/${lang}${self.suffix}`)
.map((res: Response) => res.json())); .map((res: Response) => res.json())
.catch( (err: any, source: Observable<any>, caught: Observable<any>) => {
// Empty Observable just to go ahead
return Observable.of('');
}));
}); });
return Observable.create(observer => { return Observable.create(observer => {
@ -51,10 +55,17 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
(translations: any[]) => { (translations: any[]) => {
let multiLanguage: any = ''; let multiLanguage: any = '';
translations.forEach((translate) => { translations.forEach((translate) => {
multiLanguage += JSON.stringify(translate); if(translate !== '') {
multiLanguage += JSON.stringify(translate);
}
}); });
observer.next(JSON.parse(multiLanguage.replace(/}{/g, ','))); if(multiLanguage !== '') {
observer.next(JSON.parse(multiLanguage.replace(/}{/g, ',')));
}
observer.complete(); observer.complete();
},
(err: any) => {
console.error(err);
}); });
}); });
} }