translations
This commit is contained in:
@ -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;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
Reference in New Issue
Block a user