feat(i18n): localize inventory categories UI

This commit is contained in:
2026-06-12 23:01:33 +02:00
parent 589b042e7c
commit e9a07eb28e
14 changed files with 315 additions and 17 deletions
@@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest"
import { getPageHeaderAddLabel } from "@/components/common/pageheader.utils"
describe("PageHeader", () => {
it("uses the explicit add label when provided", () => {
expect(
getPageHeaderAddLabel({
addLabel: "Agregar categoría",
title: "Categorías",
}),
).toBe("Agregar categoría")
})
it("keeps the legacy fallback when no explicit add label is provided", () => {
expect(getPageHeaderAddLabel({ title: "Items" })).toBe("Add Items")
})
})
+103
View File
@@ -163,6 +163,109 @@ describe("i18n dictionaries", () => {
})
})
it("provides localized inventory category copy for English and Spanish", () => {
expect(getDictionary("en").inventory.categories).toEqual({
list: {
title: "Categories",
addLabel: "Add Category",
empty: "No categories found.",
columns: {
name: "Name",
items: "Items",
actions: "Actions",
},
actions: {
edit: "Edit category",
delete: "Delete category",
},
},
new: {
title: "New Category",
},
edit: {
title: "Edit Category",
},
form: {
nameLabel: "Name",
namePlaceholder: "Category name",
createSubmit: "Create Category",
updateSubmit: "Update Category",
},
delete: {
label: "Delete category",
pending: "Deleting...",
unknownError: "Unknown error",
},
actions: {
createSuccess: "Category created successfully",
createFailure: "Failed to create category",
updateSuccess: "Category updated successfully",
updateFailure: "Failed to update category",
deleteSuccess: "Category deleted successfully",
deleteFailure: "Failed to delete category",
duplicateName: "Category already exists",
unchangedName: "Category name unchanged",
notFound: "Category not found",
hasItems: "Cannot delete category with items",
},
schema: {
nameRequired: "Name is required and must be at least 3 characters long",
idRequired: "ID is required",
},
})
expect(getDictionary("es").inventory.categories).toEqual({
list: {
title: "Categorías",
addLabel: "Agregar categoría",
empty: "No se encontraron categorías.",
columns: {
name: "Nombre",
items: "Artículos",
actions: "Acciones",
},
actions: {
edit: "Editar categoría",
delete: "Eliminar categoría",
},
},
new: {
title: "Nueva categoría",
},
edit: {
title: "Editar categoría",
},
form: {
nameLabel: "Nombre",
namePlaceholder: "Nombre de la categoría",
createSubmit: "Crear categoría",
updateSubmit: "Actualizar categoría",
},
delete: {
label: "Eliminar categoría",
pending: "Eliminando...",
unknownError: "Error desconocido",
},
actions: {
createSuccess: "Categoría creada correctamente",
createFailure: "Error al crear la categoría",
updateSuccess: "Categoría actualizada correctamente",
updateFailure: "Error al actualizar la categoría",
deleteSuccess: "Categoría eliminada correctamente",
deleteFailure: "Error al eliminar la categoría",
duplicateName: "La categoría ya existe",
unchangedName: "El nombre de la categoría no cambió",
notFound: "Categoría no encontrada",
hasItems: "No se puede eliminar una categoría con artículos",
},
schema: {
nameRequired:
"El nombre es obligatorio y debe tener al menos 3 caracteres",
idRequired: "El ID es obligatorio",
},
})
})
it("keeps dashboard home dictionary keys aligned across locales", () => {
expect(getDictionary("en").dashboardHome).toEqual({
heading: "Dashboard",