mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3654] translation fixes (#3861)
* fix incorrect translation * improved resource loading and error handling
This commit is contained in:
committed by
Eugenio Romano
parent
ca1505f3c1
commit
5467e92966
@@ -7,7 +7,7 @@
|
|||||||
"VERSIONS": "Версии"
|
"VERSIONS": "Версии"
|
||||||
},
|
},
|
||||||
"HOME": {
|
"HOME": {
|
||||||
"TITLE": "Угловые компоненты для Alfresco",
|
"TITLE": "Компоненты Angular для Alfresco",
|
||||||
"DOCUMENTATION": "Документация"
|
"DOCUMENTATION": "Документация"
|
||||||
},
|
},
|
||||||
"LOGOUT": {
|
"LOGOUT": {
|
||||||
|
@@ -19,7 +19,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { TranslateLoader } from '@ngx-translate/core';
|
import { TranslateLoader } from '@ngx-translate/core';
|
||||||
import { Observable, forkJoin, throwError } from 'rxjs';
|
import { Observable, forkJoin, throwError, of } from 'rxjs';
|
||||||
import { ComponentTranslationModel } from '../models/component.model';
|
import { ComponentTranslationModel } from '../models/component.model';
|
||||||
import { ObjectUtils } from '../utils/object-utils';
|
import { ObjectUtils } from '../utils/object-utils';
|
||||||
import { map, catchError, retry } from 'rxjs/operators';
|
import { map, catchError, retry } from 'rxjs/operators';
|
||||||
@@ -65,7 +65,7 @@ export class TranslateLoaderService implements TranslateLoader {
|
|||||||
component.json[lang] = res;
|
component.json[lang] = res;
|
||||||
}),
|
}),
|
||||||
retry(3),
|
retry(3),
|
||||||
catchError(() => throwError(`Error loading ${translationUrl}`))
|
catchError(() => throwError(`Failed to load ${translationUrl}`))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -108,20 +108,36 @@ export class TranslateLoaderService implements TranslateLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTranslation(lang: string): Observable<any> {
|
getTranslation(lang: string): Observable<any> {
|
||||||
const observableBatch = this.getComponentToFetch(lang);
|
let hasFailures = false;
|
||||||
|
const batch = [
|
||||||
|
...this.getComponentToFetch(lang).map(observable => {
|
||||||
|
return observable.pipe(
|
||||||
|
catchError(error => {
|
||||||
|
console.warn(error);
|
||||||
|
hasFailures = true;
|
||||||
|
return of(error);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
return Observable.create(observer => {
|
return Observable.create(observer => {
|
||||||
if (observableBatch.length > 0) {
|
|
||||||
forkJoin(observableBatch).subscribe(
|
if (batch.length > 0) {
|
||||||
|
forkJoin(batch).subscribe(
|
||||||
() => {
|
() => {
|
||||||
let fullTranslation = this.getFullTranslationJSON(lang);
|
let fullTranslation = this.getFullTranslationJSON(lang);
|
||||||
if (fullTranslation) {
|
if (fullTranslation) {
|
||||||
observer.next(fullTranslation);
|
observer.next(fullTranslation);
|
||||||
}
|
}
|
||||||
|
if (hasFailures) {
|
||||||
|
observer.error('Failed to load some resources');
|
||||||
|
} else {
|
||||||
observer.complete();
|
observer.complete();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
observer.error(err);
|
observer.error('Failed to load some resources');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let fullTranslation = this.getFullTranslationJSON(lang);
|
let fullTranslation = this.getFullTranslationJSON(lang);
|
||||||
|
Reference in New Issue
Block a user