1

I can't translate my wordpress plugin.

I have my .po and .mo files inside the plugin-name/languages folder but it doesn't work. Does anyone have a clue on what could be missing?


Details:

I translated the theme using the .po and .mo files and adding define('WPLANG', 'pt_BR'); on wp-config.php. It works fine.

But not all website is translated. So I tried the same with the plugins, but even translating the plugin .pot and naming plugin-name-pt_BR.po and plugin-name-pt_BR.mo, and placing them on /plugin-name/languages (which already existed) as I saw on the internet, it didn't work.

I also tried copying the translations on plugin-name-pt_BR.po and pasting inside wp-content/themes/theme-name/languages/pt_BR.po, but it was not use.

I tried installing Loco-Translate and POEditor, but they only manage the .po translation, which is fine and translated, but not reflected on the website.

I don't know much of Wordpress and PHP, but it seems to me that the plugin code might lack something to call the .po file.

If I don't translate this way, I'll have to translate directly inside the plugin's source code.

brenorb
  • 21
  • 2
  • Hi and welcome to StackOverflow. It's a little unclear what you are asking. Give this article a read https://stackoverflow.com/help/how-to-ask as it'll give you some pointers on how to correctly ask questions in order to get good quality answers. Remember always to provide complete, minimal and verifiable examples to let others assist you – Javier Larroulet Sep 14 '18 at 17:11
  • Thank you @JavierLarroulet. I'm sorry, I tried to provide the steps I took so it could be easier understood as I saw in another tutorial. I'll rewrite it. – brenorb Sep 14 '18 at 18:13
  • @brenorb, have you added `load_theme_textdomain` function in the functions.php of your theme? – Ivnhal Sep 14 '18 at 18:55
  • @IvnH the theme came prepared for it. The function `load_theme_textdomain( 'theme', get_template_directory() . '/languages' );` is inside the theme setup function. Also, It translates almost everything. Maybe it's a conflict inside the .po file... I don't know... – brenorb Sep 14 '18 at 21:01
  • I just saw this guy had the same problem [here](https://stackoverflow.com/questions/40438335/wordpress-cant-translate-one-term-with-loco-translate-plugin) but I didn't understand the solution. Did he just did the same thing again and it worked? – brenorb Sep 14 '18 at 21:06
  • gettext can be weird in apache, try restarting the service or have a look at [this question](https://stackoverflow.com/questions/13625659/how-to-clear-phps-gettext-cache-without-restart-apache-nor-change-domain) – msg Sep 14 '18 at 23:06
  • @brenorb, do you uploaded mo file same as po? – Ivnhal Sep 15 '18 at 05:54
  • @IvnH Yes, I did, compiled from the po file in Poedit. – brenorb Sep 15 '18 at 19:28
  • @brenorb, have you tried to re-sync translation? This options is in Poedit same as in Loco translate. – Ivnhal Sep 16 '18 at 18:16
  • @IvnH What is re-sync translation? I don't have Poedit paid version, maybe that's not available. I didn't see this option in Loco Translate. Actually, what I did is commenting the original phrases and manually translated directly on the code. I know it's bad, but it was the only way to work now :/ – brenorb Oct 15 '18 at 20:31
  • @brenorb In Poedit try from menu Catalogue - Update from sources – Ivnhal Oct 16 '18 at 08:26

0 Answers0