diff --git a/package-lock.json b/package-lock.json index c67c4371c..713db0424 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14568,6 +14568,7 @@ "resolved": "https://registry.npmjs.org/ilingo/-/ilingo-4.3.1.tgz", "integrity": "sha512-xLTyDJjrt3vPMJTVa8SX9CgdqaIcojjj13SEDQkJaYlJeKtxkxPQEK8KbNl7r/Y4GqX3kUStdPQUz0yilVztLg==", "dev": true, + "peer": true, "dependencies": { "smob": "^1.5.0" } @@ -25595,6 +25596,7 @@ "@authup/core-kit": "^1.0.0-beta.13", "@bootstrap-vue-next/nuxt": "^0.21.2", "@fortawesome/fontawesome-free": "^6.5.2", + "@ilingo/vuelidate": "^5.0.2", "@nuxtjs/google-fonts": "^3.2.0", "@pinia/nuxt": "^0.5.1", "@privateaim/client-vue": "^0.5.0", @@ -25617,7 +25619,6 @@ "bootstrap-vue-next": "^0.20.0", "events": "^3.3.0", "hapic": "^2.5.1", - "ilingo": "^4.3.1", "nuxt": "^3.11.2", "pinia": "^2.1.7", "rapiq": "^0.9.0", diff --git a/packages/client-ui/package.json b/packages/client-ui/package.json index ef1f492da..ed18249a0 100644 --- a/packages/client-ui/package.json +++ b/packages/client-ui/package.json @@ -22,6 +22,7 @@ "@authup/core-http-kit": "^1.0.0-beta.13", "@authup/core-kit": "^1.0.0-beta.13", "@bootstrap-vue-next/nuxt": "^0.21.2", + "@ilingo/vuelidate": "^5.0.2", "@fortawesome/fontawesome-free": "^6.5.2", "@nuxtjs/google-fonts": "^3.2.0", "@privateaim/client-vue": "^0.5.0", @@ -45,7 +46,6 @@ "bootstrap-vue-next": "^0.20.0", "events": "^3.3.0", "hapic": "^2.5.1", - "ilingo": "^4.3.1", "nuxt": "^3.11.2", "pinia": "^2.1.7", "rapiq": "^0.9.0", diff --git a/packages/client-ui/plugins/ilingo.ts b/packages/client-ui/plugins/ilingo.ts index 3acdd41d2..ac75275b1 100644 --- a/packages/client-ui/plugins/ilingo.ts +++ b/packages/client-ui/plugins/ilingo.ts @@ -5,25 +5,7 @@ * view the LICENSE file that was distributed with this source code. */ -import { Ilingo } from 'ilingo'; - -declare module '#app' { - interface NuxtApp { - $ilingo: Ilingo; - } -} - -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $ilingo: Ilingo; - } -} - -export default defineNuxtPlugin((ctx) => { - const ilingo = new Ilingo(); - +export default defineNuxtPlugin(() => { // registryRobotSecret: 'Die Eingabe muss größer als 8 Zeichen, min. 1 Großbuchstaben, 1 Kleinbuchstaben und 1 Zahl enthalten.', // registryRobotSecret: 'The input value must be larger than 8 letters, contain at least 1 uppercase letter, 1 lowercase letter and 1 number.', - - ctx.provide('ilingo', ilingo); }); diff --git a/packages/client-vue/src/components/node/FNodeRobot.ts b/packages/client-vue/src/components/node/FNodeRobot.ts index 56fd1e7df..1b5f9442c 100644 --- a/packages/client-vue/src/components/node/FNodeRobot.ts +++ b/packages/client-vue/src/components/node/FNodeRobot.ts @@ -43,6 +43,8 @@ export default defineComponent({ const translationsValidation = useTranslationsForNestedValidations($v.value); + const translationsSubmit = createFormSubmitTranslations(); + return () => h(ARobot, { onResolved(entity) { if (entity) { @@ -96,8 +98,6 @@ export default defineComponent({ }), }); - const translationsSubmit = createFormSubmitTranslations(); - const submitNode = buildFormSubmitWithTranslations({ submit: () => slotProps.update(form), busy: slotProps.busy, diff --git a/packages/client-vue/src/components/registry-project/FRegistryProject.ts b/packages/client-vue/src/components/registry-project/FRegistryProject.ts index 7af646759..67bb4f0b6 100644 --- a/packages/client-vue/src/components/registry-project/FRegistryProject.ts +++ b/packages/client-vue/src/components/registry-project/FRegistryProject.ts @@ -50,6 +50,8 @@ export default defineComponent({ }, }, form); + const translationsValidation = useTranslationsForNestedValidations(vuelidate.value); + const manager = createEntityManager({ type: `${DomainType.REGISTRY_PROJECT}`, setup, @@ -103,8 +105,6 @@ export default defineComponent({ ); } - const translationsValidation = useTranslationsForNestedValidations(vuelidate.value); - return () => { const fallback = () : VNodeChild => h('div', [ h('div', { diff --git a/packages/client-vue/src/core/index.ts b/packages/client-vue/src/core/index.ts index 944baec62..c735eaa8c 100644 --- a/packages/client-vue/src/core/index.ts +++ b/packages/client-vue/src/core/index.ts @@ -15,5 +15,6 @@ export * from './busy'; export * from './object'; export * from './slot'; export * from './socket'; +export * from './translator'; export * from './http-client'; export * from './vuelidate'; diff --git a/packages/client-vue/src/core/translator/index.ts b/packages/client-vue/src/core/translator/index.ts new file mode 100644 index 000000000..7f114328a --- /dev/null +++ b/packages/client-vue/src/core/translator/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024. + * Author Peter Placzek (tada5hi) + * For the full copyright and license information, + * view the LICENSE file that was distributed with this source code. + */ + +export * from './install'; +export * from './types'; diff --git a/packages/client-vue/src/core/translator/install.ts b/packages/client-vue/src/core/translator/install.ts new file mode 100644 index 000000000..be15df290 --- /dev/null +++ b/packages/client-vue/src/core/translator/install.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024. + * Author Peter Placzek (tada5hi) + * For the full copyright and license information, + * view the LICENSE file that was distributed with this source code. + */ + +import { MemoryStore } from '@ilingo/vuelidate/core'; +import { install } from '@ilingo/vuelidate'; +import type { App } from 'vue'; +import type { TranslatorInstallOptions } from './types'; + +export function installTranslator(app: App, options: TranslatorInstallOptions = {}) { + const store = new MemoryStore({ + data: {}, + }); + + install(app, { + store, + locale: options.locale, + }); +} diff --git a/packages/client-vue/src/core/translator/types.ts b/packages/client-vue/src/core/translator/types.ts new file mode 100644 index 000000000..a390f692c --- /dev/null +++ b/packages/client-vue/src/core/translator/types.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024. + * Author Peter Placzek (tada5hi) + * For the full copyright and license information, + * view the LICENSE file that was distributed with this source code. + */ + +export type TranslatorInstallOptions = { + locale?: string +}; diff --git a/packages/client-vue/src/module.ts b/packages/client-vue/src/module.ts index 0048c3eb3..96f90a925 100644 --- a/packages/client-vue/src/module.ts +++ b/packages/client-vue/src/module.ts @@ -12,6 +12,7 @@ import { installCoreHTTPClient, installSocketManager, installStorageHTTPClient, + installTranslator, } from './core'; import type { Options } from './type'; @@ -28,6 +29,10 @@ export function install(app: App, options: Options): void { baseURL: options.realtimeURL, }); + installTranslator(app, { + locale: options.translatorLocale, + }); + const storeManager = installStoreManager(app); if (options.storeManager) { applyStoreManagerOptions(storeManager, options.storeManager); diff --git a/packages/client-vue/src/type.ts b/packages/client-vue/src/type.ts index 56e4532d4..faff1c282 100644 --- a/packages/client-vue/src/type.ts +++ b/packages/client-vue/src/type.ts @@ -13,5 +13,7 @@ export type Options = { realtimeURL: string, components?: boolean | string[], - storeManager?: StoreManagerOptions + storeManager?: StoreManagerOptions, + + translatorLocale?: string, };