1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

language setting fixes

This commit is contained in:
Kyle Spearrin 2018-04-24 23:53:20 -04:00
parent a135acb3c4
commit 1a85017d18
6 changed files with 32 additions and 27 deletions

2
jslib

@ -1 +1 @@
Subproject commit 8469d18f47f0dbfc1677f98323169a93c7b1e193
Subproject commit 119a9ba6bc847049624244c8fb6957e7e2f28256

View File

@ -44,9 +44,8 @@
</div>
<div class="form-group">
<label for="locale">{{'language' | i18n}}</label>
<select id="locale" name="Locale" [(ngModel)]="locale"
(change)="saveLocale()">
<option *ngFor="let o of locales" [ngValue]="o.locale">{{o.language}}</option>
<select id="locale" name="Locale" [(ngModel)]="locale" (change)="saveLocale()">
<option *ngFor="let o of localeOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
<small class="help-block">{{'languageDesc' | i18n}}</small>
</div>

View File

@ -22,12 +22,12 @@ import { SupportedTranslationLocales } from '../../services/i18n.service';
templateUrl: 'settings.component.html',
})
export class SettingsComponent implements OnInit {
lockOptions: any[];
lockOption: number = null;
disableGa: boolean = false;
disableFavicons: boolean = false;
locales: any[];
locale: string;
lockOptions: any[];
localeOptions: any[];
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
@ -48,16 +48,16 @@ export class SettingsComponent implements OnInit {
{ name: i18nService.t('never'), value: null },
];
this.locales = [ { locale: null, language: 'Default' } ];
Object.keys(SupportedTranslationLocales).forEach((localId) => {
this.locales.push({locale: localId, language: i18nService.t(localId)});
this.localeOptions = [{ name: i18nService.t('default'), value: null }];
SupportedTranslationLocales.forEach((locale) => {
this.localeOptions.push({ name: locale, value: locale });
});
}
async ngOnInit() {
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.locale = await this.storageService.get<string>('locale');
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
const disableGa = await this.storageService.get<boolean>(ConstantsService.disableGaKey);
const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore();
@ -85,12 +85,13 @@ export class SettingsComponent implements OnInit {
this.callAnalytics('Favicons', !this.disableGa);
}
async saveLocale() {
await this.storageService.save(ConstantsService.localeKey, this.locale);
this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale });
}
private callAnalytics(name: string, enabled: boolean) {
const status = enabled ? 'Enabled' : 'Disabled';
this.analytics.eventTrack.next({ action: `${status} ${name}` });
}
async saveLocale() {
await this.storageService.save('locale', this.locale);
}
}

View File

@ -110,7 +110,8 @@ environmentService.setUrlsFromStorage().then(() => {
export function initFactory(): Function {
return async () => {
await i18nService.init(await storageService.get<string>('locale'));
const locale = await storageService.get<string>(ConstantsService.localeKey);
await i18nService.init(locale);
await authService.init();
const htmlEl = window.document.documentElement;
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());

View File

@ -774,7 +774,7 @@
"message": "Language"
},
"languageDesc": {
"message": "Change language. Require restart."
"message": "Change the language used by the application. Restart is required."
},
"copy": {
"message": "Copy",
@ -1028,5 +1028,8 @@
"organization": {
"message": "Organization",
"description": "An entity of multiple related people (ex. a team or business organization)."
},
"default": {
"message": "Default"
}
}

View File

@ -9,6 +9,8 @@ import { MessagingMain } from './main/messaging.main';
import { PowerMonitorMain } from './main/powerMonitor.main';
import { UpdaterMain } from './main/updater.main';
import { ConstantsService } from 'jslib/services/constants.service';
import { ElectronLogService } from 'jslib/electron/services/electronLog.service';
import { ElectronStorageService } from 'jslib/electron/services/electronStorage.service';
import { WindowMain } from 'jslib/electron/window.main';
@ -62,17 +64,16 @@ export class Main {
}
bootstrap() {
this.storageService.get<string>('locale').then(async (locale) => {
this.windowMain.init().then(async () => {
await this.i18nService.init(locale !== null ? locale : app.getLocale());
this.messagingMain.init();
this.menuMain.init();
this.powerMonitorMain.init();
await this.updaterMain.init();
}, (e: any) => {
// tslint:disable-next-line
console.error(e);
});
this.windowMain.init().then(async () => {
const locale = await this.storageService.get<string>(ConstantsService.localeKey);
await this.i18nService.init(locale != null ? locale : app.getLocale());
this.messagingMain.init();
this.menuMain.init();
this.powerMonitorMain.init();
await this.updaterMain.init();
}, (e: any) => {
// tslint:disable-next-line
console.error(e);
});
}
}