Skip to content

Commit 262fa6a

Browse files
committed
prepare for localization map
1 parent e83a011 commit 262fa6a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core/contracts/localizer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

22
export interface Localizer {
33
translate(text: string, local: string) : string;
4+
// translationsFor(path: string): Record<string, any>
45
}

src/optional/localizer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ import assert from 'node:assert';
1313
*/
1414
export class ShrimpleLocalizer implements Localizer, Init {
1515
private __localization!: Localization;
16+
private __localization_map!: Record<string, any>
1617
constructor(){}
18+
1719
translate(text: string, local: string): string {
1820
this.__localization.changeLanguage(local);
1921
return this.__localization.get(text);
2022
}
2123

2224
async init() {
25+
const map = await this.readLocalizationDirectory();
2326
this.__localization = new Localization({
2427
defaultLocale: "en",
2528
fallbackLocale: "en",
26-
locales: await this.readLocalizationDirectory()
29+
locales: map
2730
});
31+
this.__localization_map = map
2832
}
2933

3034
private async readLocalizationDirectory() {

0 commit comments

Comments
 (0)