mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fixed translation service
This commit is contained in:
@@ -44,7 +44,7 @@ declare var document: any;
|
||||
{path: '/search', name: 'Search', component: AlfrescoSearchComponent}
|
||||
])
|
||||
export class AppComponent {
|
||||
translate: TranslateService;
|
||||
translate: AlfrescoTranslationService;
|
||||
searchForm: ControlGroup;
|
||||
|
||||
constructor(private _fb: FormBuilder,
|
||||
@@ -58,7 +58,8 @@ export class AppComponent {
|
||||
searchTerm: ['', Validators.compose([Validators.required, Validators.minLength(3)])]
|
||||
});
|
||||
|
||||
translate.translationInit('');
|
||||
this.translate = translate;
|
||||
this.translate.translationInit();
|
||||
}
|
||||
|
||||
isActive(instruction: any[]): boolean {
|
||||
|
@@ -1,3 +1,41 @@
|
||||
{
|
||||
"title" : "Benvenuto"
|
||||
|
||||
"DOCUMENT_LIST": {
|
||||
"COLUMNS": {
|
||||
"DISPLAY_NAME": "Mostra name",
|
||||
"CREATED_BY": "Creato da",
|
||||
"CREATED_ON": "Creato il"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"FOLDER": {
|
||||
"SYSTEM_1": "Azione 1 di sistema sulla cartella",
|
||||
"CUSTOM": "Azione personalizzata su cartella"
|
||||
},
|
||||
"DOCUMENT": {
|
||||
"DOWNLOAD": "Download",
|
||||
"SYSTEM_2": "System document action 2",
|
||||
"CUSTOM": "Custom action"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"DATATABLE": {
|
||||
"COLUMNS": {
|
||||
"DISPLAY_NAME": "Display name",
|
||||
"CREATED_BY": "Created by",
|
||||
"CREATED_ON": "Created on"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"FOLDER": {
|
||||
"SYSTEM_1": "System folder action 1",
|
||||
"CUSTOM": "Custom folder action"
|
||||
},
|
||||
"DOCUMENT": {
|
||||
"DOWNLOAD": "Download",
|
||||
"SYSTEM_2": "System document action 2",
|
||||
"CUSTOM": "Custom action"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -50,7 +50,6 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
|
||||
multiLanguage += JSON.stringify(translate);
|
||||
});
|
||||
observer.next(JSON.parse(multiLanguage.replace(/}{/g, ',')));
|
||||
observer.next(multiLanguage);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
|
@@ -22,20 +22,24 @@ import { AlfrescoTranslationLoader } from './AlfrescoTranslationLoader.service';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoTranslationService extends TranslateService {
|
||||
|
||||
userLang: string;
|
||||
currentLoader: AlfrescoTranslationLoader;
|
||||
|
||||
constructor(http: Http, currentLoader: AlfrescoTranslationLoader, @Optional() missingTranslationHandler: MissingTranslationHandler) {
|
||||
super(http, currentLoader, missingTranslationHandler);
|
||||
}
|
||||
|
||||
translationInit(path: string): void {
|
||||
translationInit(name: string = ''): void {
|
||||
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||
this.userLang = userLang;
|
||||
this.setDefaultLang(this.userLang);
|
||||
this.addComponent(name);
|
||||
this.use(this.userLang);
|
||||
}
|
||||
|
||||
this.setDefaultLang(userLang);
|
||||
this.currentLoader.addComponentList(path);
|
||||
this.getTranslation(userLang);
|
||||
this.use(userLang);
|
||||
addComponent(name: string) {
|
||||
this.currentLoader.addComponentList(name);
|
||||
this.getTranslation(this.userLang);
|
||||
}
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ export class UploadButtonComponent {
|
||||
}
|
||||
});
|
||||
|
||||
translate.translationInit('node_modules/ng2-alfresco-upload');
|
||||
translate.addComponent('node_modules/ng2-alfresco-upload');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user