Skip to content

Instantly share code, notes, and snippets.

@loorlab
Created February 25, 2025 03:39
Show Gist options
  • Save loorlab/bb75a0e2e3e97b59e6c482ce2c484261 to your computer and use it in GitHub Desktop.
Save loorlab/bb75a0e2e3e97b59e6c482ce2c484261 to your computer and use it in GitHub Desktop.
Translate : WooCommerce Checkout Fields
<?php
// Force translate WooCommerce
add_filter('gettext', function($translated, $text, $domain) {
if ($domain === 'woocommerce') {
$translations = [
'Billing details' => 'Detalles de facturación',
'First name' => 'Nombre',
'Last name' => 'Apellido',
'Company name' => 'Nombre de la empresa',
'Country / Region' => 'País / Región',
'Street address' => 'Dirección',
'Apartment, suite, unit, etc. (optional)' => 'Apartamento, suite, unidad, etc. (opcional)',
'Town / City' => 'Ciudad',
'State / County' => 'Estado / Provincia',
'Postcode / ZIP' => 'Código postal',
'Phone' => 'Teléfono',
'Email address' => 'Correo electrónico',
'Additional information' => 'Información adicional',
'Order notes (optional)' => 'Notas del pedido (opcional)',
'Your order' => 'Tu pedido',
'Place order' => 'Realizar pedido',
'Subtotal' => 'Subtotal',
'Shipping' => 'Envío',
'Total' => 'Total',
'Payment method' => 'Método de pago',
'Direct bank transfer' => 'Transferencia bancaria directa',
'Check payments' => 'Pagos con cheque',
'Cash on delivery' => 'Pago contra entrega',
'Credit card' => 'Tarjeta de crédito',
'Billing Address' => 'Dirección de facturación',
'Shipping Address' => 'Dirección de envío',
'Ship to a different address?' => '¿Enviar a una dirección diferente?',
'Create an account?' => '¿Crear una cuenta?',
'I have read and agree to the website terms and conditions' => 'He leído y acepto los términos y condiciones del sitio web',
];
if (isset($translations[$text])) {
return $translations[$text];
}
}
return $translated;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment