PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.13
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.13
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / Services / Receipt_I18n_Labels.php

Receipt_I18n_Labels.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.13, at includes/Services/Receipt_I18n_Labels.php

400 lines 33.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Receipt i18n label dictionary.
4 *
5 * Provides translated label strings for receipt templates.
6 * Used by Receipt_Data_Builder and Preview_Receipt_Builder to populate
7 * the i18n section of receipt data, and by the gallery install step
8 * to translate interpolated strings at copy-time.
9 *
10 * @package WCPOS\WooCommercePOS\Services
11 */
12
13 namespace WCPOS\WooCommercePOS\Services;
14
15 use WCPOS\WooCommercePOS\i18n;
16
17 /**
18 * Receipt_I18n_Labels class.
19 */
20 class Receipt_I18n_Labels {
21
22 /**
23 * Get all standalone receipt labels, translated for the current locale.
24 *
25 * These are referenced in templates as {{i18n.key}}.
26 *
27 * @param string $locale Optional locale to use while resolving labels.
28 *
29 * @return array<string, string> Map of label key => translated string.
30 */
31 public static function get_labels( string $locale = '' ): array {
32 if ( '' !== $locale && get_locale() !== $locale && function_exists( 'switch_to_locale' ) && switch_to_locale( $locale ) ) {
33 try {
34 new i18n();
35
36 return self::get_labels();
37 } finally {
38 restore_previous_locale();
39 }
40 }
41
42 return array(
43 // Order meta.
44 'order' => /* translators: Receipt label for the order number or order reference. */ __( 'Order', 'woocommerce-pos' ),
45 'date' => /* translators: Receipt label for the sale/order date. */ __( 'Date', 'woocommerce-pos' ),
46 'invoice_no' => /* translators: Receipt label for an invoice number. */ __( 'Invoice No.', 'woocommerce-pos' ),
47 'reference' => /* translators: Receipt label for a reference code, transaction reference, or document reference. */ __( 'Reference', 'woocommerce-pos' ),
48
49 // People.
50 'cashier' => /* translators: Receipt label for the POS cashier/operator who served the customer. */ __( 'Cashier', 'woocommerce-pos' ),
51 'customer' => /* translators: Receipt label for the customer name or customer details. */ __( 'Customer', 'woocommerce-pos' ),
52 'customer_tax_id' => /* translators: Receipt label for one customer tax/VAT/GST identification number. */ __( 'Customer Tax ID', 'woocommerce-pos' ),
53 'customer_tax_ids' => /* translators: Receipt section label for multiple customer tax/VAT/GST identification numbers. */ __( 'Customer Tax IDs', 'woocommerce-pos' ),
54 'tax_id_eu_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'VAT Number', 'woocommerce-pos' ),
55 'tax_id_gb_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'VAT Number', 'woocommerce-pos' ),
56 'tax_id_sa_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'VAT Number', 'woocommerce-pos' ),
57 'tax_id_au_abn' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'ABN', 'woocommerce-pos' ),
58 'tax_id_br_cpf' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'CPF', 'woocommerce-pos' ),
59 'tax_id_br_cnpj' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'CNPJ', 'woocommerce-pos' ),
60 'tax_id_in_gst' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'GSTIN', 'woocommerce-pos' ),
61 'tax_id_it_cf' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'Codice Fiscale', 'woocommerce-pos' ),
62 'tax_id_it_piva' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'Partita IVA', 'woocommerce-pos' ),
63 'tax_id_es_nif' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'NIF', 'woocommerce-pos' ),
64 'tax_id_ar_cuit' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'CUIT', 'woocommerce-pos' ),
65 'tax_id_ca_gst_hst' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'GST/HST', 'woocommerce-pos' ),
66 'tax_id_us_ein' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'EIN', 'woocommerce-pos' ),
67 'tax_id_other' => /* translators: Receipt label for a store tax/VAT/GST/business identification number. */ __( 'Tax ID', 'woocommerce-pos' ),
68
69 // Store tax IDs.
70 'store_tax_ids' => /* translators: Receipt section label for store tax/VAT/GST/business identification numbers. */ __( 'Tax IDs', 'woocommerce-pos' ),
71 // Store tax-ID per-type labels (separate namespace from customer-side
72 // tax_id_<type> keys added in PR #850 — same type can need different
73 // display copy on the store line vs the customer line per locale).
74 'store_tax_id_label_eu_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'VAT ID', 'woocommerce-pos' ),
75 'store_tax_id_label_gb_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'VAT No.', 'woocommerce-pos' ),
76 'store_tax_id_label_sa_vat' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'VAT No.', 'woocommerce-pos' ),
77 'store_tax_id_label_au_abn' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'ABN', 'woocommerce-pos' ),
78 'store_tax_id_label_br_cpf' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'CPF', 'woocommerce-pos' ),
79 'store_tax_id_label_br_cnpj' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'CNPJ', 'woocommerce-pos' ),
80 'store_tax_id_label_in_gst' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'GSTIN', 'woocommerce-pos' ),
81 'store_tax_id_label_it_cf' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'Codice Fiscale', 'woocommerce-pos' ),
82 'store_tax_id_label_it_piva' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'P.IVA', 'woocommerce-pos' ),
83 'store_tax_id_label_es_nif' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'NIF', 'woocommerce-pos' ),
84 'store_tax_id_label_ar_cuit' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'CUIT', 'woocommerce-pos' ),
85 'store_tax_id_label_ca_gst_hst' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'GST/HST No.', 'woocommerce-pos' ),
86 'store_tax_id_label_us_ein' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'EIN', 'woocommerce-pos' ),
87 'store_tax_id_label_de_ust_id' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'USt-IdNr.', 'woocommerce-pos' ),
88 'store_tax_id_label_de_steuernummer' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'Steuernummer', 'woocommerce-pos' ),
89 'store_tax_id_label_de_hrb' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'HRB', 'woocommerce-pos' ),
90 'store_tax_id_label_nl_kvk' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'KVK', 'woocommerce-pos' ),
91 'store_tax_id_label_fr_siret' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'SIRET', 'woocommerce-pos' ),
92 'store_tax_id_label_fr_siren' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'SIREN', 'woocommerce-pos' ),
93 'store_tax_id_label_gb_company' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'Company No.', 'woocommerce-pos' ),
94 'store_tax_id_label_ch_uid' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'UID', 'woocommerce-pos' ),
95 'store_tax_id_label_other' => /* translators: Receipt label for a store tax/VAT/GST/business identification number of this type. */ __( 'Tax ID', 'woocommerce-pos' ),
96
97 // Customer tax-ID labels — mirror the store-side keys so customer.tax_ids[]
98 // renders with the same per-type labels (ABN, VAT ID, NIF, GSTIN, etc.) the
99 // receipt header uses for the store. Resolved by Receipt_Data_Builder via
100 // the shared tax-id-label helper. Stores in the wild may want to translate
101 // these differently for the bill-to block (e.g. "Customer ABN") — splitting
102 // the namespace lets them.
103 'customer_tax_id_label_eu_vat' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'VAT ID', 'woocommerce-pos' ),
104 'customer_tax_id_label_gb_vat' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'VAT No.', 'woocommerce-pos' ),
105 'customer_tax_id_label_sa_vat' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'VAT No.', 'woocommerce-pos' ),
106 'customer_tax_id_label_au_abn' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'ABN', 'woocommerce-pos' ),
107 'customer_tax_id_label_br_cpf' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'CPF', 'woocommerce-pos' ),
108 'customer_tax_id_label_br_cnpj' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'CNPJ', 'woocommerce-pos' ),
109 'customer_tax_id_label_in_gst' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'GSTIN', 'woocommerce-pos' ),
110 'customer_tax_id_label_it_cf' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'Codice Fiscale', 'woocommerce-pos' ),
111 'customer_tax_id_label_it_piva' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'P.IVA', 'woocommerce-pos' ),
112 'customer_tax_id_label_es_nif' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'NIF', 'woocommerce-pos' ),
113 'customer_tax_id_label_ar_cuit' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'CUIT', 'woocommerce-pos' ),
114 'customer_tax_id_label_ca_gst_hst' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'GST/HST No.', 'woocommerce-pos' ),
115 'customer_tax_id_label_us_ein' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'EIN', 'woocommerce-pos' ),
116 'customer_tax_id_label_de_ust_id' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'USt-IdNr.', 'woocommerce-pos' ),
117 'customer_tax_id_label_de_steuernummer' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'Steuernummer', 'woocommerce-pos' ),
118 'customer_tax_id_label_de_hrb' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'HRB', 'woocommerce-pos' ),
119 'customer_tax_id_label_nl_kvk' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'KVK', 'woocommerce-pos' ),
120 'customer_tax_id_label_fr_siret' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'SIRET', 'woocommerce-pos' ),
121 'customer_tax_id_label_fr_siren' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'SIREN', 'woocommerce-pos' ),
122 'customer_tax_id_label_gb_company' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'Company No.', 'woocommerce-pos' ),
123 'customer_tax_id_label_ch_uid' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'UID', 'woocommerce-pos' ),
124 'customer_tax_id_label_other' => /* translators: Receipt label for a customer tax/VAT/GST/business identification number of this type. */ __( 'Tax ID', 'woocommerce-pos' ),
125
126 'prepared_for' => /* translators: Receipt/quote label for the customer or recipient the document was prepared for. */ __( 'Prepared For', 'woocommerce-pos' ),
127 'processed_by' => /* translators: Receipt label for the staff member/cashier who processed the order. */ __( 'Processed by', 'woocommerce-pos' ),
128
129 // Addresses.
130 'bill_to' => /* translators: Receipt/invoice address heading for the billing customer. */ __( 'Bill To', 'woocommerce-pos' ),
131 'ship_to' => /* translators: Receipt/invoice address heading for the shipping recipient. */ __( 'Ship To', 'woocommerce-pos' ),
132 'billed_to' => /* translators: Receipt/invoice address heading for the customer being billed. */ __( 'Billed To', 'woocommerce-pos' ),
133 'billing_address' => /* translators: Receipt/invoice address heading for the billing address. */ __( 'Billing Address', 'woocommerce-pos' ),
134
135 // Table headers.
136 'item' => /* translators: Receipt table column heading for product/item name. */ __( 'Item', 'woocommerce-pos' ),
137 'sku' => /* translators: Receipt table column heading for product SKU/reference code. */ __( 'SKU', 'woocommerce-pos' ),
138 'qty' => /* translators: Receipt table column heading for quantity. */ __( 'Qty', 'woocommerce-pos' ),
139 'unit_price' => /* translators: Receipt table column heading for unit price. */ __( 'Unit Price', 'woocommerce-pos' ),
140 'regular_price' => /* translators: Receipt label for the original or regular product price. */ __( 'Regular price', 'woocommerce-pos' ),
141 'selling_price' => /* translators: Receipt label for the product selling price before coupons. */ __( 'Selling price', 'woocommerce-pos' ),
142 'savings' => /* translators: Receipt label for money saved from the regular price. */ __( 'Savings', 'woocommerce-pos' ),
143 'total_saved' => /* translators: Receipt total-row label for coupon discounts plus savings from regular prices. */ __( 'Total saved', 'woocommerce-pos' ),
144 'unit_excl' => /* translators: Receipt table column heading for unit price excluding tax/VAT/GST. */ __( 'Unit (excl.)', 'woocommerce-pos' ),
145 'total_excl' => /* translators: Receipt table column heading for line total excluding tax/VAT/GST. */ __( 'Total (excl.)', 'woocommerce-pos' ),
146 'discount' => /* translators: Receipt label for discount amount or discount line. */ __( 'Discount', 'woocommerce-pos' ),
147 'packed' => /* translators: Packing slip label indicating an item/order has been packed. */ __( 'Packed', 'woocommerce-pos' ),
148 'packed_by' => /* translators: Standalone label used in printed receipt templates — heading above a signature block where the warehouse picker signs/dates the slip. */ __( 'Packed By', 'woocommerce-pos' ),
149 'signed_name' => /* translators: Standalone label used in printed receipt templates — sublabel under a blank signature line indicating the printed name field. */ __( 'Name', 'woocommerce-pos' ),
150
151 // Short receipt table headers.
152 'item_short' => /* translators: Short receipt table header for product/item name. Keep very short, ideally 3–8 characters. */ _x( 'Item', 'short receipt table header', 'woocommerce-pos' ),
153 'sku_short' => /* translators: Short receipt table header for SKU/reference/product code. Keep very short. */ _x( 'SKU', 'short receipt table header', 'woocommerce-pos' ),
154 'qty_short' => /* translators: Short receipt table header for quantity. Keep very short. */ _x( 'Qty', 'short receipt table header', 'woocommerce-pos' ),
155 'unit_excl_short' => /* translators: Short receipt table header for unit price excluding tax/VAT/GST. Keep compact for narrow receipt columns. */ _x( 'Unit excl.', 'short receipt table header', 'woocommerce-pos' ),
156 'tax_rate_short' => /* translators: Short receipt table header for tax/VAT/GST rate percentage, not tax amount. Keep compact for narrow receipt columns. */ _x( 'Tax %', 'short receipt table header: tax rate percentage', 'woocommerce-pos' ),
157 'tax_amount_short' => /* translators: Short receipt table header for tax/VAT/GST amount, not tax rate. Keep compact for narrow receipt columns. */ _x( 'Tax', 'short receipt table header: tax amount', 'woocommerce-pos' ),
158 'total_incl_tax_short' => /* translators: Short receipt table header for line total including tax/VAT/GST. Keep compact for narrow receipt columns. */ _x( 'Total incl.', 'short receipt table header', 'woocommerce-pos' ),
159 'taxable_excl_short' => /* translators: Short receipt table header for taxable amount excluding tax/VAT/GST. Keep compact for narrow receipt columns. */ _x( 'Taxable excl.', 'short receipt table header', 'woocommerce-pos' ),
160 'taxable_incl_short' => /* translators: Short receipt table header for taxable amount including tax/VAT/GST. Keep compact for narrow receipt columns. */ _x( 'Taxable incl.', 'short receipt table header', 'woocommerce-pos' ),
161
162 // Totals.
163 'subtotal' => /* translators: Receipt total-row label for the order subtotal before final total adjustments. */ __( 'Subtotal', 'woocommerce-pos' ),
164 'subtotal_excl_tax' => /* translators: Receipt total-row label for the subtotal excluding tax/VAT/GST. */ __( 'Subtotal (excl. tax)', 'woocommerce-pos' ),
165 'total' => /* translators: Receipt total-row label for the final amount due/paid for the order. */ __( 'Total', 'woocommerce-pos' ),
166 'total_tax' => /* translators: Receipt total-row label for the total tax/VAT/GST amount. */ __( 'Total Tax', 'woocommerce-pos' ),
167 'included_tax' => /* translators: Standalone label used in printed receipt templates for tax amounts already included in displayed prices. */ __( 'Tax included', 'woocommerce-pos' ),
168 'total_incl_tax' => /* translators: Receipt total-row label for the order total including tax/VAT/GST. */ __( 'Total (incl. tax)', 'woocommerce-pos' ),
169 'grand_total_incl_tax' => /* translators: Receipt total-row label for the grand total including tax/VAT/GST. */ __( 'Grand Total (incl. tax)', 'woocommerce-pos' ),
170 'tax' => /* translators: Receipt label for tax/VAT/GST amount, not a tax rate percentage. */ __( 'Tax', 'woocommerce-pos' ),
171 'paid' => /* translators: Receipt payment-section heading for amounts already paid by the customer. */ __( 'Paid', 'woocommerce-pos' ),
172 'paid_via' => /* translators: Receipt label prefix shown before a payment method, for example "Paid via Cash". */ __( 'Paid via', 'woocommerce-pos' ),
173 'tendered' => /* translators: Standalone receipt/payment label meaning money received from the customer at checkout. Use the target-language equivalent of "Received" as a concise label; do not use wording that means "Amount paid/deposited", and do not use procurement tender/bid language. */ __( 'Tendered', 'woocommerce-pos' ),
174 'change' => /* translators: Receipt/payment label for cash returned to the customer when the received amount is greater than the total; not "change" meaning modify. */ __( 'Change', 'woocommerce-pos' ),
175
176 // Tax summary.
177 'tax_summary' => /* translators: Receipt section heading for the tax/VAT/GST breakdown. */ __( 'Tax Summary', 'woocommerce-pos' ),
178 'taxable_excl' => /* translators: Receipt tax summary label for taxable amount excluding tax/VAT/GST. */ __( 'Taxable (excl.)', 'woocommerce-pos' ),
179 'tax_amount' => /* translators: Receipt tax summary label for tax/VAT/GST amount, not a tax rate percentage. */ __( 'Tax Amount', 'woocommerce-pos' ),
180 'taxable_incl' => /* translators: Receipt tax summary label for taxable amount including tax/VAT/GST. */ __( 'Taxable (incl.)', 'woocommerce-pos' ),
181
182 // Document titles.
183 'invoice' => /* translators: Document title printed at the top of an invoice template. */ __( 'Invoice', 'woocommerce-pos' ),
184 'tax_invoice' => /* translators: Document title printed at the top of a tax invoice/VAT invoice template. */ __( 'Tax Invoice', 'woocommerce-pos' ),
185 'quote' => /* translators: Document title for a quotation/estimate, not a receipt or completed purchase. */ __( 'Quote', 'woocommerce-pos' ),
186 'receipt' => /* translators: Document title printed at the top of a completed sale receipt. */ __( 'Receipt', 'woocommerce-pos' ),
187 'gift_receipt' => /* translators: Document title for a gift receipt that usually hides prices. */ __( 'Gift Receipt', 'woocommerce-pos' ),
188 'credit_note' => /* translators: Document title for a credit note/refund document. */ __( 'Credit Note', 'woocommerce-pos' ),
189 'packing_slip' => /* translators: Document title for a packing slip used to pick/pack shipped items. */ __( 'Packing Slip', 'woocommerce-pos' ),
190
191 // Returned items.
192 'returned_items' => /* translators: Receipt section heading for products returned/refunded from the order. */ __( 'Returned Items', 'woocommerce-pos' ),
193 'amount' => /* translators: Generic receipt column/field label for a monetary amount. */ __( 'Amount', 'woocommerce-pos' ),
194 'total_refunded' => /* translators: Receipt total-row label for the total amount refunded to the customer. */ __( 'Total Refunded', 'woocommerce-pos' ),
195 'refunded' => /* translators: Receipt label for an amount refunded to the customer. */ __( 'Refunded', 'woocommerce-pos' ),
196 'net_total' => /* translators: Receipt total-row label for total after subtracting refunds. */ __( 'Net Total', 'woocommerce-pos' ),
197
198 // Section labels.
199 'customer_note' => /* translators: Receipt section heading for a note/message supplied by or about the customer. */ __( 'Customer Note', 'woocommerce-pos' ),
200 'terms_and_conditions' => /* translators: Receipt section heading for sale terms and conditions text. */ __( 'Terms & Conditions', 'woocommerce-pos' ),
201 'a_message_for_you' => /* translators: Receipt section heading for a short merchant message to the customer. */ __( 'A message for you', 'woocommerce-pos' ),
202 'details' => /* translators: Standalone label used in printed receipt templates — column heading for invoice meta (issued date, cashier, currency). */ __( 'Details', 'woocommerce-pos' ),
203 'issued' => /* translators: Standalone label used in printed receipt templates — date the invoice was issued. */ __( 'Issued', 'woocommerce-pos' ),
204
205 // Payment instructions — used by the Invoice template to render a
206 // "How to pay" panel guarded by {{#order.needs_payment}}.
207 'amount_due' => /* translators: Standalone label used in printed receipt templates — large amount-due heading on unpaid invoices. */ __( 'Amount due', 'woocommerce-pos' ),
208 'how_to_pay' => /* translators: Standalone label used in printed receipt templates — section heading for payment instructions on unpaid invoices. */ __( 'How to pay', 'woocommerce-pos' ),
209 'bank_transfer' => /* translators: Standalone label used in printed receipt templates — subheading for the bank-transfer column under "How to pay". */ __( 'Bank transfer', 'woocommerce-pos' ),
210 'pay_online' => /* translators: Standalone label used in printed receipt templates — subheading for the online-payment column under "How to pay". */ __( 'Pay online', 'woocommerce-pos' ),
211 'scan_qr_or_visit' => /* translators: Standalone label used in printed receipt templates — instruction shown next to a pay-now QR code, followed by the payment URL. */ __( 'Scan the QR code, or visit:', 'woocommerce-pos' ),
212 'account' => /* translators: Standalone label used in printed receipt templates — bank-transfer field label for the account name. */ __( 'Account', 'woocommerce-pos' ),
213
214 // Footers.
215 'thank_you' => /* translators: Short receipt footer message thanking the customer. */ __( 'Thank you!', 'woocommerce-pos' ),
216 'thank_you_purchase' => /* translators: Receipt footer message thanking the customer for a completed purchase. */ __( 'Thank you for your purchase!', 'woocommerce-pos' ),
217 'thank_you_shopping' => /* translators: Receipt footer message thanking the customer for shopping at the store. */ __( 'Thank you for shopping with us!', 'woocommerce-pos' ),
218 'thank_you_business' => /* translators: Receipt footer message thanking the customer for their business. */ __( 'Thank you for your business.', 'woocommerce-pos' ),
219 'gift_return_policy' => /* translators: Gift receipt footer explaining the return/exchange period. */ __( 'Items may be returned or exchanged within 30 days with this receipt.', 'woocommerce-pos' ),
220 'quote_validity' => /* translators: Quote document footer explaining validity period and that the quote is not a receipt. */ __( 'This quote is valid for 30 days from the date of issue. Prices are subject to change after the validity period. This is not a receipt or confirmation of purchase.', 'woocommerce-pos' ),
221 'quote_not_receipt' => /* translators: Quote document notice clarifying it is not a completed-sale receipt. */ __( 'This is a quote, not a receipt', 'woocommerce-pos' ),
222 'return_retain_receipt' => /* translators: Receipt footer asking the customer to keep the receipt for returns/records. */ __( 'Please retain this receipt for your records.', 'woocommerce-pos' ),
223
224 // Thermal / kitchen.
225 'kitchen' => /* translators: Kitchen ticket document label for food/drink preparation; keep concise and uppercase if natural in the target language. */ __( 'KITCHEN', 'woocommerce-pos' ),
226
227 // Fiscal.
228 'signature' => /* translators: Receipt label for a customer or staff signature line. */ __( 'Signature', 'woocommerce-pos' ),
229 'document_type' => /* translators: Fiscal receipt label for document type/category. */ __( 'Document Type', 'woocommerce-pos' ),
230 'copy' => /* translators: Fiscal receipt label for a printed copy of a document. */ __( 'Copy', 'woocommerce-pos' ),
231 'copy_number' => /* translators: Fiscal receipt label for copy number/sequence. */ __( 'Copy No.', 'woocommerce-pos' ),
232
233 // Order meta + footer (used by detailed-receipt header / order column / footer).
234 'status' => /* translators: Receipt label for order/document status. */ __( 'Status', 'woocommerce-pos' ),
235 'completed' => /* translators: Receipt status value meaning the order/document is completed. */ __( 'Completed', 'woocommerce-pos' ),
236 'printed' => /* translators: Receipt status value meaning the document has been printed. */ __( 'Printed', 'woocommerce-pos' ),
237 'opening_hours' => /* translators: Receipt label for the store business opening hours. */ __( 'Opening Hours', 'woocommerce-pos' ),
238 );
239 }
240
241 /**
242 * Get interpolated phrases for copy-time translation.
243 *
244 * Each entry maps the English phrase (as it appears in gallery templates,
245 * with Mustache variables intact) to a translatable format string.
246 * At copy-time, the format string is translated via __() and %s placeholders
247 * are replaced with the original Mustache variable(s).
248 *
249 * Structure: 'English phrase with {{var}}' => array(
250 * 'format' => 'English phrase with %s',
251 * 'variables' => array( '{{var}}' ),
252 * )
253 *
254 * @return array<string, array{format: string, variables: string[]}> Interpolated phrase map.
255 */
256 public static function get_interpolated_phrases(): array {
257 return array(
258 'Tax ID: {{store.tax_id}}' => array(
259 /* translators: %s: store tax identification number */
260 'format' => __( 'Tax ID: %s', 'woocommerce-pos' ),
261 'variables' => array( '{{store.tax_id}}' ),
262 ),
263 'Phone: {{store.phone}}' => array(
264 /* translators: %s: store phone number */
265 'format' => __( 'Phone: %s', 'woocommerce-pos' ),
266 'variables' => array( '{{store.phone}}' ),
267 ),
268 'Email: {{store.email}}' => array(
269 /* translators: %s: store email address */
270 'format' => __( 'Email: %s', 'woocommerce-pos' ),
271 'variables' => array( '{{store.email}}' ),
272 ),
273 'Paid via {{method_title}}' => array(
274 /* translators: %s: payment method name */
275 'format' => __( 'Paid via %s', 'woocommerce-pos' ),
276 'variables' => array( '{{method_title}}' ),
277 ),
278 'Refunded via {{method_title}}' => array(
279 /* translators: %s: payment method name */
280 'format' => __( 'Refunded via %s', 'woocommerce-pos' ),
281 'variables' => array( '{{method_title}}' ),
282 ),
283 'Served by {{cashier.name}}' => array(
284 /* translators: %s: cashier name */
285 'format' => __( 'Served by %s', 'woocommerce-pos' ),
286 'variables' => array( '{{cashier.name}}' ),
287 ),
288 'Customer: {{customer.name}}' => array(
289 /* translators: %s: customer name */
290 'format' => __( 'Customer: %s', 'woocommerce-pos' ),
291 'variables' => array( '{{customer.name}}' ),
292 ),
293 'Thank you, {{customer.name}}!' => array(
294 /* translators: %s: customer name */
295 'format' => __( 'Thank you, %s!', 'woocommerce-pos' ),
296 'variables' => array( '{{customer.name}}' ),
297 ),
298 'Ref: {{transaction_id}}' => array(
299 /* translators: %s: payment transaction ID */
300 'format' => __( 'Ref: %s', 'woocommerce-pos' ),
301 'variables' => array( '{{transaction_id}}' ),
302 ),
303 'Ref: #{{order.number}}' => array(
304 /* translators: %s: order number with # prefix */
305 'format' => __( 'Ref: %s', 'woocommerce-pos' ),
306 'variables' => array( '#{{order.number}}' ),
307 ),
308 'Order #{{order.number}}' => array(
309 /* translators: %s: order number with # prefix */
310 'format' => __( 'Order %s', 'woocommerce-pos' ),
311 'variables' => array( '#{{order.number}}' ),
312 ),
313 'SKU: {{sku}}' => array(
314 /* translators: %s: product SKU */
315 'format' => __( 'SKU: %s', 'woocommerce-pos' ),
316 'variables' => array( '{{sku}}' ),
317 ),
318 'Subtotal: {{line_subtotal_incl}}' => array(
319 /* translators: %s: line subtotal amount */
320 'format' => __( 'Subtotal: %s', 'woocommerce-pos' ),
321 'variables' => array( '{{line_subtotal_incl}}' ),
322 ),
323 'Discount: -{{discounts_incl}}' => array(
324 /* translators: %s: discount amount with minus sign */
325 'format' => __( 'Discount: %s', 'woocommerce-pos' ),
326 'variables' => array( '-{{discounts_incl}}' ),
327 ),
328 'Taxable: {{taxable_amount_excl}}' => array(
329 /* translators: %s: taxable amount */
330 'format' => __( 'Taxable: %s', 'woocommerce-pos' ),
331 'variables' => array( '{{taxable_amount_excl}}' ),
332 ),
333 );
334 }
335
336 /**
337 * Translate interpolated phrases in template content.
338 *
339 * Replaces English phrases containing Mustache variables with
340 * their translated equivalents, preserving the Mustache variables.
341 *
342 * @param string $content Template content with English phrases.
343 *
344 * @return string Content with interpolated phrases translated.
345 */
346 public static function translate_interpolated_phrases( string $content ): string {
347 $phrases = self::get_interpolated_phrases();
348
349 // Sort by key length descending to prevent substring replacement issues.
350 uksort(
351 $phrases,
352 function ( $a, $b ) {
353 return strlen( $b ) - strlen( $a );
354 }
355 );
356
357 foreach ( $phrases as $english => $config ) {
358 if ( false === strpos( $content, $english ) ) {
359 continue;
360 }
361
362 // Build the translated string with Mustache variables re-inserted.
363 // Handle both %s and %1$s numbered placeholders that translators may use.
364 $translated = $config['format'];
365 foreach ( $config['variables'] as $index => $variable ) {
366 $numbered = '%' . ( $index + 1 ) . '$s';
367 $translated = str_replace( $numbered, $variable, $translated );
368 }
369 // Replace any remaining positional %s (single-variable case).
370 if ( 1 === count( $config['variables'] ) ) {
371 $translated = str_replace( '%s', $config['variables'][0], $translated );
372 }
373 $translated = self::normalize_contact_label_phrase( $english, $translated );
374
375 $content = str_replace( $english, $translated, $content );
376 }
377
378 return $content;
379 }
380
381 /**
382 * Keep receipt contact labels consistent after copy-time translation.
383 *
384 * @param string $english Source phrase.
385 * @param string $translated Translated phrase.
386 * @return string
387 */
388 private static function normalize_contact_label_phrase( string $english, string $translated ): string {
389 if ( 'Email: {{store.email}}' === $english ) {
390 return preg_replace( '/\s*:\s*/', ': ', $translated, 1 ) ?? $translated;
391 }
392
393 if ( 'Phone: {{store.phone}}' === $english ) {
394 return preg_replace( '/\s*:\s*/', ': ', $translated, 1 ) ?? $translated;
395 }
396
397 return $translated;
398 }
399 }
400