0

I'm trying to translate a WordPress template. I went to language files, there were already 3 languages so I copied one of it (es_ES.po in my case), then opened that copy with Poedit and started translating to my language (Arabic). After finishing the translation, I changed the WordPress language from the dashboard, but the language didn't change in the template, it kept being English. Any idea why this happens?

These are the language instructions from functions.php:

load_theme_textdomain( 'mundothemes', get_template_directory() . '/idiomas' );
$locale = get_locale();
$locale_file = get_template_directory() . "/idiomas/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );

and here is a screenshot of the language folder:

enter image description here

2
  • did you generate a .mo file and placed it in the right place? Sep 19 '16 at 20:05
  • yeah, i have edit my question and include screenshot of the language folder Sep 19 '16 at 20:19
3

Can you please try this code in your theme functions.php and tell us what locale do you get on the screen?

die( var_dump( get_locale() ) );

If get_locale() value is not ar_AR then that explains why it won't load your translation. and you may need to adjust/change the locale file name ( the .mo file ) in your language folder.

5
  • sorry, but answers should be answers. What you ask should be a comment to the question Sep 19 '16 at 20:04
  • I was unable to add comment to him. that's why Sep 19 '16 at 20:07
  • it gives me string 'ar' (length=2) Sep 19 '16 at 20:47
  • In such case, please try to rename the po/mo files from ar_AR.mo to ar.mo only so that the file name match exactly what's returned from get_locale() and see if that solves the problem Sep 19 '16 at 20:48
  • i have change the .mo file name to ar and it works super fine now, thank you Sep 19 '16 at 20:49

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.