Skip to content

Commit

Permalink
style: apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Trap committed Dec 28, 2024
1 parent cca46bb commit 935681f
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/services/LocaleResolver.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { type LocaleName } from '../config';

export type AllLocalesInDb = Record<string, Record<string, string>>;

type LocaleKey = string;

type LocaleKeysLowerCaseMapping = {
[localeName: string]: {
[lowerCasedLocaleKey: string]: LocaleKey;
};
};

export class LocaleResolver {
private readonly localeKeysMapping: LocaleKeysLowerCaseMapping = {};

constructor(allLocales: AllLocalesInDb) {
void Object.keys(allLocales).forEach(localeName => {
const localeValues: Record<string, string> = {};
this.localeKeysMapping[localeName] = localeValues;

void Object.keys(allLocales[localeName]).forEach(localeKey => {
localeValues[localeKey.toLowerCase()] = localeKey;
});
});
}

public retrieveKey(exfilName: string, locale: LocaleName): string {
return this.localeKeysMapping?.[locale]?.[exfilName.toLowerCase()] ?? exfilName;
}
}
import { type LocaleName } from '../config';

export type AllLocalesInDb = Record<string, Record<string, string>>;

type LocaleKey = string;

type LocaleKeysLowerCaseMapping = {
[localeName: string]: {
[lowerCasedLocaleKey: string]: LocaleKey;
};
};

export class LocaleResolver {
private readonly localeKeysMapping: LocaleKeysLowerCaseMapping = {};

constructor(allLocales: AllLocalesInDb) {
void Object.keys(allLocales).forEach(localeName => {
const localeValues: Record<string, string> = {};
this.localeKeysMapping[localeName] = localeValues;

void Object.keys(allLocales[localeName]).forEach(localeKey => {
localeValues[localeKey.toLowerCase()] = localeKey;
});
});
}

public retrieveKey(exfilName: string, locale: LocaleName): string {
return this.localeKeysMapping?.[locale]?.[exfilName.toLowerCase()] ?? exfilName;
}
}

0 comments on commit 935681f

Please sign in to comment.