Marius Vetrici
CEO wpriders
Date
July 2, 2015

Translate Plugin From Child Theme

Ever needed to translate some strings from a plugin so as to be able to further upgrade the main plugin without loosing your translations?

I did.

This is because there some languages around for which there are no default translations in plugins like WooCommerce Social Login or WooCommerce Bookings.

Unfortunately there’s no standard way to do that (at least I found none), but after some debugging inside WordPress here’s a solution that I would like to share with you:
In order to use this, follow these steps:

  1. Find the text domain of your plugin (look in plugin source code)
  2. Create a /translations folder inside your Theme
  3. Copy the .po file of your plugin to the /translations folder
  4. Rename the .po file and give it the following name: {text_domain}-{locale}.po For example: woocommerce-social-login-ro_RO.po (where woocommerce-social-login is the text domain and ro_RO is the desired locale)
  5. Compile .po file to .mo using a tool like PoEdit That’s it.

Optionally

In case you want to remove from your .po file (in your /translations folder) the untranslated strings so as to only leave there the one that you translated, feel free to use msgattrib gettext tool:

Entrepreneurs usually struggle to create their online platforms when they don’t have a technical partner. It’s confusing and overwhelming.
We have a 5-step process that makes it easy and helps them avoid all the traps. In just 60 days, your web platform is set up and they can start making money.
Send us your project idea and get a free 5-minute review.
Want a beautiful and effective website?

Leave a reply

Your email address will not be published.

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

Want More Amazing Stories?
Sign up now and get the best business as well as technical advice on how to run your WordPress powered business:
  • This field is for validation purposes and should be left unchanged.