Dynamically load language files (#446)

This commit is contained in:
Darko Gjorgjijoski
2025-08-28 15:19:51 +02:00
committed by GitHub
parent 32f7bc053a
commit a40bf5840d
10 changed files with 154 additions and 59 deletions

View File

@@ -65,7 +65,8 @@ export default {
}
if(typeof res.data.profile_language === 'string') {
global.locale.value = res.data.profile_language
// Use dynamic language loading instead of direct assignment
await window.loadLanguage(res.data.profile_language)
}
let dbstep = parseInt(res.data.profile_complete)

View File

@@ -27,6 +27,8 @@
<BaseButton
v-show="!isFetchingInitialData"
:loading="isChangingLanguage"
:disabled="isChangingLanguage"
@click="next"
>
{{ $t('wizard.continue') }}
@@ -43,12 +45,11 @@
import { ref, onMounted } from 'vue'
import { useInstallationStore } from '@/scripts/admin/stores/installation.js'
const { global } = window.i18n
const emit = defineEmits(['next'])
let isFetchingInitialData = ref(false)
let isSaving = ref(false)
let isChangingLanguage = ref(false)
let languages = ref([])
let currentLanguage = 'en'
@@ -75,11 +76,19 @@ function next() {
isSaving.value = false
}
function changeLanguage(event){
if(typeof global.locale !== 'string') {
global.locale.value = event
async function changeLanguage(event) {
if (!event) return
isChangingLanguage.value = true
try {
// Dynamically load the selected language
await window.loadLanguage(event)
currentLanguage.value = event
} catch (error) {
console.error('Failed to change language:', error)
} finally {
isChangingLanguage.value = false
}
}
</script>