mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
i18n fixes (#1614)
* i18n fixes - fix issue with default (fallback) language set to browser language - fix issue with fallback language loading when browser language set to non-English locale * code and UI fixes - move document list i18n strings into own scope - replace MDL menu with @angular/material menu (fixes issue with menu items translation, not supported by MDL) - minor improvements * fix unit tests * improve i18n docs and code - provide basic documentation for Translation service - remove custom Login component localisation in favour of documentation sample - simplified i18n setup for demo shell (single path for dev/prod env) * remove unnecessary comments
This commit is contained in:
committed by
Mario Romano
parent
8edd2a2d23
commit
07bad77547
@@ -22,24 +22,35 @@ import { AlfrescoTranslateLoader } from './alfresco-translate-loader.service';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoTranslationService {
|
||||
defaultLang: string = 'en';
|
||||
userLang: string = 'en';
|
||||
customLoader: AlfrescoTranslateLoader;
|
||||
|
||||
constructor(public translate: TranslateService) {
|
||||
this.userLang = translate.getBrowserLang() || 'en';
|
||||
translate.setDefaultLang(this.userLang);
|
||||
this.userLang = translate.getBrowserLang() || this.defaultLang;
|
||||
translate.setDefaultLang(this.defaultLang);
|
||||
this.customLoader = <AlfrescoTranslateLoader> this.translate.currentLoader;
|
||||
this.customLoader.init(this.userLang);
|
||||
this.use(this.userLang);
|
||||
}
|
||||
|
||||
addTranslationFolder(name: string = '', path: string = '') {
|
||||
if (!this.customLoader.existComponent(name)) {
|
||||
this.customLoader.addComponentList(name, path);
|
||||
this.translate.getTranslation(this.userLang).subscribe(
|
||||
() => {
|
||||
this.translate.use(this.userLang);
|
||||
}
|
||||
);
|
||||
if (this.userLang !== this.defaultLang) {
|
||||
this.translate.getTranslation(this.defaultLang).subscribe(() => {
|
||||
this.translate.getTranslation(this.userLang).subscribe(
|
||||
() => {
|
||||
this.translate.use(this.userLang);
|
||||
}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.translate.getTranslation(this.userLang).subscribe(
|
||||
() => {
|
||||
this.translate.use(this.userLang);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user