248
248
249
249
<script setup>
250
250
import { useI18n } from " vue-i18n"
251
- import { onMounted , provide , ref } from " vue"
251
+ import { onMounted , provide , ref , watch } from " vue"
252
252
253
253
import BaseAppLink from " ./components/basecomponents/BaseAppLink.vue"
254
254
import BaseButton from " ./components/basecomponents/BaseButton.vue"
@@ -260,8 +260,8 @@ import Step5 from "./components/installer/Step5"
260
260
import Step6 from " ./components/installer/Step6"
261
261
import Step7 from " ./components/installer/Step7"
262
262
263
- const { t } = useI18n ()
264
- const installerData = ref (window .installerData )
263
+ const { t , locale } = useI18n ()
264
+ const installerData = ref (window .installerData || {} )
265
265
266
266
if (! installerData .value .stepData ) {
267
267
installerData .value .stepData = {
@@ -304,15 +304,63 @@ const steps = ref([
304
304
},
305
305
])
306
306
307
+ function refreshStepTitles () {
308
+ steps .value = [
309
+ { step: 1 , stepTitle: t (" Installation language" ) },
310
+ { step: 2 , stepTitle: t (" Requirements" ) },
311
+ { step: 3 , stepTitle: t (" License" ) },
312
+ { step: 4 , stepTitle: t (" Database settings" ) },
313
+ { step: 5 , stepTitle: t (" Config settings" ) },
314
+ { step: 6 , stepTitle: t (" Show Overview" ) },
315
+ { step: 7 , stepTitle: t (" Install" ) },
316
+ ]
317
+ }
318
+
319
+ function normalizeLocale (iso ) {
320
+ if (! iso) return " en_US"
321
+ const low = String (iso).toLowerCase ()
322
+ if (low === " es" || low .startsWith (" es_" )) return " es"
323
+ if (low === " en" || low .startsWith (" en_" )) return " en_US"
324
+ return iso
325
+ }
326
+
307
327
onMounted (() => {
308
- const txtIsExecutable = document .getElementById (" is_executable" )
328
+ const initial = normalizeLocale (
329
+ installerData .value .langIso || installerData .value .languageForm
330
+ )
331
+
332
+ installerData .value .langIso = initial
309
333
310
- if (! txtIsExecutable) {
311
- return
334
+ if (initial && locale .value !== initial) {
335
+ locale .value = initial
336
+ refreshStepTitles ()
312
337
}
313
338
314
- document
315
- .querySelectorAll (" button" )
316
- .forEach ((button ) => button .addEventListener (" click" , () => (txtIsExecutable .value = button .name )))
339
+ const txtIsExecutable = document .getElementById (" is_executable" )
340
+ if (! txtIsExecutable) return
341
+
342
+ const form = document .getElementById (" install_form" )
343
+ if (form) {
344
+ form
345
+ .querySelectorAll (" button" )
346
+ .forEach ((button ) =>
347
+ button .addEventListener (" click" , () => (txtIsExecutable .value = button .name ))
348
+ )
349
+ }
317
350
})
351
+
352
+ watch (
353
+ () => installerData .value ? .langIso ,
354
+ (iso ) => {
355
+ const next = normalizeLocale (iso)
356
+ if (next && next !== iso) {
357
+ installerData .value .langIso = next
358
+ return
359
+ }
360
+ if (next && locale .value !== next) {
361
+ locale .value = next
362
+ refreshStepTitles ()
363
+ }
364
+ }
365
+ )
318
366
< / script>
0 commit comments