mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 14:02:48 +00:00
fix: setting of default language
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
"@ngx-translate/http-loader": "4.0.0",
|
||||
"@openstapps/api": "0.25.0",
|
||||
"@openstapps/configuration": "0.25.0",
|
||||
"@openstapps/core": "0.36.0",
|
||||
"@openstapps/core": "0.42.0",
|
||||
"cordova-android": "9.0.0",
|
||||
"cordova-browser": "6.0.0",
|
||||
"cordova-ios": "6.2.0",
|
||||
|
||||
@@ -66,10 +66,9 @@ export class AppComponent {
|
||||
private readonly configProvider: ConfigProvider,
|
||||
private readonly logger: NGXLogger) {
|
||||
initLogger(logger);
|
||||
this.initializeApp();
|
||||
|
||||
// this language will be used as a fallback when a translation isn't found in the current language
|
||||
translateService.setDefaultLang('en');
|
||||
this.translateService.setDefaultLang('en');
|
||||
this.initializeApp();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,6 +105,9 @@ export class AppComponent {
|
||||
|
||||
try {
|
||||
// set language from settings
|
||||
if (this.configProvider.firstSession) {
|
||||
await this.settingsProvider.setSettingValue('profile', 'language', this.translateService.getBrowserLang());
|
||||
}
|
||||
const languageCode = (await this.settingsProvider.getValue('profile', 'language')) as string;
|
||||
this.thingTranslateService.translator.language = languageCode as SCLanguageCode;
|
||||
this.translateService.use(languageCode);
|
||||
|
||||
@@ -38,7 +38,6 @@ import {StorageModule} from './modules/storage/storage.module';
|
||||
import {ThingTranslateModule} from './translation/thing-translate.module';
|
||||
import {fakeBackendProvider} from './_helpers/fake-backend.interceptor';
|
||||
|
||||
moment.locale('de');
|
||||
registerLocaleData(localeDe);
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,11 +48,14 @@ export class ConfigProvider {
|
||||
* App configuration as IndexResponse
|
||||
*/
|
||||
config: SCIndexResponse;
|
||||
/**
|
||||
* First session indicator
|
||||
*/
|
||||
firstSession = true;
|
||||
/**
|
||||
* Initialised status flag of config provider
|
||||
*/
|
||||
initialised = false;
|
||||
|
||||
/**
|
||||
* Version of the @openstapps/core package that app is using
|
||||
*/
|
||||
@@ -117,6 +120,7 @@ export class ConfigProvider {
|
||||
// load saved configuration
|
||||
try {
|
||||
this.config = await this.loadLocal();
|
||||
this.firstSession = false;
|
||||
this.initialised = true;
|
||||
this.logger.log(`initialised configuration from storage`);
|
||||
if (this.config.backend.SCVersion !== this.scVersion) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {SCSearchQuery, SCSearchResponse, SCThingOriginType, SCThings, SCThingType} from '@openstapps/core';
|
||||
import {SCSearchRequest, SCSearchResponse, SCThingOriginType, SCThings, SCThingType} from '@openstapps/core';
|
||||
import {SCSaveableThing} from '@openstapps/core';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
@@ -169,7 +169,7 @@ export class DataProvider {
|
||||
*
|
||||
* @param query - query to send to the backend
|
||||
*/
|
||||
async search(query: SCSearchQuery): Promise<SCSearchResponse> {
|
||||
async search(query: SCSearchRequest): Promise<SCSearchResponse> {
|
||||
return (this.client.search(query));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
import {Injectable, OnDestroy} from '@angular/core';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {SCLanguage, SCThings, SCThingTranslator, SCThingType, SCTranslations} from '@openstapps/core';
|
||||
import {SCLanguage, SCLanguageCode, SCThings, SCThingTranslator, SCThingType, SCTranslations} from '@openstapps/core';
|
||||
import moment from 'moment';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {isDefined, ThingTranslateParser} from './thing-translate.parser';
|
||||
@@ -40,14 +40,11 @@ export class ThingTranslateService implements OnDestroy {
|
||||
*/
|
||||
constructor(private readonly translateService: TranslateService,
|
||||
public parser: ThingTranslateParser){
|
||||
|
||||
this.translator = new SCThingTranslator('de' ?? this.translateService.currentLang as keyof SCTranslations<SCLanguage>);
|
||||
moment.updateLocale(this.translator.language);
|
||||
|
||||
this.translator = new SCThingTranslator(this.translateService.getBrowserLang() as SCLanguageCode ?? 'en');
|
||||
/** set the default language from configuration */
|
||||
this.onLangChange = this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||
this.translator.language = event.lang as keyof SCTranslations<SCLanguage>;
|
||||
moment.updateLocale(event.lang);
|
||||
moment.locale(event.lang);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user