diff --git a/packages/data-models/appConfig.ts b/packages/data-models/appConfig.ts index 90289914a7..90ea4b3a35 100644 --- a/packages/data-models/appConfig.ts +++ b/packages/data-models/appConfig.ts @@ -51,6 +51,15 @@ const APP_LANGUAGES = { default: "gb_en", }; +export interface ILanguageMeta { + rtl?: boolean; +} +const APP_LANGUAGES_META: { [languageCode: string]: ILanguageMeta } = { + en_rtl: { + rtl: true, + }, +}; + /** Specifies the skins available to the current app build. * "defaultSkinName": the name of the skin used by default for a given build * "available": an array of all skins that are available to the current build */ @@ -221,6 +230,7 @@ const APP_CONFIG = { APP_INITIALISATION_DEFAULTS, APP_AUTHENTICATION_DEFAULTS, APP_LANGUAGES, + APP_LANGUAGES_META, APP_ROUTE_DEFAULTS, APP_SIDEMENU_DEFAULTS, APP_FOOTER_DEFAULTS, diff --git a/src/app/app.component.html b/src/app/app.component.html index 4b70664b80..f6931026ed 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,9 @@ - + { this.platforms = this.platform.platforms().join(" "); this.subscribeToAppConfigChanges(); + // ensure deployment field set correctly for use in any startup services or templates localStorage.setItem(this.appFields.DEPLOYMENT_NAME, this.DEPLOYMENT_NAME); localStorage.setItem(this.appFields.APP_VERSION, this.APP_VERSION); diff --git a/src/app/shared/components/template/services/template-translate.service.ts b/src/app/shared/components/template/services/template-translate.service.ts index 8b9b605f0f..d5473a6443 100644 --- a/src/app/shared/components/template/services/template-translate.service.ts +++ b/src/app/shared/components/template/services/template-translate.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from "@angular/core"; +import { Injectable, WritableSignal, signal } from "@angular/core"; import { IAppConfig } from "data-models"; import { BehaviorSubject } from "rxjs"; import { AppConfigService } from "src/app/shared/services/app-config/app-config.service"; @@ -21,6 +21,8 @@ export class TemplateTranslateService extends AsyncServiceBase { app_language$ = new BehaviorSubject(null); appFields: IAppConfig["APP_FIELDS"]; appLanguages: IAppConfig["APP_LANGUAGES"]; + appLanguagesMeta: IAppConfig["APP_LANGUAGES_META"]; + languageDirection: WritableSignal<"ltr" | "rtl"> = signal("ltr"); translation_strings = {}; constructor( @@ -54,6 +56,7 @@ export class TemplateTranslateService extends AsyncServiceBase { /** Set the local storage variable that tracks the app language */ async setLanguage(code: string, updateDB = true) { if (code) { + console.log("[SET LANGUAGE]", code); if (updateDB) { this.localStorageService.setString(this.appFields.APP_LANGUAGE, code); } @@ -61,7 +64,8 @@ export class TemplateTranslateService extends AsyncServiceBase { this.translation_strings = translationStrings || {}; // update observable for subscribers this.app_language$.next(code); - // console.log("[Language Set]", code); + // update language direction signal + this.languageDirection.set(this.appLanguagesMeta?.[code]?.rtl ? "rtl" : "ltr"); } } @@ -141,6 +145,7 @@ export class TemplateTranslateService extends AsyncServiceBase { this.appConfigService.appConfig$.subscribe((appConfig: IAppConfig) => { this.appFields = appConfig.APP_FIELDS; this.appLanguages = appConfig.APP_LANGUAGES; + this.appLanguagesMeta = appConfig.APP_LANGUAGES_META; }); } }