Skip to content

Commit

Permalink
fix: typing for loading translation strings (#3077)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshat Patel <[email protected]>
  • Loading branch information
klaascuvelier and Akshat55 authored Dec 17, 2024
1 parent 5c03216 commit f591581
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


/**
Expand All @@ -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();

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit f591581

Please sign in to comment.