Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client wanted to translate the currency symbol from 'EGP' to 'جنيه' using string translation, but it was not working.
Solution:
We informed the client that currency symbols are managed by WooCommerce and there are limitations to translating them directly through string translation. However, we provided a solution using WooCommerce hooks to change the currency code. We directed the client to the WooCommerce documentation on how to change a currency symbol and provided sample code to be placed in the

functions.php

file of their theme after ensuring a full site backup.

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
    
function change_existing_currency_symbol( $currency_symbol, $currency ) {
     switch( $currency ) {
           case 'EGP':           
              if(ICL_LANGUAGE_CODE=='en'){
                  $currency_symbol = 'EGP'; 
              }else{
                 $currency_symbol = ' جنيه ';  
              }
           break;            
     }
     return $currency_symbol;
}

We asked the client to try this solution and provide feedback.

If this solution does not apply to your situation, or if it seems outdated, we recommend opening a new support ticket. We also highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please contact us through the WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by mohameda-80 4 years, 5 months ago.

Assisted by: Bigul.

Author Posts
August 21, 2020 at 9:30 pm #6847865

mohameda-80

Hi

I wont to translate from EGP to جنيه, I'm traying with string translation but not working

thanks

WhatsApp Image 2020-08-21 at 11.27.48 PM.jpeg
WhatsApp Image 2020-08-21 at 11.27.25 PM.jpeg
WhatsApp Image 2020-08-21 at 11.26.55 PM.jpeg
1.jpeg
August 24, 2020 at 7:16 pm #6862463

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

To help you faster, I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us: http://wpml.org/faq/provide-debug-information-faster-support/

Please note the Currency Symbols are managed by WooCommerce, so there are limitations to translate it. But we can change the Currency code via WooCommerce Hooks.

Please refer to this documentation https://docs.woocommerce.com/document/change-a-currency-symbol/ and the following sample code for more details.

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
  
function change_existing_currency_symbol( $currency_symbol, $currency ) {
     switch( $currency ) {
           case 'EGP':           
              if(ICL_LANGUAGE_CODE=='en'){
                  $currency_symbol = 'EGP'; 
              }else{
                 $currency_symbol = 'جنيه';  
              }
           break;            
     }
     return $currency_symbol;
}

You can place this code in functions.php file of your theme after a full site backup. Please try it and let me know your feedback.

--
Thanks!

Bigul

August 27, 2020 at 10:43 am #6885319

mohameda-80

thank you working well but i need to give space between جنيه and value

12.jpeg
August 27, 2020 at 4:00 pm #6887935

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the feedback. Happy to know the getting the translated output now. Please try with the following code and make sure you are getting the expected result or not.

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
   
function change_existing_currency_symbol( $currency_symbol, $currency ) {
     switch( $currency ) {
           case 'EGP':           
              if(ICL_LANGUAGE_CODE=='en'){
                  $currency_symbol = 'EGP'; 
              }else{
                 $currency_symbol = ' جنيه ';  
              }
           break;            
     }
     return $currency_symbol;
}

--
Thanks!

Bigul