feat(i18n): localize movement UI

This commit is contained in:
2026-06-14 01:20:23 +02:00
parent 7d5ab64653
commit f62cd6fb37
8 changed files with 270 additions and 17 deletions
@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest"
import { formatMovementType } from "@/app/(dashboard)/movements/movement.copy"
describe("movement copy helpers", () => {
const typeCopy = {
IN: "Entrada",
OUT: "Salida",
ASSIGNMENT: "Asignación",
RETURN: "Devolución",
ADJUSTMENT: "Ajuste",
DELETED: "Eliminación",
}
const fallbackCopy = {
missingValue: "-",
unknownType: "Tipo de movimiento desconocido",
}
it("formats known movement types with localized display labels", () => {
expect(formatMovementType("IN", typeCopy, fallbackCopy)).toBe("Entrada")
expect(formatMovementType("RETURN", typeCopy, fallbackCopy)).toBe(
"Devolución",
)
})
it("falls back for unknown movement type values without rewriting the raw value", () => {
expect(formatMovementType("LEGACY", typeCopy, fallbackCopy)).toBe(
"Tipo de movimiento desconocido",
)
})
})
+70
View File
@@ -559,6 +559,76 @@ describe("i18n dictionaries", () => {
})
})
it("provides localized movement UI copy for English and Spanish", () => {
expect(getDictionary("en").inventory.movements).toEqual({
list: {
title: "Movements",
empty: "No movements found",
columns: {
type: "Type",
item: "Item",
serialNumber: "Serial Number",
quantity: "Quantity",
recipient: "Recipient",
date: "Date",
},
},
snippet: {
title: "Movements",
labels: {
type: "Type",
quantity: "Quantity",
},
},
types: {
IN: "In",
OUT: "Out",
ASSIGNMENT: "Assignment",
RETURN: "Return",
ADJUSTMENT: "Adjustment",
DELETED: "Deleted",
},
fallback: {
missingValue: "-",
unknownType: "Unknown movement type",
},
})
expect(getDictionary("es").inventory.movements).toEqual({
list: {
title: "Movimientos",
empty: "No se encontraron movimientos.",
columns: {
type: "Tipo",
item: "Artículo",
serialNumber: "Número de serie",
quantity: "Cantidad",
recipient: "Destinatario",
date: "Fecha",
},
},
snippet: {
title: "Movimientos",
labels: {
type: "Tipo",
quantity: "Cantidad",
},
},
types: {
IN: "Entrada",
OUT: "Salida",
ASSIGNMENT: "Asignación",
RETURN: "Devolución",
ADJUSTMENT: "Ajuste",
DELETED: "Eliminación",
},
fallback: {
missingValue: "-",
unknownType: "Tipo de movimiento desconocido",
},
})
})
it("keeps dashboard home dictionary keys aligned across locales", () => {
expect(getDictionary("en").dashboardHome).toEqual({
heading: "Dashboard",