File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'fs-extra' ;
2
2
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin' ;
3
3
import webpack from 'webpack' ;
4
+ import translations from '../src/script/translations.js' ;
4
5
5
6
const BUILD = fs . readJsonSync ( '.build.json' ) ;
6
7
@@ -35,6 +36,7 @@ export default {
35
36
} ,
36
37
plugins : [
37
38
new webpack . DefinePlugin ( { __BUILD__ : JSON . stringify ( BUILD ) } ) ,
39
+ new webpack . DefinePlugin ( { __TRANSLATIONS__ : JSON . stringify ( translations ) } ) ,
38
40
] ,
39
41
resolve : {
40
42
extensions : [ '.js' , '.ts' ] ,
Original file line number Diff line number Diff line change 1
1
import i18next , { i18n } from 'i18next' ;
2
- import translations from '@APF/translations.js' ;
3
2
import { stringArray } from '@APF/lib/helper' ;
4
3
4
+ // __TRANSLATIONS__ is injected by webpack from ROOT/src/script/
5
+ /* eslint-disable-next-line @typescript-eslint/naming-convention */
6
+ declare const __TRANSLATIONS__ : any ;
7
+
5
8
export default class Translation {
6
9
i18next : i18n ;
7
10
11
+ static readonly translations = typeof __TRANSLATIONS__ == 'undefined' ? { common : { } } : __TRANSLATIONS__ ;
12
+
8
13
//#region Class reference helpers
9
14
// Can be overridden in children classes
10
15
get Class ( ) { return ( this . constructor as typeof Translation ) ; }
@@ -17,7 +22,7 @@ export default class Translation {
17
22
lng : language ,
18
23
fallbackLng : 'en' ,
19
24
ns : namespaces ,
20
- resources : translations
25
+ resources : this . Class . translations ,
21
26
} ) ;
22
27
}
23
28
You can’t perform that action at this time.
0 commit comments