Fix: translations

This commit is contained in:
Kujiu 2021-12-04 16:44:11 +01:00
parent 39dc1e4d18
commit 8b596c0f6e
Signed by: kujiu
GPG key ID: ABBB2CAC6855599F
8 changed files with 65 additions and 27 deletions

View file

@ -1,5 +1,8 @@
<script setup> <script setup>
import ReloadPWA from './components/ReloadPWA.vue'; import ReloadPWA from './components/ReloadPWA.vue';
import {useI18n} from 'vue-i18n';
const {t} = useI18n({useScope: 'local'});
</script> </script>
<template> <template>
@ -10,8 +13,14 @@ import ReloadPWA from './components/ReloadPWA.vue';
<header> <header>
<router-link to='/apps'> <router-link to='/apps'>
<img alt="" src="./assets/logo.svg"/> <img alt="" src="./assets/logo.svg"/>
{{ $t('home.apps') }} {{ t('home.apps') }}
</router-link> </router-link>
<select v-model="$i18n.locale" @change="$i18n.loadMessages()">
<option value="de">Deutsch</option>
<option value="en">English</option>
<option value="fr">Français</option>
<option value="nl">Nederlands</option>
</select>
</header> </header>
<footer> <footer>
</footer> </footer>

View file

@ -236,12 +236,14 @@ h1, h2, h3, h4, h5, h6 {
h1 { h1 {
font-size: 2.2rem; font-size: 2.2rem;
padding-bottom: .3rem;
border-bottom: 0.3em solid var(--BClr);
} }
h2 { h2 {
font-size: 1.65rem; font-size: 1.65rem;
padding-bottom: .3rem; padding-bottom: .2rem;
border-bottom: 0.3em solid var(--BClr); border-bottom: 0.2em solid var(--BClr);
} }
h3 { h3 {

View file

@ -1,7 +1,16 @@
<script setup>
import {useI18n} from 'vue-i18n';
const {t} = useI18n({useScope: 'local'});
</script>
<template> <template>
<h1>Communication</h1> <h1>{{ t('apps.communication') }}</h1>
<h1>Accounting</h1> <h1>{{ t('apps.accounting') }}</h1>
<h1>Ordering</h1> <h1>{{ t('apps.ordering') }}</h1>
<h1>Stocks</h1> <h1>{{ t('apps.stocks') }}</h1>
<h1>Monitoring</h1> <h1>{{ t('apps.monitoring') }}</h1>
</template> </template>
<i18n lang="json" locale="en" src="../locale/en.json"/>
<i18n lang="json" locale="fr" src="../locale/fr.json"/>

View file

@ -2,18 +2,18 @@
<div v-if="offlineReady || needRefresh" role="alert"> <div v-if="offlineReady || needRefresh" role="alert">
<div class="admonition warning"> <div class="admonition warning">
<span v-if="offlineReady"> <span v-if="offlineReady">
{{ $t('pwa.ready') }} {{ t('pwa.ready') }}
</span> </span>
<span v-else> <span v-else>
{{ $t('pwa.new_content') }} {{ t('pwa.new_content') }}
</span> </span>
</div> </div>
<div class=""> <div class="">
<button v-if="needRefresh" @click="updateServiceWorker()"> <button v-if="needRefresh" @click="updateServiceWorker()">
{{ $t('pwa.reload') }} {{ t('pwa.reload') }}
</button> </button>
<button @click="close"> <button @click="close">
{{ $t('pwa.close') }} {{ t('pwa.close') }}
</button> </button>
</div> </div>
</div> </div>
@ -22,18 +22,20 @@
<script> <script>
import {defineComponent} from "vue"; import {defineComponent} from "vue";
import {useRegisterSW} from "virtual:pwa-register/vue"; import {useRegisterSW} from "virtual:pwa-register/vue";
import {useI18n} from 'vue-i18n';
const {updateServiceWorker} = useRegisterSW(); const {updateServiceWorker} = useRegisterSW();
export default defineComponent({ export default defineComponent({
name: "ReloadPWA", name: "ReloadPWA",
setup() { setup() {
const {t} = useI18n({useScope: 'local'});
const {offlineReady, needRefresh, updateServiceWorker} = useRegisterSW(); const {offlineReady, needRefresh, updateServiceWorker} = useRegisterSW();
const close = async () => { const close = async () => {
offlineReady.value = false; offlineReady.value = false;
needRefresh.value = false; needRefresh.value = false;
}; };
return {offlineReady, needRefresh, updateServiceWorker, close}; return {offlineReady, needRefresh, updateServiceWorker, close, t};
}, },
methods: { methods: {
async close() { async close() {
@ -46,5 +48,6 @@ export default defineComponent({
}, },
}); });
</script> </script>
<i18n lang="json" locale="en" src="../locale/en.json"/> <i18n lang="json" locale="en" src="../locale/en.json"/>
<i18n lang="json" locale="fr" src="../locale/fr.json"/> <i18n lang="json" locale="fr" src="../locale/fr.json"/>

View file

@ -1,4 +1,11 @@
{ {
"apps": {
"communication": "",
"accounting": "",
"ordering": "",
"stocks": "",
"monitoring": ""
},
"home": { "home": {
"apps": "Applications" "apps": "Applications"
}, },

View file

@ -1,4 +1,11 @@
{ {
"apps": {
"communication": "Communication",
"accounting": "Comptabilité",
"ordering": "Commande",
"stocks": "Stocks",
"monitoring": "Veille"
},
"home": { "home": {
"apps": "Applications" "apps": "Applications"
}, },

View file

@ -22,8 +22,7 @@ app.use(createI18n({
locale: languages[0].trim().split(/-|_/)[0], locale: languages[0].trim().split(/-|_/)[0],
fallbackLocale: 'en', fallbackLocale: 'en',
legacy: false, legacy: false,
globalInjection: true, globalInjection: true
messages: {}
})); }));
app.use(router); app.use(router);
app.use(store); app.use(store);

View file

@ -16,7 +16,9 @@ export default defineConfig({
plugins: [ plugins: [
vue(), vue(),
vueI18n({ vueI18n({
include: path.resolve(__dirname, '**/locale/**') include: path.resolve(__dirname, '**/locale/**'),
compositionOnly: true,
fullInstall: true
}), }),
VitePWA({ VitePWA({
mode: "production", mode: "production",