mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3630] fix i18n fallback behaviour (#3851)
* fix i18n fallback behaviour * update tests * update tests * configuration fixes * test configuration fix
This commit is contained in:
committed by
Eugenio Romano
parent
d1f87837ac
commit
54cca45ec1
@@ -62,22 +62,29 @@ export class TranslationService {
|
||||
addTranslationFolder(name: string = '', path: string = '') {
|
||||
if (!this.customLoader.providerRegistered(name)) {
|
||||
this.customLoader.registerProvider(name, path);
|
||||
|
||||
if (this.userLang) {
|
||||
this.translate.getTranslation(this.userLang).subscribe(() => {
|
||||
this.translate.use(this.userLang);
|
||||
this.onTranslationChanged(this.userLang);
|
||||
}
|
||||
);
|
||||
this.loadTranslation(this.userLang, this.defaultLang);
|
||||
} else {
|
||||
this.translate.getTranslation(this.defaultLang).subscribe(() => {
|
||||
this.translate.use(this.defaultLang);
|
||||
this.onTranslationChanged(this.defaultLang);
|
||||
}
|
||||
);
|
||||
this.loadTranslation(this.defaultLang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadTranslation(lang: string, fallback?: string) {
|
||||
this.translate.getTranslation(lang).subscribe(
|
||||
() => {
|
||||
this.translate.use(lang);
|
||||
this.onTranslationChanged(lang);
|
||||
},
|
||||
() => {
|
||||
if (fallback && fallback !== lang) {
|
||||
this.loadTranslation(fallback);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a notification callback when the translation language changes.
|
||||
* @param lang The new language code
|
||||
|
Reference in New Issue
Block a user