Skip to content

Commit 17bedef

Browse files
author
Petr Kachanovsky
committed
fix: add translation loading to every page
1 parent 3de3136 commit 17bedef

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

custom/LanguageEveryPageLoader.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template/>
2+
3+
<script setup>
4+
import { onMounted } from 'vue';
5+
import { useI18n } from 'vue-i18n';
6+
import { setLang, getLocalLang } from './langCommon';
7+
8+
const { setLocaleMessage, locale } = useI18n();
9+
10+
const props = defineProps(['meta']);
11+
12+
onMounted(() => {
13+
setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, getLocalLang(props.meta.supportedLanguages));
14+
});
15+
</script>

custom/LanguageInUserMenu.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ const selectedOption = computed(() => {
8787
8888
8989
onMounted(() => {
90-
console.log('Language In user menu mounted', props.meta.supportedLanguages);
9190
selectedLanguage.value = getLocalLang(props.meta.supportedLanguages);
92-
setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, selectedLanguage.value);
93-
// todo this mounted executed only on this component mount, f5 from another page apart login will not read it
9491
});
95-
96-
97-
98-
99-
100-
101-
10292
</script>

custom/LanguageUnderLogin.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ const options = computed(() => {
6161
});
6262
6363
onMounted(() => {
64-
console.log('LanguageUnderLogin mounted', props.meta.supportedLanguages);
6564
selectedLanguage.value = getLocalLang(props.meta.supportedLanguages);
66-
setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, selectedLanguage.value);
67-
// todo this mounted executed only on this component mount, f5 from another page apart login will not read it
6865
});
69-
70-
71-
72-
73-
74-
75-
7666
</script>

index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ export default class I18nPlugin extends AdminForthPlugin {
250250
meta: compMeta
251251
});
252252

253+
adminforth.config.customization.globalInjections.everyPageBottom.push({
254+
file: this.componentPath('LanguageEveryPageLoader.vue'),
255+
meta: compMeta
256+
});
257+
253258
// disable create allowedActions for translations
254259
resourceConfig.options.allowedActions.create = false;
255260

0 commit comments

Comments
 (0)