How to Translate the WooCommerce Currency Symbol for Multilingual Stores

In a recent Business Bloomer Club Slack thread, a WooCommerce user wanted to translate the currency code “TWD” (Taiwan Dollar) into the Traditional Chinese symbol “新台幣.”

Since WPML does not handle currency symbols directly, an alternative solution is required.

Here’s how to customize WooCommerce currency symbols to display a translated version.

Solution: Use WooCommerce’s woocommerce_currency_symbol Filter

WooCommerce provides a woocommerce_currency_symbol filter that allows you to modify the currency symbol. This filter can change the currency label site-wide, making it ideal for translating currency codes.

Add the following code snippet to your theme’s functions.php file:

add_filter( 'woocommerce_currency_symbol', 'custom_currency_symbol', 10, 2 );

function custom_currency_symbol( $currency_symbol, $currency ) {
    if ( 'TWD' === $currency ) {
        $currency_symbol = '新台幣'; // Traditional Chinese for Taiwan Dollar
    }
    return $currency_symbol;
}

Explanation of the Code

  1. Filter Application: The woocommerce_currency_symbol filter allows you to change the currency symbol dynamically.
  2. Condition for TWD: This snippet checks if the currency is set to “TWD” (Taiwan Dollar). If so, it replaces “TWD” with the Traditional Chinese symbol “新台幣.”

Additional Considerations

  1. Multi-Currency Plugins: If you’re using a multi-currency plugin, ensure compatibility with the plugin to prevent overrides.
  2. Testing the Translation: Test the currency display across the site to confirm that the change appears consistently on product pages, checkout, and invoices.

Conclusion

By using WooCommerce’s woocommerce_currency_symbol filter, you can easily translate currency codes into local symbols or text, ensuring a localized and user-friendly experience for your customers.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

Your email address will not be published. Required fields are marked *