translations

This commit is contained in:
2025-06-25 13:53:36 +02:00
parent 9407253e69
commit 3521a477f2
12 changed files with 224 additions and 133 deletions

View File

@ -1,5 +1,6 @@
import type { VueI18n } from "vue-i18n";
import { usePB } from "~/composables/usePB";
import type { GenericResponse } from "~/types";
export default defineNuxtPlugin(async (nuxtApp) => {
const loaded = [] as Array<string>;
@ -11,16 +12,16 @@ export default defineNuxtPlugin(async (nuxtApp) => {
if (loaded.includes(newLocale)) return;
try {
const translation = await pb.collection("translation").getList(1, 1, {
expand: "id_lang",
filter: `id_lang.iso='${newLocale}'`,
});
// const translation = await pb.collection("translation").getList(1, 1, {
// expand: "id_lang",
// filter: `id_lang.iso='${newLocale}'`,
// });
if (translation.totalItems === 1) {
i18n.setLocaleMessage(newLocale, translation.items[0].data);
} else {
i18n.setLocaleMessage(newLocale, {});
}
const { data } = await useMyFetch<GenericResponse<object>>(
"/api/public/front/translation"
);
i18n.setLocaleMessage(newLocale, data);
loaded.push(newLocale);
} catch (err) {
@ -28,4 +29,4 @@ export default defineNuxtPlugin(async (nuxtApp) => {
throw err;
}
};
});
});

View File

@ -3,7 +3,6 @@ import { defineNuxtPlugin } from "#app";
export default defineNuxtPlugin(async () => {
const menuStore = useMenuStore();
await menuStore.loadMenu();
await menuStore.loadFooter();
await menuStore.getCountryList();
await menuStore.getCurrencies();
});