@@ -14,6 +14,7 @@ import {contentType} from 'mime-types';
1414import * as CloudFunc from '#common/cloudfunc' ;
1515import root from './root.js' ;
1616import prefixer from './prefixer.js' ;
17+ import { readTranslations } from './i18n.js' ;
1718import Template from './template.js' ;
1819import { getColumns } from './columns.js' ;
1920import { getThemes } from './theme.js' ;
@@ -167,32 +168,8 @@ function indexProcessing(config, options) {
167168 const name = config ( 'name' ) ;
168169
169170 const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
170- let lang = config ( 'lang' ) ;
171- if ( ! lang || lang === 'undefined' ) {
172- lang = 'en' ;
173- }
174-
175- let dictPath = join ( __dirname , '..' , 'json' , 'i18n' , `${ lang } .json` ) ;
176- let [ readError , jsonString ] = tryCatch ( readFileSync , dictPath , 'utf8' ) ;
177-
178- if ( readError ) {
179- // Diagnostyka dla GitHub Actions - wypisujemy gdzie dokładnie szuka serwer
180- console . error ( '=== I18N DEBUG INFO ===' ) ;
181- console . error ( 'Current __dirname:' , __dirname ) ;
182- console . error ( 'Attempted dictPath 1:' , dictPath ) ;
183- console . error ( 'Error Message:' , readError . message ) ;
184-
185- dictPath = join ( __dirname , '..' , '..' , 'json' , 'i18n' , `${ lang } .json` ) ;
186- console . error ( 'Attempted dictPath 2:' , dictPath ) ;
187- [ readError , jsonString ] = tryCatch ( readFileSync , dictPath , 'utf8' ) ;
188- }
189-
190- if ( readError ) {
191- dictPath = join ( __dirname , '..' , 'json' , 'i18n' , 'en.json' ) ;
192- [ readError , jsonString ] = tryCatch ( readFileSync , dictPath , 'utf8' ) ;
193- }
194-
195- const i18nPack = readError ? { } : JSON . parse ( jsonString ) ;
171+ const lang = config ( 'lang' ) || 'en' ;
172+ const i18nPack = readTranslations ( lang ) ;
196173
197174 data = rendy ( data , {
198175 title : CloudFunc . getTitle ( {
@@ -203,14 +180,11 @@ function indexProcessing(config, options) {
203180 config : stringify ( config ( '*' ) ) ,
204181 columns : getColumns ( ) [ config ( 'columns' ) ] ,
205182 themes : getThemes ( ) [ config ( 'theme' ) ] ,
183+ i18n : stringify ( i18nPack ) . replace ( / " / g, '"' ) || '{}' ,
206184 } ) ;
207185
208- const i18nScript = `<script>window.__CLOUDCMD_I18N_PACK__ = ${ stringify ( i18nPack ) } ;</script>` ;
209- data = data . replace ( '<head>' , `<head>${ i18nScript } ` ) ;
210-
211186 return data ;
212187
213-
214188}
215189
216190function buildIndex ( config , html , data ) {
0 commit comments