diff --git a/jslib b/jslib index 8469d18f..119a9ba6 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 8469d18f47f0dbfc1677f98323169a93c7b1e193 +Subproject commit 119a9ba6bc847049624244c8fb6957e7e2f28256 diff --git a/src/app/accounts/settings.component.html b/src/app/accounts/settings.component.html index b8f20a4e..68aad5bc 100644 --- a/src/app/accounts/settings.component.html +++ b/src/app/accounts/settings.component.html @@ -44,9 +44,8 @@
- + {{'languageDesc' | i18n}}
diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index a694f971..08c41740 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -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(ConstantsService.lockOptionKey); this.disableFavicons = await this.storageService.get(ConstantsService.disableFaviconKey); - this.locale = await this.storageService.get('locale'); + this.locale = await this.storageService.get(ConstantsService.localeKey); const disableGa = await this.storageService.get(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); - } } diff --git a/src/app/services.module.ts b/src/app/services.module.ts index 2766c2f8..6c086de7 100644 --- a/src/app/services.module.ts +++ b/src/app/services.module.ts @@ -110,7 +110,8 @@ environmentService.setUrlsFromStorage().then(() => { export function initFactory(): Function { return async () => { - await i18nService.init(await storageService.get('locale')); + const locale = await storageService.get(ConstantsService.localeKey); + await i18nService.init(locale); await authService.init(); const htmlEl = window.document.documentElement; htmlEl.classList.add('os_' + platformUtilsService.getDeviceString()); diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 655d431a..6be13856 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -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" } } diff --git a/src/main.ts b/src/main.ts index 229f2009..0b1ca7fe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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('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(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); }); } }