diff --git a/src/uix/active-uix/active-uix.svelte.test.ts b/src/uix/active-uix/active-uix.svelte.test.ts index c283f46dc..25869451d 100644 --- a/src/uix/active-uix/active-uix.svelte.test.ts +++ b/src/uix/active-uix/active-uix.svelte.test.ts @@ -28,6 +28,7 @@ import { _resetMorfoRegistryForTesting, registerMorfo, v, type Morfo } from '$ui import { alertDialogMorfo } from '$uix/morfo/components/alert-dialog'; import { announceMorfo } from '$uix/morfo/components/announce'; import { breadcrumbMorfo } from '$uix/morfo/components/breadcrumb'; +import { calendarMorfo } from '$uix/morfo/components/calendar'; import { carouselMorfo } from '$uix/morfo/components/carousel'; import { clipboardMorfo } from '$uix/morfo/components/clipboard'; import { colorFieldMorfo } from '$uix/morfo/components/color-field'; @@ -46,6 +47,7 @@ import { navigationMenuMorfo } from '$uix/morfo/components/navigation-menu'; import { paginationMorfo } from '$uix/morfo/components/pagination'; import { pinInputMorfo } from '$uix/morfo/components/pin-input'; import { progressMorfo } from '$uix/morfo/components/progress'; +import { rangeCalendarMorfo } from '$uix/morfo/components/range-calendar'; import { ratingGroupMorfo } from '$uix/morfo/components/rating-group'; import { scrollAreaMorfo } from '$uix/morfo/components/scroll-area'; import { searchFieldMorfo } from '$uix/morfo/components/search-field'; @@ -148,8 +150,6 @@ describe('createActiveUix (standalone)', () => { const out = uix.langs.t('components.dialog.content.roledescription'); expect(typeof out).toBe('string'); expect(out.length).toBeGreaterThan(0); - expect(uix.langs.t('components.calendar.prev-month')).toBe('Mes anterior'); - expect(uix.langs.t('components.range-calendar.range-start')).toBe('inicio del rango'); } finally { uix.dispose(); } @@ -160,6 +160,7 @@ describe('createActiveUix (standalone)', () => { try { expect(uix.langs.t('common.buttons.close')).toBe('Cerrar'); expect(uix.langs.ts('#?common.buttons.close|Close')).toBe('Cerrar'); + expect(uix.langs.t('common.calendar.prev-month')).toBe('Mes anterior'); } finally { uix.dispose(); } @@ -293,6 +294,12 @@ describe('createActiveUix (standalone)', () => { expect(uix.langs.t('components.color-picker.area-description')).toBe( 'Usa las flechas para ajustar saturación (horizontal) y brillo (vertical)' ); + registerMorfo(calendarMorfo); + registerMorfo(rangeCalendarMorfo); + expect(uix.langs.t('components.calendar.label')).toBe('Calendario'); + expect(uix.langs.t('components.range-calendar.range-start')).toBe('inicio del rango'); + expect(uix.langs.t('common.calendar.prev-month')).toBe('Mes anterior'); + expect(uix.langs.t('common.calendar.year-select')).toBe('Seleccionar año'); } finally { uix.dispose(); _resetMorfoRegistryForTesting(); diff --git a/src/uix/langs.ts b/src/uix/langs.ts index ccd83377e..a911aa8b1 100644 --- a/src/uix/langs.ts +++ b/src/uix/langs.ts @@ -19,6 +19,12 @@ export const commonLangs = { reset: { es: 'Restablecer', en: 'Reset' }, save: { es: 'Guardar', en: 'Save' }, submit: { es: 'Enviar', en: 'Submit' } + }, + calendar: { + 'prev-month': { es: 'Mes anterior', en: 'Previous month' }, + 'next-month': { es: 'Mes siguiente', en: 'Next month' }, + 'month-select': { es: 'Seleccionar mes', en: 'Select month' }, + 'year-select': { es: 'Seleccionar año', en: 'Select year' } } } satisfies LangNode; @@ -49,34 +55,6 @@ export const componentLangs = { }, }, - calendar: { - label: { es: 'Calendario', en: 'Calendar' }, - 'prev-month': { es: 'Mes anterior', en: 'Previous month' }, - 'next-month': { es: 'Mes siguiente', en: 'Next month' }, - 'prev-year': { es: 'Año anterior', en: 'Previous year' }, - 'next-year': { es: 'Año siguiente', en: 'Next year' }, - 'month-select': { es: 'Seleccionar mes', en: 'Select month' }, - 'year-select': { es: 'Seleccionar año', en: 'Select year' }, - 'week-label': { es: 'Semana', en: 'Week' }, - 'week-number-abbr': { es: 'Sem.', en: 'Wk' }, - holiday: { es: 'festivo', en: 'holiday' }, - today: { es: 'hoy', en: 'today' }, - selected: { es: 'seleccionado', en: 'selected' }, - 'selected-date': { es: 'Fecha seleccionada: {{value}}', en: 'Selected date: {{value}}' }, - 'navigated-to': { es: 'Mostrando {{value}}', en: 'Showing {{value}}' }, - }, - - 'range-calendar': { - label: { es: 'Calendario de rango', en: 'Range calendar' }, - 'range-start': { es: 'inicio del rango', en: 'range start' }, - 'range-end': { es: 'fin del rango', en: 'range end' }, - 'in-range': { es: 'dentro del rango', en: 'in range' }, - 'selected-range': { - es: 'Rango seleccionado: {{start}} a {{end}}', - en: 'Selected range: {{start}} to {{end}}' - }, - }, - 'date-field': { input: { es: 'Campo de fecha', en: 'Date field' }, year: { es: 'Año', en: 'Year' }, diff --git a/src/uix/morfo/components/calendar.ts b/src/uix/morfo/components/calendar.ts index 91a33076b..5b0d6569f 100644 --- a/src/uix/morfo/components/calendar.ts +++ b/src/uix/morfo/components/calendar.ts @@ -6,6 +6,9 @@ export const calendarMorfo = { kebab: 'calendar', scope: ['soma'], apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/grid/', + translations: { + label: { es: 'Calendario', en: 'Calendar' } + }, parts: [ { name: 'Provider', @@ -71,7 +74,7 @@ export const calendarMorfo = { { attr: 'type', value: v.literal('button') }, { attr: 'aria-label', - value: v.translationRef('#?components.calendar.prev-month|Previous month'), + value: v.commonRef('calendar.prev-month', 'Previous month'), severity: 'recommended' }, { attr: 'aria-disabled', value: v.propRef('disabled'), severity: 'optional' } @@ -90,7 +93,7 @@ export const calendarMorfo = { { attr: 'type', value: v.literal('button') }, { attr: 'aria-label', - value: v.translationRef('#?components.calendar.next-month|Next month'), + value: v.commonRef('calendar.next-month', 'Next month'), severity: 'recommended' }, { attr: 'aria-disabled', value: v.propRef('disabled'), severity: 'optional' } @@ -107,7 +110,7 @@ export const calendarMorfo = { aria: [ { attr: 'aria-label', - value: v.translationRef('#?components.calendar.month|Month'), + value: v.commonRef('calendar.month-select', 'Select month'), severity: 'recommended' }, { attr: 'aria-disabled', value: v.propRef('disabled'), severity: 'optional' } @@ -124,7 +127,7 @@ export const calendarMorfo = { aria: [ { attr: 'aria-label', - value: v.translationRef('#?components.calendar.year|Year'), + value: v.commonRef('calendar.year-select', 'Select year'), severity: 'recommended' }, { attr: 'aria-disabled', value: v.propRef('disabled'), severity: 'optional' } diff --git a/src/uix/morfo/components/range-calendar.ts b/src/uix/morfo/components/range-calendar.ts index de7cac66c..eea6f5b40 100644 --- a/src/uix/morfo/components/range-calendar.ts +++ b/src/uix/morfo/components/range-calendar.ts @@ -6,6 +6,12 @@ export const rangeCalendarMorfo = { kebab: 'range-calendar', scope: ['soma'], apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/grid/', + translations: { + label: { es: 'Calendario de rango', en: 'Range calendar' }, + 'range-start': { es: 'inicio del rango', en: 'range start' }, + 'range-end': { es: 'fin del rango', en: 'range end' }, + 'in-range': { es: 'dentro del rango', en: 'in range' } + }, parts: [ { name: 'Provider', @@ -72,7 +78,7 @@ export const rangeCalendarMorfo = { { attr: 'type', value: v.literal('button') }, { attr: 'aria-label', - value: v.translationRef('#?components.range-calendar.prev-month|Previous month'), + value: v.commonRef('calendar.prev-month', 'Previous month'), severity: 'recommended' } ] @@ -90,7 +96,7 @@ export const rangeCalendarMorfo = { { attr: 'type', value: v.literal('button') }, { attr: 'aria-label', - value: v.translationRef('#?components.range-calendar.next-month|Next month'), + value: v.commonRef('calendar.next-month', 'Next month'), severity: 'recommended' } ] diff --git a/src/uix/soma/components/calendar/langs.ts b/src/uix/soma/components/calendar/langs.ts index 6393ec667..29855f865 100644 --- a/src/uix/soma/components/calendar/langs.ts +++ b/src/uix/soma/components/calendar/langs.ts @@ -1,15 +1,8 @@ /** Idlangref constants for Calendar. Values are fallback defaults. */ export const CALENDAR_LANGS = { LABEL: '#?components.calendar.label|Calendar', - PREV_MONTH: '#?components.calendar.prev-month|Previous month', - NEXT_MONTH: '#?components.calendar.next-month|Next month', - PREV_YEAR: '#?components.calendar.prev-year|Previous year', - NEXT_YEAR: '#?components.calendar.next-year|Next year', - MONTH_SELECT: '#?components.calendar.month-select|Select month', - YEAR_SELECT: '#?components.calendar.year-select|Select year', - WEEK_LABEL: '#?components.calendar.week-label|Week', - WEEK_NUMBER_ABBR: '#?components.calendar.week-number-abbr|Wk', - HOLIDAY: '#?components.calendar.holiday|holiday', - TODAY: '#?components.calendar.today|today', - SELECTED: '#?components.calendar.selected|selected' + PREV_MONTH: '#?common.calendar.prev-month|Previous month', + NEXT_MONTH: '#?common.calendar.next-month|Next month', + MONTH_SELECT: '#?common.calendar.month-select|Select month', + YEAR_SELECT: '#?common.calendar.year-select|Select year' } as const; diff --git a/src/uix/soma/components/range-calendar/langs.ts b/src/uix/soma/components/range-calendar/langs.ts index 1002fe9ee..5264f4b6a 100644 --- a/src/uix/soma/components/range-calendar/langs.ts +++ b/src/uix/soma/components/range-calendar/langs.ts @@ -1,15 +1,14 @@ /** - * Idlangref constants for RangeCalendar. Reuses most calendar keys through - * the shared `components.calendar.*` namespace; adds its own for range- - * specific announcements and labels. + * Idlangref constants for RangeCalendar. Reuses shared calendar action + * labels from `common.calendar.*`; owns range-specific labels. */ export const RANGE_CALENDAR_LANGS = { LABEL: '#?components.range-calendar.label|Range calendar', RANGE_START: '#?components.range-calendar.range-start|range start', RANGE_END: '#?components.range-calendar.range-end|range end', IN_RANGE: '#?components.range-calendar.in-range|in range', - PREV_MONTH: '#?components.calendar.prev-month|Previous month', - NEXT_MONTH: '#?components.calendar.next-month|Next month', - MONTH_SELECT: '#?components.calendar.month-select|Select month', - YEAR_SELECT: '#?components.calendar.year-select|Select year' + PREV_MONTH: '#?common.calendar.prev-month|Previous month', + NEXT_MONTH: '#?common.calendar.next-month|Next month', + MONTH_SELECT: '#?common.calendar.month-select|Select month', + YEAR_SELECT: '#?common.calendar.year-select|Select year' } as const;