Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions backend/src/i18n/locales/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"invoiceTitle": "Фактура",
"invoiceNumberLabel": "Номер на фактура",
"invoiceNumberShortLabel": "Фактура №",
"invoiceDateLabel": "Дата на фактура",
"dateLabel": "Дата",
"dueDateLabel": "Срок за плащане",
"dueShortLabel": "Срок",
"referenceLabel": "Референция",
"billToHeading": "Получател",
"itemsHeading": "Детайли на фактурата",
"itemHeaderDescription": "Описание",
"itemHeaderQuantity": "Количество",
"itemHeaderQuantityShort": "Кол.",
"itemHeaderUnit": "Мярка",
"itemHeaderUnitPrice": "Единична цена",
"itemHeaderUnitPriceShort": "Ставка",
"itemHeaderAmount": "Сума",
"itemHeaderTax": "Данък",
"summaryHeading": "Обобщение на фактурата",
"subtotalLabel": "Междинна сума",
"discountLabel": "Отстъпка",
"taxLabel": "Данък",
"totalLabel": "Общо",
"statusLabel": "Статус",
"taxSummaryHeading": "Обобщение на данъци",
"taxableLabel": "Подлежащо на облагане",
"taxAmountLabel": "Сума на данъка",
"taxIdLabel": "Данъчен номер",
"outstandingBalanceLabel": "Неплатен остатък",
"paymentInformationHeading": "Информация за плащане",
"paymentMethodsLabel": "Начини на плащане",
"paymentMethodsPrefix": "Начини:",
"bankAccountLabel": "Банкова сметка",
"bankAccountPrefix": "Банка:",
"paymentTermsLabel": "Условия за плащане",
"notesHeading": "Бележки",
"thankYouNote": "Благодарим ви за доверието!"
}
91 changes: 47 additions & 44 deletions backend/src/i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ptBrRaw from "./locales/pt-br.json" with { type: "json" };
import trRaw from "./locales/tr.json" with { type: "json" };
import esCoRaw from "./locales/es-co.json" with { type: "json" };
import esArRaw from "./locales/es-ar.json" with { type: "json" };
import bgRaw from "./locales/bg.json" with { type: "json" };

export type InvoiceLabels = {
invoiceTitle: string;
Expand Down Expand Up @@ -48,48 +49,49 @@ export type InvoiceLabels = {

const REQUIRED_KEYS = [
"invoiceTitle",
"invoiceNumberLabel",
"invoiceNumberShortLabel",
"invoiceDateLabel",
"dateLabel",
"dueDateLabel",
"dueShortLabel",
"referenceLabel",
"billToHeading",
"itemsHeading",
"itemHeaderDescription",
"itemHeaderQuantity",
"itemHeaderQuantityShort",
"itemHeaderUnit",
"itemHeaderUnitPrice",
"itemHeaderUnitPriceShort",
"itemHeaderAmount",
"itemHeaderTax",
"summaryHeading",
"subtotalLabel",
"discountLabel",
"taxLabel",
"totalLabel",
"statusLabel",
"taxSummaryHeading",
"taxableLabel",
"taxAmountLabel",
"taxIdLabel",
"outstandingBalanceLabel",
"paymentInformationHeading",
"paymentMethodsLabel",
"paymentMethodsPrefix",
"bankAccountLabel",
"bankAccountPrefix",
"paymentTermsLabel",
"notesHeading",
"thankYouNote",
"invoiceNumberLabel",
"invoiceNumberShortLabel",
"invoiceDateLabel",
"dateLabel",
"dueDateLabel",
"dueShortLabel",
"referenceLabel",
"billToHeading",
"itemsHeading",
"itemHeaderDescription",
"itemHeaderQuantity",
"itemHeaderQuantityShort",
"itemHeaderUnit",
"itemHeaderUnitPrice",
"itemHeaderUnitPriceShort",
"itemHeaderAmount",
"itemHeaderTax",
"summaryHeading",
"subtotalLabel",
"discountLabel",
"taxLabel",
"totalLabel",
"statusLabel",
"taxSummaryHeading",
"taxableLabel",
"taxAmountLabel",
"taxIdLabel",
"outstandingBalanceLabel",
"paymentInformationHeading",
"paymentMethodsLabel",
"paymentMethodsPrefix",
"bankAccountLabel",
"bankAccountPrefix",
"paymentTermsLabel",
"notesHeading",
"thankYouNote",
] as const;

function coerceLabels(locale: string, raw: unknown): InvoiceLabels {
if (!raw || typeof raw !== "object") {
throw new Error(`Invalid translation data for locale '${locale}'`);
}

const record = raw as Record<string, unknown>;
for (const key of REQUIRED_KEYS) {
if (typeof record[key] !== "string") {
Expand All @@ -103,14 +105,15 @@ function coerceLabels(locale: string, raw: unknown): InvoiceLabels {

const catalogs: Record<string, InvoiceLabels> = Object.freeze({
en: coerceLabels("en", enRaw),
nl: coerceLabels("nl", nlRaw),
de: coerceLabels("de", deRaw),
"pt-br": coerceLabels("pt-br", ptBrRaw),
pt: coerceLabels("pt", ptBrRaw), // alias for pt-br
tr: coerceLabels("tr", trRaw),
"es-co": coerceLabels("es-co", esCoRaw),
es: coerceLabels("es", esCoRaw), // alias for es-co
"es-ar": coerceLabels("es-ar", esArRaw),
nl: coerceLabels("nl", nlRaw),
de: coerceLabels("de", deRaw),
"pt-br": coerceLabels("pt-br", ptBrRaw),
pt: coerceLabels("pt", ptBrRaw), // alias for pt-br
tr: coerceLabels("tr", trRaw),
"es-co": coerceLabels("es-co", esCoRaw),
es: coerceLabels("es", esCoRaw), // alias for es-co
"es-ar": coerceLabels("es-ar", esArRaw),
bg: coerceLabels("bg", bgRaw),
});

function normalizeLocale(locale?: string): string {
Expand Down
Loading