File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
2
2
export interface Localizer {
3
3
translate ( text : string , local : string ) : string ;
4
+ // translationsFor(path: string): Record<string, any>
4
5
}
Original file line number Diff line number Diff line change @@ -13,18 +13,22 @@ import assert from 'node:assert';
13
13
*/
14
14
export class ShrimpleLocalizer implements Localizer , Init {
15
15
private __localization ! : Localization ;
16
+ private __localization_map ! : Record < string , any >
16
17
constructor ( ) { }
18
+
17
19
translate ( text : string , local : string ) : string {
18
20
this . __localization . changeLanguage ( local ) ;
19
21
return this . __localization . get ( text ) ;
20
22
}
21
23
22
24
async init ( ) {
25
+ const map = await this . readLocalizationDirectory ( ) ;
23
26
this . __localization = new Localization ( {
24
27
defaultLocale : "en" ,
25
28
fallbackLocale : "en" ,
26
- locales : await this . readLocalizationDirectory ( )
29
+ locales : map
27
30
} ) ;
31
+ this . __localization_map = map
28
32
}
29
33
30
34
private async readLocalizationDirectory ( ) {
You can’t perform that action at this time.
0 commit comments