diff --git a/components/layout/AppHeader-ldcgroup.vue b/components/layout/AppHeader-ldcgroup.vue index ff4dc4c..d127922 100644 --- a/components/layout/AppHeader-ldcgroup.vue +++ b/components/layout/AppHeader-ldcgroup.vue @@ -166,7 +166,10 @@ export default defineComponent({ this.settings = useAppStore().data.settings(); const { locale, availableLocales } = useI18n({ useScope: "global"}); this.locale = locale.value; - const localeSortArr = ["fr", "nl"]; + let localeSortArr = [] as Array; + window.ipcRendererObject.getJsonData().then((dataJson) => { + localeSortArr = dataJson.settings.locales; + }); this.locales = availableLocales.sort((LocA, LocB) => localeSortArr.indexOf(LocA) - localeSortArr.indexOf(LocB)).map(localeStr => { return { iso: localeStr, diff --git a/components/layout/AppHeader.vue b/components/layout/AppHeader.vue index c096a9a..fc0d950 100644 --- a/components/layout/AppHeader.vue +++ b/components/layout/AppHeader.vue @@ -69,7 +69,6 @@ 'btn ms-3 px-2 mx-0 shadow fw-bold': true, 'btn-secondary': locale !== localeObject.iso, 'btn-white bg-white': locale === localeObject.iso, - 'd-none': localeObject.show !== true, }" :title="localeObject.label" data-bs-toggle="tooltip" @@ -97,7 +96,6 @@ type LocaleParams = { iso: string, flag: string, label: string, - show: boolean, }; export default defineComponent({ @@ -154,13 +152,15 @@ export default defineComponent({ this.settings = useAppStore().data.settings(); const { locale, availableLocales } = useI18n({ useScope: "global"}); this.locale = locale.value; - const localeSortArr = ["fr", "en", "de", "es", "nl"]; + let localeSortArr = [] as Array; + window.ipcRendererObject.getJsonData().then((dataJson) => { + localeSortArr = dataJson.settings.locales; + }); this.locales = availableLocales.sort((LocA, LocB) => localeSortArr.indexOf(LocA) - localeSortArr.indexOf(LocB)).map(localeStr => { return { iso: localeStr, flag: this.t("_flag", {}, localeStr), label: this.t("_lang", {}, localeStr), - show: this.t("_show", {}, localeStr) === "true", }; }); }, diff --git a/i18n.config.ts b/i18n.config.ts index 39f42dc..95686de 100644 --- a/i18n.config.ts +++ b/i18n.config.ts @@ -1,19 +1,18 @@ -import de from "./locales/de"; -import en from "./locales/en"; -import es from "./locales/es"; -import fr from "./locales/fr"; -import nl from "./locales/nl"; +export default defineI18nConfig(async () => { + const dataJson = await window.ipcRendererObject.getJsonData(); + const localeCodes = dataJson.settings.locales; -export default defineI18nConfig(() => ({ - legacy: false, - globalInjection: true, - locale: "fr", - fallbackLocale: "fr", - messages: { - fr, - de, - en, - nl, - es + const messages: Record = {}; + + for (const locale of localeCodes) { + messages[locale] = (await import(`./locales/${locale}.ts`)).default; } -})); + + return { + legacy: false, + globalInjection: true, + locale: "fr", + fallbackLocale: "fr", + messages, + }; +}); diff --git a/index.d.ts b/index.d.ts index b63a58f..e81d9bc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,14 +1,12 @@ export { }; - import type { RouteLocation as NRouteLocation } from "vue-router"; - import type { ipcRendererObject, versions } from "./electron/preload"; +import type { RouteLocation as NRouteLocation } from "vue-router"; +import type { ipcRendererObject, versions } from "./electron/preload"; // * --- MODELS From JSON Schema type Locale = string; -type i18nFieldList = -"name" | "slug" | "description" | -"sub_title" | "footer_phrase"; +type i18nFieldList = "name" | "slug" | "description" | "sub_title" | "footer_phrase"; type i18nField = Record; type i18nModel = SettingsModel | BrandModel | RangeModel | ProductModel; @@ -23,6 +21,8 @@ type AppModel = { /** Settings from Showroom Bo */ type SettingsModel = { + /** Langues disponibles dans l'application */ + locales: Array /** Sous-titre de l'application */ sub_title: i18nField; /** Texte en bas de page */ diff --git a/locales/de.ts b/locales/de.ts index 61f4b72..ef1d7ce 100644 --- a/locales/de.ts +++ b/locales/de.ts @@ -1,7 +1,6 @@ export default { "_flag": "de", "_lang": "Deutsch", - "_show": "true", "error_occured": "An error has occured", "loading": "Loading", "show_hide_languages": "Show / Hide languages", diff --git a/locales/en.ts b/locales/en.ts index ae265f6..374ebb7 100644 --- a/locales/en.ts +++ b/locales/en.ts @@ -1,7 +1,6 @@ export default { "_flag": "en", "_lang": "English", - "_show": "true", "error_occured": "An error has occured", "loading": "Loading", "show_hide_languages": "Show / Hide languages", diff --git a/locales/es.ts b/locales/es.ts index 946dce8..64bb26d 100644 --- a/locales/es.ts +++ b/locales/es.ts @@ -1,7 +1,6 @@ export default { "_flag": "es", "_lang": "Español", - "_show": "true", "error_occured": "Se ha producido un error", "loading": "Loading", "show_hide_languages": "Mostrar / Ocultar idiomas", diff --git a/locales/fr.ts b/locales/fr.ts index 3b99cb6..5191408 100644 --- a/locales/fr.ts +++ b/locales/fr.ts @@ -1,7 +1,6 @@ export default { "_flag": "fr", "_lang": "Francais", - "_show": "true", "error_occured": "Une erreur est survenue", "loading": "Chargement", "show_hide_languages": "Afficher / Masquer les langues", diff --git a/locales/nl.ts b/locales/nl.ts index 19099bd..a0316df 100644 --- a/locales/nl.ts +++ b/locales/nl.ts @@ -1,7 +1,6 @@ export default { "_flag": "nl", "_lang": "Nederlands", - "_show": "true", "error_occured": "Er is een fout opgetreden", "loading": "Bezig met laden", "show_hide_languages": "Talen tonen/verbergen", diff --git a/nuxt.config.ts b/nuxt.config.ts index 40100d4..6d426f3 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -70,7 +70,7 @@ export default defineNuxtConfig({ pinia: "/node_modules/@pinia/nuxt/node_modules/pinia/dist/pinia.mjs" }, i18n: { - locales: ["fr", "en", "de", "es", "nl"], + locales: UnzipData.loadJsonDataFile()?.settings.locales, defaultLocale: "fr", // * Ajouter aussi la locale dans ce fichier vueI18n: "./i18n.config.ts" diff --git a/public/schemas/brand.schema.json b/public/schemas/brand.schema.json index 28a747b..62c6a9a 100644 --- a/public/schemas/brand.schema.json +++ b/public/schemas/brand.schema.json @@ -43,10 +43,6 @@ "description": "Couleur de la marque", "$ref": "#/$defs/hexcolor" }, - "shelf": { - "description": "Les enfant sont rendus sur un étagere.", - "type": "boolean" - }, "status": { "description": "Visible ? (présent dans l'export).", "type": "boolean" @@ -82,7 +78,6 @@ "name", "slug", "color", - "shelf", "status", "picture", "created_at", diff --git a/public/schemas/range.schema.json b/public/schemas/range.schema.json index 1c56ccb..84476cc 100644 --- a/public/schemas/range.schema.json +++ b/public/schemas/range.schema.json @@ -58,10 +58,6 @@ "type": "integer", "minimum": 1 }, - "shelf": { - "description": "Les enfant sont rendus sur un étagere.", - "type": "boolean" - }, "status": { "description": "Visible ? (présent dans l'export).", "type": "boolean" @@ -104,7 +100,6 @@ "slug", "picture", "order", - "shelf", "status", "brand_id", "font_id", diff --git a/public/schemas/settings.schema.json b/public/schemas/settings.schema.json index eaf75cc..43daacf 100644 --- a/public/schemas/settings.schema.json +++ b/public/schemas/settings.schema.json @@ -4,6 +4,10 @@ "description": "Settings from Showroom Bo", "type": "object", "properties": { + "locales": { + "description": "Langues disponibles dans l'application", + "type": "array" + }, "sub_title": { "description": "Sous-titre de l'application", "type": "object", @@ -59,6 +63,7 @@ } }, "required": [ + "locales", "sub_title", "footer_phrase", "logo",