mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Add language selection in settings (#75)
* Add language selection in settings * Removed comment * Mapping Locale-Language saved as key-value instead of list of objects * Remove comment * Revert supported locales array
This commit is contained in:
committed by
Kyle Spearrin
parent
4d015568f5
commit
6bf0821ca6
@@ -15,6 +15,8 @@ import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
|
||||
import { ConstantsService } from 'jslib/services/constants.service';
|
||||
|
||||
import { SupportedTranslationLocales } from '../../services/i18n.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
templateUrl: 'settings.component.html',
|
||||
@@ -24,6 +26,8 @@ export class SettingsComponent implements OnInit {
|
||||
lockOption: number = null;
|
||||
disableGa: boolean = false;
|
||||
disableFavicons: boolean = false;
|
||||
locales: any[];
|
||||
locale: string;
|
||||
|
||||
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||
@@ -43,11 +47,17 @@ export class SettingsComponent implements OnInit {
|
||||
{ name: i18nService.t('onRestart'), value: -1 },
|
||||
{ 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)});
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
const disableGa = await this.storageService.get<boolean>(ConstantsService.disableGaKey);
|
||||
const disableGaByDefault = this.platformUtilsService.isFirefox() || this.platformUtilsService.isMacAppStore();
|
||||
@@ -79,4 +89,8 @@ export class SettingsComponent implements OnInit {
|
||||
const status = enabled ? 'Enabled' : 'Disabled';
|
||||
this.analytics.eventTrack.next({ action: `${status} ${name}` });
|
||||
}
|
||||
|
||||
async saveLocale() {
|
||||
await this.storageService.save('locale', this.locale);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user