0

I made changes to my website and it became multilingual locally. I'm using qTranslate-X plugin. I deal with PT and EN. I used __() and _e() functions for strings and POEdit for creating .po and .mo files.

While on my localhost, everything worked fine. But, as soon as I pushed it to production, the wp-content/themes/fottorama/languages are not loaded anymore and then strings are not translated. (obs: fottorama is my theme name). The website is www.fottorama.com.br.

Could anyone give me a path or any orientation regarding this? I really appreciate your help.

0

First of all, I would like to thank @the_dramatist for spending his time helping me. At the end, I made a huge and stupid mistake. It was my fault:

Locally, I set the qTranslate available languages and for Portuguese, I changed the locale name from pt_PT to pt_BR. When I pushed the code to production and it went live, I had to set it again on wp-admin and I forgot to make the same change. So it was looking for a pt_PT.mo file, while there was only a pt_BR.mo file.

I hope no one faces something like this.

0

First of all check the text domain you initiated in theme header. Better you keep that as the theme name, like if the theme name is My Theme and base theme directory name is my-theme then keep the text domain my-theme. Then you need to load the text domain with load_theme_textdomain hooking to plugins_loaded hook in functions.php like below-

add_action( 'plugins_loaded', 'mytheme_load_textdomain' );
/**
 * Load theme textdomain.
 *
 * @since 1.0.0
 */
function mytheme_load_textdomain() {
  load_theme_textdomain( 'my-plugin', false, basename( dirname( __FILE__ ) ) . '/languages' ); 
}

Keep the *.mo and *.po files name like my-theme-{language-sufix}.po and my-theme-{language-sufix}.mo and inside the __() or _e() functions you must pass the text domain as string, not as variable.

If it's still not working then you can try testing by putting your translated *.po and *.mo file in wp-content/languages/themes directory with name my-theme-{language-sufix}.po and my-theme-{language-sufix}.mo.

  • I used the theme text domain which is set in my style.css file. Now I see that I have a 'qtranslate' text domain in qtranslate.php plugin file. Are you saying that I should rewrite all my translation functions in order to use the plugin text domain instead? If I messed it up, why everything was working locally while using 'fottorama' text domain instead of 'qtranslate' text domain? Thanks again! – Rodrigo Barbosa Nov 22 '17 at 12:30
  • Obviously ! Your plugin should have your unique text domain ! Otherwise how you'll be able to translate that ? @RodrigoBarbosa – CodeMascot Nov 22 '17 at 12:42
  • Sorry if I'm not getting it, but I'm not translating a plugin. I'm using a WP plugin, qTranslate-X, to translate my theme. My functions use the unique 'theme' text domain, 'fottorama', which is loaded with add_action( 'after_setup_theme', 'fottorama_theme_setup' ) in functions.php. Is everything really wrong? Because it works fine on localhost. Sorry if I'm being stupid. – Rodrigo Barbosa Nov 22 '17 at 12:59
  • Uh... I understand now. Please give your *.po and *.mo file name here and ensure me if there is any function has been called like load_theme_textdomain or not. I'm going ut for one or two hours. When I'll be be back I'll give you the answer. – CodeMascot Nov 22 '17 at 13:03
  • thanks a lot for your help. But I found my mistake. It was stupid. I just published my answer. – Rodrigo Barbosa Nov 22 '17 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.