File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,6 @@ const unplugin = createUnplugin<ReplexicaConfig>((options) => ({
1515 transform ( code , absoluteFilePath ) {
1616 try {
1717 const relativeFilePath = path . relative ( process . cwd ( ) , absoluteFilePath ) ;
18-
19- const relativeFileDir = path . relative ( process . cwd ( ) , path . dirname ( absoluteFilePath ) ) ;
2018
2119 const compiler = ReplexicaCompiler
2220 . fromCode ( code , relativeFilePath )
@@ -28,9 +26,10 @@ const unplugin = createUnplugin<ReplexicaConfig>((options) => ({
2826 const result = compiler . generate ( ) ;
2927
3028 const outputProcessor = ReplexicaOutputProcessor . create ( relativeFilePath , options ) ;
31- outputProcessor . saveData ( compiler . data ) ;
29+ outputProcessor . saveBuildData ( compiler . data ) ;
3230 outputProcessor . saveFullSourceLocaleData ( compiler . data ) ;
3331 outputProcessor . saveClientSourceLocaleData ( compiler . data ) ;
32+ outputProcessor . saveStubLocaleData ( ) ;
3433
3534 if ( options . debug ) {
3635 outputProcessor . saveAst ( compiler . ast ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class ReplexicaOutputProcessor {
1717 private _outDir = path . join ( process . cwd ( ) , `node_modules/@replexica/translations` ) ;
1818 private _debugDir = path . join ( process . cwd ( ) , '.debug/replexica' ) ;
1919
20- public saveData ( data : ReplexicaCompilerData ) {
20+ public saveBuildData ( data : ReplexicaCompilerData ) {
2121 const filePath = path . join ( this . _outDir , '.replexica.json' ) ;
2222 const existingData : ReplexicaData = this . _loadObject < ReplexicaData > ( filePath ) || this . _createEmptyData ( ) ;
2323 const newData : ReplexicaData = {
@@ -50,6 +50,16 @@ export class ReplexicaOutputProcessor {
5050 ) ;
5151 }
5252
53+ public saveStubLocaleData ( ) {
54+ for ( const targetLocale of this . options . locale . targets ) {
55+ const fullLocaleDataFilePath = path . join ( this . _outDir , `${ targetLocale } .json` ) ;
56+ fs . writeFileSync ( fullLocaleDataFilePath , '{}' , 'utf-8' ) ;
57+
58+ const clientLocaleDataFilePath = path . join ( this . _outDir , `${ targetLocale } .client.json` ) ;
59+ fs . writeFileSync ( clientLocaleDataFilePath , '{}' , 'utf-8' ) ;
60+ }
61+ }
62+
5363 private _saveSourceLocaleData (
5464 data : ReplexicaCompilerData ,
5565 fileName : string ,
You can’t perform that action at this time.
0 commit comments