From 7310ce06008419cc3217455a44cdea6a40d71909 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 28 Nov 2024 15:06:30 +0100 Subject: [PATCH 1/2] fix typing for translation strings --- src/i18n/i18n.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/i18n/i18n.service.ts b/src/i18n/i18n.service.ts index 7dbf098202..33e8d3d1b2 100644 --- a/src/i18n/i18n.service.ts +++ b/src/i18n/i18n.service.ts @@ -135,7 +135,9 @@ export class Overridable { /** * An object of strings, should follow the same format as src/i18n/en.json */ -export type TranslationStrings = { [key: string]: string }; +export type TranslationStrings = { + [key: string]: string | TranslationStrings; +}; /** @@ -148,7 +150,7 @@ export type TranslationStrings = { [key: string]: string }; */ @Injectable() export class I18n { - protected translationStrings = EN; + protected translationStrings: TranslationStrings = EN protected translations = new Map(); @@ -264,8 +266,8 @@ export class I18n { * * @param path looks like `"NOTIFICATION.CLOSE_BUTTON"` */ - public getValueFromPath(path): string | { [key: string]: string } { - let value = this.translationStrings; + public getValueFromPath(path: string): string | TranslationStrings { + let value: string | TranslationStrings = this.translationStrings; for (const segment of path.split(".")) { if (value[segment] !== undefined && value[segment] !== null) { value = value[segment]; From 5d5fee358683d30bdfea6e7e6385650d6d2ea16a Mon Sep 17 00:00:00 2001 From: Akshat Patel <38994122+Akshat55@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:39:26 -0500 Subject: [PATCH 2/2] chore: lint fix --- src/i18n/i18n.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/i18n.service.ts b/src/i18n/i18n.service.ts index 33e8d3d1b2..75d9b8d237 100644 --- a/src/i18n/i18n.service.ts +++ b/src/i18n/i18n.service.ts @@ -150,7 +150,7 @@ export type TranslationStrings = { */ @Injectable() export class I18n { - protected translationStrings: TranslationStrings = EN + protected translationStrings: TranslationStrings = EN; protected translations = new Map();