Language fixes

This commit is contained in:
Juan 2018-06-01 09:04:49 +02:00
parent 27dc90ac3d
commit a015b790b5
2 changed files with 23 additions and 4 deletions

View File

@ -35,9 +35,9 @@
<ul pad-small>
<li
ng-repeat="lang in ::$ctrl.langs"
name="{{::lang}}"
ng-click="$ctrl.onChangeLangClick(lang)">
<span>{{::lang}}</span>
name="{{::lang.code}}"
ng-click="$ctrl.onChangeLangClick(lang.code)">
<span>{{::lang.name}}</span>
</li>
</ul>
</vn-menu>

View File

@ -1,6 +1,16 @@
import ngModule from '../../module';
import './style.scss';
let languages = {
es: 'Español',
en: 'English',
ca: 'Català',
pt: 'Português',
fr: 'Français',
nl: 'Nederlands',
mn: 'Монгол хэл'
};
export default class MainMenu {
constructor($translate, $scope, $http, $window, modulesFactory) {
this.$ = $scope;
@ -8,8 +18,15 @@ export default class MainMenu {
this.$translate = $translate;
this.$window = $window;
this.modules = modulesFactory.getModules();
this.langs = $translate.getAvailableLanguageKeys();
this.langs = [];
for (var code of $translate.getAvailableLanguageKeys())
this.langs.push({
code: code,
name: languages[code] ? languages[code] : code
});
}
getCurrentUserName() {
this.$http.get('/auth/api/Accounts/getCurrentUserName')
.then(json => {
@ -20,9 +37,11 @@ export default class MainMenu {
onLogoutClick() {
this.$window.location = '/logout';
}
onChangeLangClick(lang) {
this.$translate.use(lang);
}
$onInit() {
this.getCurrentUserName();
}