Localize objects and enhance i18n integration

- Replaced hardcoded labels in `Bookings.vue`, `Orders.vue`, and `Vehicles.vue` with dynamic translations using `i18n`.
- Added comprehensive translation keys for `objects` in `en.json` and `da.json`.
- Improved multilingual support for objects metadata, columns, and labels.
This commit is contained in:
Jeppe Bundgaard
2026-02-17 12:56:40 +01:00
parent 665dc61d98
commit fd8b86987f
5 changed files with 225 additions and 76 deletions
@@ -4,31 +4,37 @@ import { authenticatedRequest } from "@/components/session/authenticatedRequest.
import { ObjectsGlobal } from "@/components/session/token/SessionUser/Objects/ObjectsGlobal.vue";
import { SessionUser } from "@/components/session/token/SessionUser.vue";
import {ref} from "vue";
import i18n from '@/i18n';
const t = (key) => i18n.global.t(key);
/**
* The Bookings object
*/
export const Bookings = {
meta: {
title: "Bookinger",
icon: "fas fa-list",
description: "Oversigt over bookinger",
endpoint: "/bookings",
labels: {
single: "booking",
multiple: "bookinger",
fields: {
names: {
customer_number: {
label: "E-conomic kundenummer",
get meta() {
return {
title: t('objects.bookings.title'),
icon: "fas fa-list",
description: t('objects.bookings.description'),
endpoint: "/bookings",
labels: {
single: t('objects.bookings.single'),
multiple: t('objects.bookings.multiple'),
fields: {
names: {
customer_number: {
label: t('objects.bookings.columns.economic_customer_number'),
},
},
},
},
},
};
},
columns: {
get columns() {
return {
id: {
label: "ID",
label: t('objects.columns.id'),
type: "number",
sortable: true,
creation: {
@@ -36,7 +42,7 @@ export const Bookings = {
}
},
customer_number: {
label: "Kundenummer",
label: t('objects.columns.customer_number'),
type: "number",
sortable: true,
creation: {
@@ -44,7 +50,7 @@ export const Bookings = {
},
},
wash_type: {
label: "Vasketype",
label: t('objects.bookings.columns.wash_type'),
type: "string",
sortable: true,
creation: {
@@ -52,7 +58,7 @@ export const Bookings = {
},
},
contact_email: {
label: "Kontakt E-mail",
label: t('objects.bookings.columns.contact_email'),
type: "string",
sortable: true,
creation: {
@@ -60,7 +66,7 @@ export const Bookings = {
},
},
reference_number: {
label: "Reference",
label: t('objects.columns.reference'),
type: "string",
sortable: true,
creation: {
@@ -68,7 +74,7 @@ export const Bookings = {
},
},
regNrTraekker: {
label: "Reg. 1",
label: t('objects.bookings.columns.reg_1'),
type: "string",
sortable: true,
creation: {
@@ -76,7 +82,7 @@ export const Bookings = {
},
},
regNrTrailer: {
label: "Reg. 2",
label: t('objects.bookings.columns.reg_2'),
type: "string",
sortable: true,
creation: {
@@ -84,7 +90,7 @@ export const Bookings = {
},
},
washCertificateEmail: {
label: "Vaskecertifikat E-mail",
label: t('objects.bookings.columns.wash_certificate_email'),
type: "string",
sortable: true,
creation: {
@@ -92,7 +98,7 @@ export const Bookings = {
},
},
date: {
label: "Dato",
label: t('objects.columns.date'),
type: "string",
sortable: true,
creation: {
@@ -100,7 +106,7 @@ export const Bookings = {
},
},
department: {
label: "Afdeling",
label: t('objects.columns.department'),
type: "select",
sortable: true,
creation: {
@@ -111,7 +117,7 @@ export const Bookings = {
}
},
pickup_bool: {
label: "Hentning",
label: t('objects.bookings.columns.pickup'),
type: "boolean",
sortable: true,
creation: {
@@ -119,7 +125,7 @@ export const Bookings = {
},
},
notes: {
label: "Noter",
label: t('objects.columns.notes'),
type: "string",
sortable: true,
creation: {
@@ -127,7 +133,7 @@ export const Bookings = {
},
},
washCertificateStatus: {
label: "Vaskecertifikat status",
label: t('objects.bookings.columns.wash_certificate_status'),
type: "select",
sortable: true,
creation: {
@@ -142,7 +148,7 @@ export const Bookings = {
}
},
washCertificateUrl: {
label: "Vaskecertifikat URL",
label: t('objects.bookings.columns.wash_certificate_url'),
type: "string",
sortable: true,
creation: {
@@ -150,7 +156,7 @@ export const Bookings = {
},
},
status: {
label: "Status",
label: t('objects.columns.status'),
type: "select",
sortable: true,
creation: {
@@ -165,7 +171,7 @@ export const Bookings = {
}
},
data: {
label: "Data",
label: t('objects.columns.data'),
type: "string",
sortable: false,
creation: {
@@ -173,7 +179,7 @@ export const Bookings = {
},
},
wash_certificate_pdf: {
label: "Vaskecertifikat PDF",
label: t('objects.bookings.columns.wash_certificate_pdf'),
type: "string",
sortable: false,
creation: {
@@ -181,7 +187,7 @@ export const Bookings = {
},
},
created_at: {
label: "Oprettet",
label: t('objects.columns.created'),
type: "string",
sortable: true,
creation: {
@@ -189,13 +195,14 @@ export const Bookings = {
},
},
deleted_at: {
label: "Slettet",
label: t('objects.columns.deleted'),
type: "string",
sortable: true,
creation: {
required: false
},
},
};
},
set: {
reference_number: async (id, reference) => {
@@ -4,6 +4,9 @@ import {ObjectsGlobal} from "@/components/session/token/SessionUser/Objects/Obje
import {SessionUser} from "@/components/session/token/SessionUser.vue";
import CustomerSearchFieldPos from "@/components/forms/department/pos/input/customerSearchFieldPos.vue";
import {createApp} from "vue";
import i18n from '@/i18n';
const t = (key) => i18n.global.t(key);
// Define a function to show the SweetAlert2 modal with the Vue component
const showCustomerSearchModal = (onSuccessFunction = null) => {
@@ -215,20 +218,23 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
* The Orders object
*/
export const Orders = {
meta: {
title: "Vaskelog",
icon: "fas fa-list",
description: "Oversigt over vaskelog",
endpoint: "/orders",
labels: {
single: "Transaktion",
multiple: "Vaskelog",
entries: "Vaske",
}
get meta() {
return {
title: t('objects.orders.title'),
icon: "fas fa-list",
description: t('objects.orders.description'),
endpoint: "/orders",
labels: {
single: t('objects.orders.single'),
multiple: t('objects.orders.multiple'),
entries: t('objects.orders.entries'),
}
};
},
columns: {
get columns() {
return {
id: {
label: "ID",
label: t('objects.columns.id'),
type: "number",
sortable: true,
creation: {
@@ -236,7 +242,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
customer_id: {
label: "Kunde",
label: t('objects.columns.customer'),
type: "number",
sortable: true,
creation: {
@@ -244,7 +250,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
cashier_id: {
label: "Kasserer",
label: t('objects.orders.columns.cashier'),
type: "number",
sortable: true,
creation: {
@@ -252,7 +258,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
department_id: {
label: "Afdeling",
label: t('objects.columns.department'),
type: "number",
sortable: true,
creation: {
@@ -260,7 +266,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
reference: {
label: "Reference",
label: t('objects.columns.reference'),
type: "string",
sortable: true,
creation: {
@@ -268,7 +274,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
reg_1: {
label: "Nummerplade",
label: t('objects.orders.columns.license_plate'),
type: "string",
sortable: true,
creation: {
@@ -276,7 +282,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
reg_2: {
label: "Reg. 2",
label: t('objects.orders.columns.reg_2'),
type: "string",
sortable: true,
creation: {
@@ -284,7 +290,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
reg_3: {
label: "Reg. 3",
label: t('objects.orders.columns.reg_3'),
type: "string",
sortable: true,
creation: {
@@ -292,7 +298,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
notes: {
label: "Noter",
label: t('objects.columns.notes'),
type: "string",
sortable: true,
creation: {
@@ -300,7 +306,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
invoice_collection_id: {
label: "Faktura",
label: t('objects.columns.invoice'),
type: "number",
sortable: true,
creation: {
@@ -308,7 +314,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
booking_id: {
label: "Booking",
label: t('objects.columns.booking'),
type: "number",
sortable: true,
creation: {
@@ -316,7 +322,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
wash_id: {
label: "Vask ID",
label: t('objects.orders.columns.wash_id'),
type: "string",
sortable: true,
creation: {
@@ -324,7 +330,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
lane: {
label: "Bane",
label: t('objects.orders.columns.lane'),
type: "string",
sortable: true,
creation: {
@@ -332,7 +338,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
po: {
label: "PO",
label: t('objects.orders.columns.po'),
type: "string",
sortable: true,
creation: {
@@ -340,7 +346,7 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
created_at: {
label: "Dato",
label: t('objects.columns.date'),
type: "date",
sortable: true,
creation: {
@@ -348,13 +354,14 @@ const showChangeOrderInvoiceCollectionForm = async (id) => {
}
},
completed_at: {
label: "Fuldført",
label: t('objects.columns.completed'),
type: "date",
sortable: true,
creation: {
required: false
}
},
};
},
add: async (customer_id, cashier_id, department_id, reference, reg_1, reg_2, reg_3, notes, invoice_collection_id) => {
return ObjectsGlobal.add.object(
@@ -2,25 +2,31 @@
import {ObjectsGlobal} from "@/components/session/token/SessionUser/Objects/ObjectsGlobal.vue";
import {SessionUser} from "@/components/session/token/SessionUser.vue";
import Swal from "sweetalert2";
import i18n from '@/i18n';
const t = (key) => i18n.global.t(key);
/**
* The Vehicles object
*/
export const Vehicles = {
meta: {
title: "Køretøjer",
icon: "fas fa-list",
description: "Oversigt over køretøjer",
endpoint: "/vehicles",
labels: {
single: "køretøj",
multiple: "køretøjer"
}
get meta() {
return {
title: t('objects.vehicles.title'),
icon: "fas fa-list",
description: t('objects.vehicles.description'),
endpoint: "/vehicles",
labels: {
single: t('objects.vehicles.single'),
multiple: t('objects.vehicles.multiple')
}
};
},
columns: {
get columns() {
return {
id: {
label: "ID",
label: t('objects.columns.id'),
type: "number",
sortable: true,
creation: {
@@ -28,7 +34,7 @@ export const Vehicles = {
}
},
type: {
label: "Type",
label: t('objects.columns.type'),
type: "select",
sortable: true,
creation: {
@@ -78,7 +84,7 @@ export const Vehicles = {
},
},
reg: {
label: "Reg. 1.",
label: t('objects.vehicles.columns.reg'),
type: "string",
sortable: true,
creation: {
@@ -86,7 +92,7 @@ export const Vehicles = {
}
},
wash_subscription: {
label: "Vaskeabonnement",
label: t('objects.vehicles.columns.wash_subscription'),
type: "boolean",
sortable: true,
creation: {
@@ -94,7 +100,7 @@ export const Vehicles = {
}
},
customer_id: {
label: "Kunde ID",
label: t('objects.columns.customer_id'),
type: "number",
sortable: true,
creation: {
@@ -102,13 +108,14 @@ export const Vehicles = {
}
},
reference: {
label: "Reference",
label: t('objects.columns.reference'),
type: "string",
sortable: true,
creation: {
required: false,
}
},
};
},
add: async (type, reg, wash_subscription, customer_id, reference = null) => {
return ObjectsGlobal.add.object(
+64
View File
@@ -199,6 +199,70 @@
"my_bookings": "Mine bookinger",
"my_invoices": "Mine fakturaer"
},
"objects": {
"columns": {
"id": "ID",
"type": "Type",
"customer_id": "Kunde ID",
"customer": "Kunde",
"department": "Afdeling",
"reference": "Reference",
"notes": "Noter",
"invoice": "Faktura",
"booking": "Booking",
"date": "Dato",
"completed": "Fuldført",
"customer_number": "Kundenummer",
"status": "Status",
"data": "Data",
"created": "Oprettet",
"deleted": "Slettet"
},
"vehicles": {
"title": "Køretøjer",
"description": "Oversigt over køretøjer",
"single": "køretøj",
"multiple": "køretøjer",
"columns": {
"reg": "Reg. 1.",
"wash_subscription": "Vaskeabonnement"
}
},
"orders": {
"title": "Vaskelog",
"description": "Oversigt over vaskelog",
"single": "Transaktion",
"multiple": "Vaskelog",
"entries": "Vaske",
"columns": {
"cashier": "Kasserer",
"license_plate": "Nummerplade",
"reg_2": "Reg. 2",
"reg_3": "Reg. 3",
"wash_id": "Vask ID",
"lane": "Bane",
"po": "PO"
}
},
"bookings": {
"title": "Bookinger",
"description": "Oversigt over bookinger",
"single": "booking",
"multiple": "bookinger",
"columns": {
"economic_customer_number": "E-conomic kundenummer",
"wash_type": "Vasketype",
"contact_email": "Kontakt E-mail",
"reg_1": "Reg. 1",
"reg_2": "Reg. 2",
"wash_certificate_email": "Vaskecertifikat E-mail",
"pickup": "Hentning",
"wash_certificate_status": "Vaskecertifikat status",
"wash_certificate_url": "Vaskecertifikat URL",
"wash_certificate_pdf": "Vaskecertifikat PDF"
}
}
},
"global": {
"compare": "Sammenlign",
"generate_wash_certificate": "Generer vaskecertifikat",
+64
View File
@@ -199,6 +199,70 @@
"my_bookings": "My Bookings",
"my_invoices": "My Invoices"
},
"objects": {
"columns": {
"id": "ID",
"type": "Type",
"customer_id": "Customer ID",
"customer": "Customer",
"department": "Department",
"reference": "Reference",
"notes": "Notes",
"invoice": "Invoice",
"booking": "Booking",
"date": "Date",
"completed": "Completed",
"customer_number": "Customer Number",
"status": "Status",
"data": "Data",
"created": "Created",
"deleted": "Deleted"
},
"vehicles": {
"title": "Vehicles",
"description": "Overview of vehicles",
"single": "vehicle",
"multiple": "vehicles",
"columns": {
"reg": "Reg. 1.",
"wash_subscription": "Wash Subscription"
}
},
"orders": {
"title": "Wash Log",
"description": "Overview of wash log",
"single": "Transaction",
"multiple": "Wash Log",
"entries": "Washes",
"columns": {
"cashier": "Cashier",
"license_plate": "License Plate",
"reg_2": "Reg. 2",
"reg_3": "Reg. 3",
"wash_id": "Wash ID",
"lane": "Lane",
"po": "PO"
}
},
"bookings": {
"title": "Bookings",
"description": "Overview of bookings",
"single": "booking",
"multiple": "bookings",
"columns": {
"economic_customer_number": "E-conomic customer number",
"wash_type": "Wash Type",
"contact_email": "Contact Email",
"reg_1": "Reg. 1",
"reg_2": "Reg. 2",
"wash_certificate_email": "Wash Certificate Email",
"pickup": "Pickup",
"wash_certificate_status": "Wash Certificate Status",
"wash_certificate_url": "Wash Certificate URL",
"wash_certificate_pdf": "Wash Certificate PDF"
}
}
},
"global": {
"compare": "Compare",
"generate_wash_certificate": "Generate wash certificate",