File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,19 @@ export async function prepareJsonFiles() {
3737 await Promise . all ( currentLocales . map ( l => mergeLocale ( l ) ) )
3838}
3939
40- export async function mergeLocaleObject ( locale : LocaleObject ) {
40+ export async function mergeLocaleObject ( locale : LocaleObject , copy = false ) {
4141 const files = locale . files ?? [ ]
4242 if ( locale . file || files . length === 1 ) {
43- const json = locale . file ?? ( files [ 0 ] ? getFileName ( files [ 0 ] ) : undefined )
43+ const json =
44+ ( locale . file ? getFileName ( locale . file ) : undefined ) ??
45+ ( files [ 0 ] ? getFileName ( files [ 0 ] ) : undefined )
4446 if ( ! json ) return
45- await fs . cp ( path . resolve ( `${ localesFolder } /${ json } ` ) , path . resolve ( `${ destFolder } /${ json } ` ) )
46- return
47+ if ( copy ) {
48+ await fs . cp ( path . resolve ( `${ localesFolder } /${ json } ` ) , path . resolve ( `${ destFolder } /${ json } ` ) )
49+ return
50+ } else {
51+ return await loadJsonFile ( json )
52+ }
4753 }
4854
4955 const firstFile = files [ 0 ]
@@ -69,9 +75,14 @@ function getFileName(file: string | { path: string }): string {
6975}
7076
7177async function mergeLocale ( locale : LocaleObject ) {
72- const source = await mergeLocaleObject ( locale )
78+ const source = await mergeLocaleObject ( locale , true )
79+ if ( ! source ) {
80+ return
81+ }
82+
7383 await fs . writeFile (
7484 path . resolve ( `${ destFolder } /${ locale . code } .json` ) ,
7585 JSON . stringify ( source , null , 2 ) ,
86+ 'utf-8' ,
7687 )
7788}
You can’t perform that action at this time.
0 commit comments