easy-invoice-pdf/src/app/schema/translations.ts
Vlad Sazonau 5a4e9debc1
feat: add /?template=stripe|default to url, implement URL compression logic (#130)
* feat: add debug local storage UI and update README; include new template parameter handling in invoice form

* feat: add URL compression logic when generating link to invoice to reduce url length + add unit tests + improved existing e2e tests

* ci: remove type check step from unit tests workflow to streamline CI process

* test: update e2e tests for Stripe invoice sharing logic and template; increase timeout for visibility checks

* test: refactor e2e tests for invoice generation and sharing; update element selectors and enhance URL disallow rules in robots.txt

* chore: enhance README with detailed features and update about page references; add GitHub star CTA component

* chore: update configuration files for Prettier, run prettify across the project

* chore: run dedupe

* test: add e2e tests for Open Graph meta tags in invoice templates; verify correct rendering for default and Stripe templates

* chore: remove @stagewise/toolbar-next package and related development toolbar component from the project
2025-08-20 01:15:48 +02:00

844 lines
23 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { z } from "zod";
import { SUPPORTED_LANGUAGES, type SupportedLanguages } from "./index";
// Schema for seller translations
const sellerTranslationSchema = z
.object({
name: z.string(),
vatNo: z.string(),
email: z.string(),
accountNumber: z.string(),
swiftBic: z.string(),
})
.strict();
// Schema for buyer translations
const buyerTranslationSchema = z
.object({
name: z.string(),
vatNo: z.string(),
email: z.string(),
})
.strict();
// Schema for invoice items table translations
const invoiceItemsTableTranslationSchema = z
.object({
no: z.string(),
nameOfGoodsService: z.string(),
typeOfGTU: z.string(),
amount: z.string(),
unit: z.string(),
netPrice: z.string(),
vat: z.string(),
netAmount: z.string(),
vatAmount: z.string(),
preTaxAmount: z.string(),
sum: z.string(),
})
.strict();
// Schema for payment info translations
const paymentInfoTranslationSchema = z
.object({
paymentMethod: z.string(),
paymentDate: z.string(),
})
.strict();
// Schema for VAT summary table translations
const vatSummaryTableTranslationSchema = z
.object({
vatRate: z.string(),
net: z.string(),
vat: z.string(),
preTax: z.string(),
total: z.string(),
})
.strict();
// Schema for payment totals translations
const paymentTotalsTranslationSchema = z
.object({
toPay: z.string(),
paid: z.string(),
leftToPay: z.string(),
amountInWords: z.string(),
})
.strict();
// Schema for Stripe-specific translations
const stripeTranslationSchema = z
.object({
invoice: z.string(),
invoiceNumber: z.string(),
dateOfIssue: z.string(),
dateDue: z.string(),
servicePeriod: z.string(),
billTo: z.string(),
due: z.string(),
payOnline: z.string(),
description: z.string(),
qty: z.string(),
unitPrice: z.string(),
amount: z.string(),
tax: z.string(),
subtotal: z.string(),
total: z.string(),
amountDue: z.string(),
page: z.string(),
of: z.string(),
})
.strict();
// Main translation schema
export const translationSchema = z
.object({
invoiceNumber: z.string(),
dateOfIssue: z.string(),
dateOfService: z.string(),
invoiceType: z.string(),
seller: sellerTranslationSchema,
buyer: buyerTranslationSchema,
invoiceItemsTable: invoiceItemsTableTranslationSchema,
paymentInfo: paymentInfoTranslationSchema,
vatSummaryTable: vatSummaryTableTranslationSchema,
paymentTotals: paymentTotalsTranslationSchema,
personAuthorizedToReceive: z.string(),
personAuthorizedToIssue: z.string(),
createdWith: z.string(),
stripe: stripeTranslationSchema,
})
.strict();
// Create a map of language to schema
// {
// en: translationSchema,
// pl: translationSchema,
// de: translationSchema,
// ...etc
// }
const languageToSchemaMap = Object.fromEntries(
SUPPORTED_LANGUAGES.map((lang) => [lang, translationSchema]),
);
// Schema for all translations
export const translationsSchema = z.object(languageToSchemaMap);
// Type for a single language translation
export type TranslationSchema = z.infer<typeof translationSchema>;
// Type for all translations
export type TranslationsSchema = z.infer<typeof translationsSchema>;
export const TRANSLATIONS = {
en: {
invoiceNumber: "Invoice No. of",
dateOfIssue: "Date of issue",
dateOfService: "Date of sales/of executing the service",
invoiceType: "Invoice Type",
seller: {
name: "Seller",
vatNo: "VAT no",
email: "e-mail",
accountNumber: "Account Number",
swiftBic: "SWIFT/BIC number",
},
buyer: {
name: "Buyer",
vatNo: "VAT no",
email: "e-mail",
},
invoiceItemsTable: {
no: "No",
nameOfGoodsService: "Name of goods/service",
typeOfGTU: "Type of GTU",
amount: "Amount",
unit: "Unit",
netPrice: "Net price",
vat: "VAT",
netAmount: "Net\n Amount",
vatAmount: "VAT Amount",
preTaxAmount: "Pre-tax amount",
sum: "SUM",
},
paymentInfo: {
paymentMethod: "Payment method",
paymentDate: "Payment date",
},
vatSummaryTable: {
vatRate: "VAT rate",
net: "Net",
vat: "VAT",
preTax: "Pre-tax",
total: "Total",
},
paymentTotals: {
toPay: "To pay",
paid: "Paid",
leftToPay: "Left to pay",
amountInWords: "Amount in words",
},
personAuthorizedToReceive: "Person authorized to receive",
personAuthorizedToIssue: "Person authorized to issue",
createdWith: "Created with",
stripe: {
invoice: "Invoice",
invoiceNumber: "Invoice number",
dateOfIssue: "Date of issue",
dateDue: "Date due",
servicePeriod: "Service period",
billTo: "Bill to",
due: "due",
payOnline: "Pay Online",
description: "Description",
qty: "Qty",
unitPrice: "Unit Price",
amount: "Amount",
tax: "Tax",
subtotal: "Subtotal",
total: "Total",
amountDue: "Amount Due",
page: "Page",
of: "of",
},
},
pl: {
invoiceNumber: "Faktura nr",
dateOfIssue: "Data wystawienia",
dateOfService: "Data sprzedaży / wykonania usługi",
invoiceType: "Typ faktury",
seller: {
name: "Sprzedawca",
vatNo: "NIP",
email: "E-mail",
accountNumber: "Nr konta",
swiftBic: "Nr SWIFT/BIC",
},
buyer: {
name: "Nabywca",
vatNo: "NIP",
email: "E-mail",
},
invoiceItemsTable: {
no: "lp.",
nameOfGoodsService: "Nazwa towaru/usługi",
typeOfGTU: "Typ\n GTU",
amount: "Ilość",
unit: "Jm",
netPrice: "Cena\n netto",
vat: "VAT",
netAmount: "Kwota\n netto",
vatAmount: "Kwota VAT",
preTaxAmount: "Kwota\n brutto",
sum: "SUMA",
},
paymentInfo: {
paymentMethod: "Sposób wpłaty",
paymentDate: "Termin zapłaty",
},
vatSummaryTable: {
vatRate: "Stawka VAT",
net: "Netto",
vat: "VAT",
preTax: "Brutto",
total: "Razem",
},
paymentTotals: {
toPay: "Razem do zapłaty",
paid: "Wpłacono",
leftToPay: "Pozostało do zapłaty",
amountInWords: "Kwota słownie",
},
personAuthorizedToReceive: "Osoba upoważniona do odbioru",
personAuthorizedToIssue: "Osoba upoważniona do wystawienia",
createdWith: "Utworzono za pomocą",
stripe: {
invoice: "Faktura",
invoiceNumber: "Numer faktury",
dateOfIssue: "Data wystawienia",
dateDue: "Termin płatności",
servicePeriod: "Okres realizacji",
billTo: "Nabywca",
due: "do zapłaty do",
payOnline: "Płatność online",
description: "Opis",
qty: "Ilość",
unitPrice: "Cena jednostkowa",
amount: "Kwota",
tax: "Podatek",
subtotal: "Podsumowanie",
total: "Razem",
amountDue: "Kwota do zapłaty",
page: "Strona",
of: "z",
},
},
de: {
invoiceNumber: "Rechnungsnummer",
dateOfIssue: "Ausstellungsdatum",
dateOfService: "Verkaufsdatum/Leistungsdatum",
invoiceType: "Rechnungstyp",
seller: {
name: "Verkäufer",
vatNo: "USt-IdNr",
email: "E-Mail",
accountNumber: "Kontonummer",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Käufer",
vatNo: "USt-IdNr",
email: "E-Mail",
},
invoiceItemsTable: {
no: "Nr",
nameOfGoodsService: "Bezeichnung der Ware/Dienstleistung",
typeOfGTU: "GTU-Typ",
amount: "Menge",
unit: "Einheit",
netPrice: "Nettopreis",
vat: "MwSt",
netAmount: "Netto\n Betrag",
vatAmount: "MwSt Betrag",
preTaxAmount: "Bruttobetrag",
sum: "SUMME",
},
paymentInfo: {
paymentMethod: "Zahlungsart",
paymentDate: "Zahlungsdatum",
},
vatSummaryTable: {
vatRate: "MwSt-Satz",
net: "Netto",
vat: "MwSt",
preTax: "Brutto",
total: "Gesamt",
},
paymentTotals: {
toPay: "Zu zahlen",
paid: "Bezahlt",
leftToPay: "Restbetrag",
amountInWords: "Betrag in Worten",
},
personAuthorizedToReceive: "Empfangsberechtigte Person",
personAuthorizedToIssue: "Ausstellungsberechtigte Person",
createdWith: "Erstellt mit",
stripe: {
invoice: "Rechnung",
invoiceNumber: "Rechnungsnummer",
dateOfIssue: "Ausstellungsdatum",
dateDue: "Fälligkeitsdatum",
servicePeriod: "Leistungszeitraum",
billTo: "Rechnung an",
due: "fällig",
payOnline: "Online-Zahlung",
description: "Beschreibung",
qty: "Menge",
unitPrice: "Einzelpreis",
amount: "Betrag",
tax: "Steuer",
subtotal: "Zwischensumme",
total: "Gesamt",
amountDue: "Fälligkeitsbetrag",
page: "Seite",
of: "von",
},
},
es: {
invoiceNumber: "Factura N°",
dateOfIssue: "Fecha de emisión",
dateOfService: "Fecha de venta/prestación del servicio",
invoiceType: "Tipo de factura",
seller: {
name: "Vendedor",
vatNo: "NIF/CIF",
email: "Correo electrónico",
accountNumber: "Número de cuenta",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Comprador",
vatNo: "NIF/CIF",
email: "Correo electrónico",
},
invoiceItemsTable: {
no: "N°",
nameOfGoodsService: "Descripción del producto/servicio",
typeOfGTU: "Tipo\n GTU",
amount: "Cantidad",
unit: "Unidad",
netPrice: "Precio neto",
vat: "IVA",
netAmount: "Importe\n neto",
vatAmount: "Importe IVA",
preTaxAmount: "Importe bruto",
sum: "TOTAL",
},
paymentInfo: {
paymentMethod: "Forma de pago",
paymentDate: "Fecha de pago",
},
vatSummaryTable: {
vatRate: "Tipo IVA",
net: "Neto",
vat: "IVA",
preTax: "Bruto",
total: "Total",
},
paymentTotals: {
toPay: "Total a pagar",
paid: "Pagado",
leftToPay: "Pendiente de pago",
amountInWords: "Importe en letras",
},
personAuthorizedToReceive: "Persona autorizada para recibir",
personAuthorizedToIssue: "Persona autorizada para emitir",
createdWith: "Creado con",
stripe: {
invoice: "Factura",
invoiceNumber: "Número de factura",
dateOfIssue: "Fecha de emisión",
dateDue: "Fecha de vencimiento",
servicePeriod: "Periodo de servicio",
billTo: "Facturar a",
due: "vencimiento",
payOnline: "Pago en línea",
description: "Descripción",
qty: "Cantidad",
unitPrice: "Precio unitario",
amount: "Monto",
tax: "Impuesto",
subtotal: "Subtotal",
total: "Total",
amountDue: "Monto vencido",
page: "Página",
of: "de",
},
},
pt: {
invoiceNumber: "Fatura N°",
dateOfIssue: "Data de emissão",
dateOfService: "Data de venda/prestação do serviço",
invoiceType: "Tipo de fatura",
seller: {
name: "Vendedor",
vatNo: "NIF",
email: "E-mail",
accountNumber: "Número da conta",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Comprador",
vatNo: "NIF",
email: "E-mail",
},
invoiceItemsTable: {
no: "N°",
nameOfGoodsService: "Descrição do produto/serviço",
typeOfGTU: "Tipo\n GTU",
amount: "Quantidade",
unit: "Unidade",
netPrice: "Preço\n líquido",
vat: "IVA",
netAmount: "Valor\n líquido",
vatAmount: "Valor IVA",
preTaxAmount: "Valor bruto",
sum: "TOTAL",
},
paymentInfo: {
paymentMethod: "Forma de pagamento",
paymentDate: "Data de pagamento",
},
vatSummaryTable: {
vatRate: "Taxa IVA",
net: "Líquido",
vat: "IVA",
preTax: "Bruto",
total: "Total",
},
paymentTotals: {
toPay: "Total a pagar",
paid: "Pago",
leftToPay: "Valor em falta",
amountInWords: "Valor por extenso",
},
personAuthorizedToReceive: "Pessoa autorizada a receber",
personAuthorizedToIssue: "Pessoa autorizada a emitir",
createdWith: "Criado com",
stripe: {
invoice: "Fatura",
invoiceNumber: "Número da fatura",
dateOfIssue: "Data de emissão",
dateDue: "Data de vencimento",
servicePeriod: "Período de serviço",
billTo: "Cobrar de",
due: "vencimento",
payOnline: "Pagamento online",
description: "Descrição",
qty: "Quantidade",
unitPrice: "Preço unitário",
amount: "Valor",
tax: "Imposto",
subtotal: "Subtotal",
total: "Total",
amountDue: "Valor vencido",
page: "Página",
of: "de",
},
},
ru: {
invoiceNumber: "Инвойс №",
dateOfIssue: "Дата выставления",
dateOfService: "Дата продажи/оказания услуги",
invoiceType: "Тип счёта",
seller: {
name: "Продавец",
vatNo: "ИНН",
email: "Эл. почта",
accountNumber: "Номер счёта",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Покупатель",
vatNo: "ИНН",
email: "Эл. почта",
},
invoiceItemsTable: {
no: "№",
nameOfGoodsService: "Наименование товара/услуги",
typeOfGTU: "Тип\n GTU",
amount: "Количество",
unit: "Ед.\n изм.",
netPrice: "Цена без НДС",
vat: "НДС",
netAmount: "Сумма\n без НДС",
vatAmount: "Сумма НДС",
preTaxAmount: "Сумма с НДС",
sum: "ИТОГО",
},
paymentInfo: {
paymentMethod: "Способ оплаты",
paymentDate: "Дата оплаты",
},
vatSummaryTable: {
vatRate: "Ставка НДС",
net: "Без НДС",
vat: "НДС",
preTax: "С НДС",
total: "Всего",
},
paymentTotals: {
toPay: "Итого к оплате",
paid: "Оплачено",
leftToPay: "Осталось оплатить",
amountInWords: "Сумма прописью",
},
personAuthorizedToReceive: "Уполномоченное лицо на получение",
personAuthorizedToIssue: "Уполномоченное лицо на выставление",
createdWith: "Создано с помощью",
stripe: {
invoice: "Счет",
invoiceNumber: "Номер счета",
dateOfIssue: "Дата выставления",
dateDue: "Дата оплаты",
servicePeriod: "Период оказания услуг",
billTo: "Плательщик",
due: "оплатить до",
payOnline: "Оплатить онлайн",
description: "Описание",
qty: "Количество",
unitPrice: "Цена за единицу",
amount: "Сумма",
tax: "Налог",
subtotal: "Промежуточный итог",
total: "Итого",
amountDue: "Сумма к оплате",
page: "Страница",
of: "из",
},
},
uk: {
invoiceNumber: "Рахунок-фактура №",
dateOfIssue: "Дата виставлення",
dateOfService: "Дата продажу/надання послуги",
invoiceType: "Тип рахунку",
seller: {
name: "Продавець",
vatNo: "ІПН",
email: "Ел. пошта",
accountNumber: "Номер рахунку",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Покупець",
vatNo: "ІПН",
email: "Ел. пошта",
},
invoiceItemsTable: {
no: "№",
nameOfGoodsService: "Найменування товару/послуги",
typeOfGTU: "Тип\n GTU",
amount: "Кількість",
unit: "Од.\n вим.",
netPrice: "Ціна без ПДВ",
vat: "ПДВ",
netAmount: "Сума\n без ПДВ",
vatAmount: "Сума ПДВ",
preTaxAmount: "Сума з ПДВ",
sum: "РАЗОМ",
},
paymentInfo: {
paymentMethod: "Спосіб оплати",
paymentDate: "Дата оплати",
},
vatSummaryTable: {
vatRate: "Ставка ПДВ",
net: "Без ПДВ",
vat: "ПДВ",
preTax: "З ПДВ",
total: "Всього",
},
paymentTotals: {
toPay: "Разом до сплати",
paid: "Сплачено",
leftToPay: "Залишилось сплатити",
amountInWords: "Сума прописом",
},
personAuthorizedToReceive: "Уповноважена особа на отримання",
personAuthorizedToIssue: "Уповноважена особа на виставлення",
createdWith: "Створено за допомогою",
stripe: {
invoice: "Рахунок",
invoiceNumber: "Номер рахунку",
dateOfIssue: "Дата виставлення",
dateDue: "Дата оплати",
servicePeriod: "Період надання послуги",
billTo: "Платник",
due: "оплатити до",
payOnline: "Оплатити онлайн",
description: "Опис",
qty: "Кількість",
unitPrice: "Ціна за одиницю",
amount: "Сума",
tax: "Податок",
subtotal: "Проміжний ітог",
total: "Всього",
amountDue: "Сума до сплати",
page: "Сторінка",
of: "з",
},
},
fr: {
invoiceNumber: "Facture N°",
dateOfIssue: "Date d'émission",
dateOfService: "Date de vente/prestation de service",
invoiceType: "Type de facture",
seller: {
name: "Vendeur",
vatNo: "N° TVA",
email: "E-mail",
accountNumber: "Numéro de compte",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Acheteur",
vatNo: "N° TVA",
email: "E-mail",
},
invoiceItemsTable: {
no: "N°",
nameOfGoodsService: "Désignation du produit/service",
typeOfGTU: "Type\n GTU",
amount: "Quantité",
unit: "Unité",
netPrice: "Prix HT",
vat: "TVA",
netAmount: "Montant\n HT",
vatAmount: "Montant TVA",
preTaxAmount: "Montant TTC",
sum: "TOTAL",
},
paymentInfo: {
paymentMethod: "Mode de paiement",
paymentDate: "Date de paiement",
},
vatSummaryTable: {
vatRate: "Taux TVA",
net: "HT",
vat: "TVA",
preTax: "TTC",
total: "Total",
},
paymentTotals: {
toPay: "Total à payer",
paid: "Payé",
leftToPay: "Reste à payer",
amountInWords: "Montant en lettres",
},
personAuthorizedToReceive: "Personne autorisée à recevoir",
personAuthorizedToIssue: "Personne autorisée à émettre",
createdWith: "Créé avec",
stripe: {
invoice: "Facture",
invoiceNumber: "Numéro de facture",
dateOfIssue: "Date d'émission",
dateDue: "Date d'échéance",
servicePeriod: "Période de service",
billTo: "Facturé à",
due: "échéance",
payOnline: "Payer en ligne",
description: "Description",
qty: "Quantité",
unitPrice: "Prix unitaire",
amount: "Montant",
tax: "Taxe",
subtotal: "Sous-total",
total: "Total",
amountDue: "Montant échéant",
page: "Page",
of: "de",
},
},
it: {
invoiceNumber: "Fattura N°",
dateOfIssue: "Data di emissione",
dateOfService: "Data di vendita/prestazione del servizio",
invoiceType: "Tipo di fattura",
seller: {
name: "Venditore",
vatNo: "P.IVA",
email: "E-mail",
accountNumber: "Numero di conto",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Acquirente",
vatNo: "P.IVA",
email: "E-mail",
},
invoiceItemsTable: {
no: "N°",
nameOfGoodsService: "Descrizione del prodotto/servizio",
typeOfGTU: "Tipo\n GTU",
amount: "Quantità",
unit: "Unità",
netPrice: "Prezzo netto",
vat: "IVA",
netAmount: "Importo\n netto",
vatAmount: "Importo IVA",
preTaxAmount: "Importo lordo",
sum: "TOTALE",
},
paymentInfo: {
paymentMethod: "Metodo di pagamento",
paymentDate: "Data di pagamento",
},
vatSummaryTable: {
vatRate: "Aliquota IVA",
net: "Netto",
vat: "IVA",
preTax: "Lordo",
total: "Totale",
},
paymentTotals: {
toPay: "Totale da pagare",
paid: "Pagato",
leftToPay: "Rimanente da pagare",
amountInWords: "Importo in lettere",
},
personAuthorizedToReceive: "Persona autorizzata a ricevere",
personAuthorizedToIssue: "Persona autorizzata a emettere",
createdWith: "Creato con",
stripe: {
invoice: "Fattura",
invoiceNumber: "Numero di fattura",
dateOfIssue: "Data di emissione",
dateDue: "Data di scadenza",
servicePeriod: "Periodo di servizio",
billTo: "Fatturare a",
due: "scadenza",
payOnline: "Pagare online",
description: "Descrizione",
qty: "Quantità",
unitPrice: "Prezzo unitario",
amount: "Importo",
tax: "Imposta",
subtotal: "Totale parziale",
total: "Totale",
amountDue: "Importo scaduto",
page: "Pagina",
of: "di",
},
},
nl: {
invoiceNumber: "Factuurnummer",
dateOfIssue: "Uitgiftedatum",
dateOfService: "Datum van verkoop/dienstverlening",
invoiceType: "Factuurtype",
seller: {
name: "Verkoper",
vatNo: "BTW-nummer",
email: "E-mail",
accountNumber: "Rekeningnummer",
swiftBic: "SWIFT/BIC",
},
buyer: {
name: "Koper",
vatNo: "BTW-nummer",
email: "E-mail",
},
invoiceItemsTable: {
no: "Nr",
nameOfGoodsService: "Omschrijving product/dienst",
typeOfGTU: "GTU-type",
amount: "Aantal",
unit: "Eenheid",
netPrice: "Netto prijs",
vat: "BTW",
netAmount: "Netto\n bedrag",
vatAmount: "BTW bedrag",
preTaxAmount: "Bruto bedrag",
sum: "TOTAAL",
},
paymentInfo: {
paymentMethod: "Betaalmethode",
paymentDate: "Betaaldatum",
},
vatSummaryTable: {
vatRate: "BTW-tarief",
net: "Netto",
vat: "BTW",
preTax: "Bruto",
total: "Totaal",
},
paymentTotals: {
toPay: "Te betalen",
paid: "Betaald",
leftToPay: "Nog te betalen",
amountInWords: "Bedrag in woorden",
},
personAuthorizedToReceive: "Persoon gemachtigd voor ontvangst",
personAuthorizedToIssue: "Persoon gemachtigd voor uitgifte",
createdWith: "Gemaakt met",
stripe: {
invoice: "Factuur",
invoiceNumber: "Factuurnummer",
dateOfIssue: "Uitgiftedatum",
dateDue: "Vervaldatum",
servicePeriod: "Dienstverleningperiode",
billTo: "Factuur aan",
due: "verval",
payOnline: "Online betalen",
description: "Omschrijving",
qty: "Aantal",
unitPrice: "Netto prijs",
amount: "Bedrag",
tax: "Belasting",
subtotal: "Subtotaal",
total: "Totaal",
amountDue: "Bedrag te betalen",
page: "Pagina",
of: "van",
},
},
} as const satisfies Record<SupportedLanguages, TranslationSchema>;