Skip to content

Translation Method to change string without doing any code

Language is an interesting part of human life. Someone love to call his Mother like Mom or another one loves to call “Mummy or Ma”. Similarly when you are running a website with lots of English words which was written by the plugin/theme author which can be different or you might not like that wording.

Let me give you an example- When the user is not selecting any address on the checkout it shows this message- No shipping method has been selected. Please double check your address, or contact us if you need any help.

Now, the website owner needs to change this text and he is not a developer or he does not want to modify any code inside the plugin. Now the question is how it can be done?

How to change a string without modifying code in the Same Language?

Your website default language is English. Now, you need to change the above sentences from WooCommerce plugin without modifying the code. How you can do it?

Yes, you can apply my own titled “Translation method” 😀

By following my method you can keep your site language in your Default Langauge but the string which you need to change would be changed.

Applying the Translation Method

When you translate any WordPress plugin that time you just need to translate the plugin POT file and you need to insert the .po and .mo file. You can get help from this post.

Now, our problem is we need to keep the website in English, not to any other language.

When WordPress translate a plugin that time it reads the translated file name and then it replaces the translations file of the plugin with the file which is similar to the selected Langauge Code. Like if you set the website Langauge to Bengali then the language code is “bn_BD”. WordPress will check if the plugin has the translated file in bn_BD inside the language folder of the plugin. If the system gets the file then it will show all the strings inside the Translated file.

By using this method of WordPress, we will change a String and keep the website in English.

Our Target to change ” No shipping method has been selected. Please double check your address, or contact us if you need any help.” from WooCommerce and replace with “Hello! this is Nazmul Hassan”.

1st Step -> Install POEDIT on your local PC

2nd Step -> Open the woocommerce.pot file via your POT file-

Opening POT file of WooCommerce

Step-3 -> Now, find the string you want to translate and insert your translation like below-

Translating the string

Step-4 -> After translating just save the file as woocommerce-en_GB.mo & woocommerce-en_GB.po inside the wp-content/plugins/woocommerce/i18n/languages folder or you can insert it on wp-content/languages/plugins folder.

Now, when I have renamed the translation file to en_GB that means I need to set my WordPress language to English (United Kingdom) version. No need to worry, your all the strings will be same as before because you did not translate or change anything inside the .po/.mo file rather than a single string.

WordPress will read the file name and it will fetch all the strings from your woocommerce-en_GB.mo file 🙂

How it looks now?

Before applying the translation method it was like this-

Before Translating

After applying the translation method-

Applied Translation method
Published inCustomer SupportTips & Tricks

Be First to Comment

Leave a Reply

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

%d bloggers like this: