Skip to content

Commit f591581

Browse files
fix: typing for loading translation strings (#3077)
Co-authored-by: Akshat Patel <[email protected]>
1 parent 5c03216 commit f591581

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/i18n/i18n.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export class Overridable {
135135
/**
136136
* An object of strings, should follow the same format as src/i18n/en.json
137137
*/
138-
export type TranslationStrings = { [key: string]: string };
138+
export type TranslationStrings = {
139+
[key: string]: string | TranslationStrings;
140+
};
139141

140142

141143
/**
@@ -148,7 +150,7 @@ export type TranslationStrings = { [key: string]: string };
148150
*/
149151
@Injectable()
150152
export class I18n {
151-
protected translationStrings = EN;
153+
protected translationStrings: TranslationStrings = EN;
152154

153155
protected translations = new Map();
154156

@@ -264,8 +266,8 @@ export class I18n {
264266
*
265267
* @param path looks like `"NOTIFICATION.CLOSE_BUTTON"`
266268
*/
267-
public getValueFromPath(path): string | { [key: string]: string } {
268-
let value = this.translationStrings;
269+
public getValueFromPath(path: string): string | TranslationStrings {
270+
let value: string | TranslationStrings = this.translationStrings;
269271
for (const segment of path.split(".")) {
270272
if (value[segment] !== undefined && value[segment] !== null) {
271273
value = value[segment];

0 commit comments

Comments
 (0)