mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-28 12:35:40 +01:00
language setting fixes
This commit is contained in:
parent
a135acb3c4
commit
1a85017d18
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit 8469d18f47f0dbfc1677f98323169a93c7b1e193
|
Subproject commit 119a9ba6bc847049624244c8fb6957e7e2f28256
|
@ -44,9 +44,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="locale">{{'language' | i18n}}</label>
|
<label for="locale">{{'language' | i18n}}</label>
|
||||||
<select id="locale" name="Locale" [(ngModel)]="locale"
|
<select id="locale" name="Locale" [(ngModel)]="locale" (change)="saveLocale()">
|
||||||
(change)="saveLocale()">
|
<option *ngFor="let o of localeOptions" [ngValue]="o.value">{{o.name}}</option>
|
||||||
<option *ngFor="let o of locales" [ngValue]="o.locale">{{o.language}}</option>
|
|
||||||
</select>
|
</select>
|
||||||
<small class="help-block">{{'languageDesc' | i18n}}</small>
|
<small class="help-block">{{'languageDesc' | i18n}}</small>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,12 +22,12 @@ import { SupportedTranslationLocales } from '../../services/i18n.service';
|
|||||||
templateUrl: 'settings.component.html',
|
templateUrl: 'settings.component.html',
|
||||||
})
|
})
|
||||||
export class SettingsComponent implements OnInit {
|
export class SettingsComponent implements OnInit {
|
||||||
lockOptions: any[];
|
|
||||||
lockOption: number = null;
|
lockOption: number = null;
|
||||||
disableGa: boolean = false;
|
disableGa: boolean = false;
|
||||||
disableFavicons: boolean = false;
|
disableFavicons: boolean = false;
|
||||||
locales: any[];
|
|
||||||
locale: string;
|
locale: string;
|
||||||
|
lockOptions: any[];
|
||||||
|
localeOptions: any[];
|
||||||
|
|
||||||
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||||
@ -48,16 +48,16 @@ export class SettingsComponent implements OnInit {
|
|||||||
{ name: i18nService.t('never'), value: null },
|
{ name: i18nService.t('never'), value: null },
|
||||||
];
|
];
|
||||||
|
|
||||||
this.locales = [ { locale: null, language: 'Default' } ];
|
this.localeOptions = [{ name: i18nService.t('default'), value: null }];
|
||||||
Object.keys(SupportedTranslationLocales).forEach((localId) => {
|
SupportedTranslationLocales.forEach((locale) => {
|
||||||
this.locales.push({locale: localId, language: i18nService.t(localId)});
|
this.localeOptions.push({ name: locale, value: locale });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||||
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
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 disableGa = await this.storageService.get<boolean>(ConstantsService.disableGaKey);
|
||||||
const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore();
|
const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore();
|
||||||
@ -85,12 +85,13 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.callAnalytics('Favicons', !this.disableGa);
|
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) {
|
private callAnalytics(name: string, enabled: boolean) {
|
||||||
const status = enabled ? 'Enabled' : 'Disabled';
|
const status = enabled ? 'Enabled' : 'Disabled';
|
||||||
this.analytics.eventTrack.next({ action: `${status} ${name}` });
|
this.analytics.eventTrack.next({ action: `${status} ${name}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveLocale() {
|
|
||||||
await this.storageService.save('locale', this.locale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,8 @@ environmentService.setUrlsFromStorage().then(() => {
|
|||||||
|
|
||||||
export function initFactory(): Function {
|
export function initFactory(): Function {
|
||||||
return async () => {
|
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();
|
await authService.init();
|
||||||
const htmlEl = window.document.documentElement;
|
const htmlEl = window.document.documentElement;
|
||||||
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());
|
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());
|
||||||
|
@ -774,7 +774,7 @@
|
|||||||
"message": "Language"
|
"message": "Language"
|
||||||
},
|
},
|
||||||
"languageDesc": {
|
"languageDesc": {
|
||||||
"message": "Change language. Require restart."
|
"message": "Change the language used by the application. Restart is required."
|
||||||
},
|
},
|
||||||
"copy": {
|
"copy": {
|
||||||
"message": "Copy",
|
"message": "Copy",
|
||||||
@ -1028,5 +1028,8 @@
|
|||||||
"organization": {
|
"organization": {
|
||||||
"message": "Organization",
|
"message": "Organization",
|
||||||
"description": "An entity of multiple related people (ex. a team or business organization)."
|
"description": "An entity of multiple related people (ex. a team or business organization)."
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"message": "Default"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/main.ts
23
src/main.ts
@ -9,6 +9,8 @@ import { MessagingMain } from './main/messaging.main';
|
|||||||
import { PowerMonitorMain } from './main/powerMonitor.main';
|
import { PowerMonitorMain } from './main/powerMonitor.main';
|
||||||
import { UpdaterMain } from './main/updater.main';
|
import { UpdaterMain } from './main/updater.main';
|
||||||
|
|
||||||
|
import { ConstantsService } from 'jslib/services/constants.service';
|
||||||
|
|
||||||
import { ElectronLogService } from 'jslib/electron/services/electronLog.service';
|
import { ElectronLogService } from 'jslib/electron/services/electronLog.service';
|
||||||
import { ElectronStorageService } from 'jslib/electron/services/electronStorage.service';
|
import { ElectronStorageService } from 'jslib/electron/services/electronStorage.service';
|
||||||
import { WindowMain } from 'jslib/electron/window.main';
|
import { WindowMain } from 'jslib/electron/window.main';
|
||||||
@ -62,17 +64,16 @@ export class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
this.storageService.get<string>('locale').then(async (locale) => {
|
this.windowMain.init().then(async () => {
|
||||||
this.windowMain.init().then(async () => {
|
const locale = await this.storageService.get<string>(ConstantsService.localeKey);
|
||||||
await this.i18nService.init(locale !== null ? locale : app.getLocale());
|
await this.i18nService.init(locale != null ? locale : app.getLocale());
|
||||||
this.messagingMain.init();
|
this.messagingMain.init();
|
||||||
this.menuMain.init();
|
this.menuMain.init();
|
||||||
this.powerMonitorMain.init();
|
this.powerMonitorMain.init();
|
||||||
await this.updaterMain.init();
|
await this.updaterMain.init();
|
||||||
}, (e: any) => {
|
}, (e: any) => {
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user