refactor(i18n): improve language handling and UI updates
All checks were successful
Deploy to production / deploy (push) Successful in 2m49s
All checks were successful
Deploy to production / deploy (push) Successful in 2m49s
- Enhanced language setting logic in App.vue and AppHeader.vue to support reactive updates without page reloads. - Updated language options in AppHeader.vue to use native labels for improved clarity. - Introduced a utility function in i18n/index.js to streamline locale updates, ensuring consistent language handling across the application.
This commit is contained in:
@@ -195,11 +195,20 @@ const i18n = createI18n({
|
||||
messages
|
||||
});
|
||||
|
||||
// Überwache Änderungen der Sprache im Store und aktualisiere i18n entsprechend
|
||||
function setGlobalLocale(next) {
|
||||
const loc = i18n.global.locale;
|
||||
if (loc && typeof loc === 'object' && 'value' in loc) {
|
||||
loc.value = next;
|
||||
} else {
|
||||
i18n.global.locale = next;
|
||||
}
|
||||
}
|
||||
|
||||
// Überwache Änderungen der Sprache im Store und aktualisiere i18n (ohne Seiten-Reload)
|
||||
store.watch(
|
||||
(state) => state.language,
|
||||
(newLanguage) => {
|
||||
i18n.global.locale.value = newLanguage;
|
||||
setGlobalLocale(newLanguage);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user