From a6654b30ff5b554fc0a837126a7337194c87e1cf Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 15 May 2026 10:27:23 +0200 Subject: [PATCH] Move form drag translations to morfo --- src/uix/active-uix/active-uix.svelte.test.ts | 12 ++++++ src/uix/langs.ts | 39 -------------------- src/uix/morfo/components/drag-drop.ts | 27 ++++++++++++++ src/uix/morfo/components/form.ts | 10 +++++ src/uix/soma/components/drag-drop/README.md | 2 +- src/uix/soma/components/form/langs.ts | 4 +- 6 files changed, 52 insertions(+), 42 deletions(-) diff --git a/src/uix/active-uix/active-uix.svelte.test.ts b/src/uix/active-uix/active-uix.svelte.test.ts index dab047347..51db415bd 100644 --- a/src/uix/active-uix/active-uix.svelte.test.ts +++ b/src/uix/active-uix/active-uix.svelte.test.ts @@ -32,9 +32,11 @@ import { carouselMorfo } from '$uix/morfo/components/carousel'; import { clipboardMorfo } from '$uix/morfo/components/clipboard'; import { comboboxMorfo } from '$uix/morfo/components/combobox'; import { commandMorfo } from '$uix/morfo/components/command'; +import { dragDropMorfo } from '$uix/morfo/components/drag-drop'; import { drawerMorfo } from '$uix/morfo/components/drawer'; import { feedMorfo } from '$uix/morfo/components/feed'; import { fileUploadMorfo } from '$uix/morfo/components/file-upload'; +import { formMorfo } from '$uix/morfo/components/form'; import { gridListMorfo } from '$uix/morfo/components/grid-list'; import { listboxMorfo } from '$uix/morfo/components/listbox'; import { meterMorfo } from '$uix/morfo/components/meter'; @@ -271,6 +273,16 @@ describe('createActiveUix (standalone)', () => { expect(uix.langs.t('components.carousel.indicator', { index: 2 })).toBe( 'Ir a la diapositiva 2' ); + registerMorfo(dragDropMorfo); + registerMorfo(formMorfo); + expect(uix.langs.t('components.drag-drop.drag-over', { target: 'Lista' })).toBe( + 'Sobre zona de destino Lista' + ); + expect(uix.langs.t('components.drag-drop.droppable')).toBe('zona de destino'); + expect(uix.langs.t('components.form.error-summary-single')).toBe( + '1 error del formulario necesita tu atención' + ); + expect(uix.langs.t('common.buttons.submit')).toBe('Enviar'); } finally { uix.dispose(); _resetMorfoRegistryForTesting(); diff --git a/src/uix/langs.ts b/src/uix/langs.ts index 03704b712..48a703fe1 100644 --- a/src/uix/langs.ts +++ b/src/uix/langs.ts @@ -181,43 +181,4 @@ export const componentLangs = { 'format-select': { es: 'Formato de color', en: 'Color format' }, }, - 'drag-drop': { - 'drag-started': { - es: 'Arrastrando {{item}}', - en: 'Started dragging {{item}}', - }, - 'drag-over': { - es: 'Sobre zona de destino {{target}}', - en: 'Over drop zone {{target}}', - }, - dropped: { - es: 'Soltado {{item}} sobre {{target}}', - en: 'Dropped {{item}} on {{target}}', - }, - cancelled: { es: 'Arrastre cancelado', en: 'Drag cancelled' }, - 'no-targets': { - es: 'Sin zonas de destino disponibles', - en: 'No drop targets available', - }, - 'draggable-role': { es: 'arrastrable', en: 'draggable' }, - 'droppable-role': { es: 'zona de destino', en: 'drop zone' }, - 'droppable-active': { - es: 'zona de destino activa', - en: 'active drop zone', - }, - }, - - form: { - submit: { es: 'Enviar', en: 'Submit' }, - reset: { es: 'Restablecer', en: 'Reset' }, - 'error-summary-title': { - es: '{{count}} errores del formulario necesitan tu atención', - en: '{{count}} form errors need your attention' - }, - 'error-summary-single': { - es: '1 error del formulario necesita tu atención', - en: '1 form error needs your attention' - }, - }, - } satisfies LangNode; diff --git a/src/uix/morfo/components/drag-drop.ts b/src/uix/morfo/components/drag-drop.ts index 8575e4e4e..79f65f657 100644 --- a/src/uix/morfo/components/drag-drop.ts +++ b/src/uix/morfo/components/drag-drop.ts @@ -5,6 +5,33 @@ export const dragDropMorfo = { name: 'DragDrop', kebab: 'drag-drop', scope: ['soma'], + translations: { + 'drag-started': { + es: 'Arrastrando {{item}}', + en: 'Started dragging {{item}}' + }, + 'drag-over': { + es: 'Sobre zona de destino {{target}}', + en: 'Over drop zone {{target}}' + }, + dropped: { + es: 'Soltado {{item}} sobre {{target}}', + en: 'Dropped {{item}} on {{target}}' + }, + cancelled: { es: 'Arrastre cancelado', en: 'Drag cancelled' }, + 'no-targets': { + es: 'Sin zonas de destino disponibles', + en: 'No drop targets available' + }, + draggable: { es: 'arrastrable', en: 'Draggable' }, + droppable: { es: 'zona de destino', en: 'Drop zone' }, + 'draggable-role': { es: 'arrastrable', en: 'draggable' }, + 'droppable-role': { es: 'zona de destino', en: 'drop zone' }, + 'droppable-active': { + es: 'zona de destino activa', + en: 'active drop zone' + } + }, parts: [ { name: 'Provider', diff --git a/src/uix/morfo/components/form.ts b/src/uix/morfo/components/form.ts index 61f000075..205893820 100644 --- a/src/uix/morfo/components/form.ts +++ b/src/uix/morfo/components/form.ts @@ -5,6 +5,16 @@ export const formMorfo = { name: 'Form', kebab: 'form', scope: ['soma'], + translations: { + 'error-summary-title': { + es: '{{count}} errores del formulario necesitan tu atención', + en: '{{count}} form errors need your attention' + }, + 'error-summary-single': { + es: '1 error del formulario necesita tu atención', + en: '1 form error needs your attention' + } + }, parts: [ { name: 'Provider', diff --git a/src/uix/soma/components/drag-drop/README.md b/src/uix/soma/components/drag-drop/README.md index f730ec0a3..80cc0e0c9 100644 --- a/src/uix/soma/components/drag-drop/README.md +++ b/src/uix/soma/components/drag-drop/README.md @@ -84,7 +84,7 @@ Snippet props: `{ over, accepting }`. | Droppable | `aria-dropeffect` | `'move'` while accepting, `'none'` otherwise | | Droppable | `tabindex` | `0` during drag if accepting; `-1` otherwise | -Each drag step is announced via the `Announce` global API. Component-owned announcement strings should live in the drag-drop morfo `langs` catalog; legacy imperative constants may still appear in [langs.ts](./langs.ts) during migration. Disable with `announceEnabled={false}` on the Provider when wiring your own. +Each drag step is announced via the `Announce` global API. Component-owned announcement strings live in the drag-drop `morfo.translations` catalog. Disable with `announceEnabled={false}` on the Provider when wiring your own. ## Data Attributes diff --git a/src/uix/soma/components/form/langs.ts b/src/uix/soma/components/form/langs.ts index 84b300163..845935226 100644 --- a/src/uix/soma/components/form/langs.ts +++ b/src/uix/soma/components/form/langs.ts @@ -1,7 +1,7 @@ /** Idlangref constants for Form. */ export const FORM_LANGS = { - SUBMIT: '#?components.form.submit|Submit', - RESET: '#?components.form.reset|Reset', + SUBMIT: '#?common.buttons.submit|Submit', + RESET: '#?common.buttons.reset|Reset', ERROR_SUMMARY_TITLE: '#?components.form.error-summary-title|{{count}} form errors need your attention', ERROR_SUMMARY_SINGLE: '#?components.form.error-summary-single|1 form error needs your attention'