0

I have translated the po file and uploaded the mo and po files in the languages folder with the language code file name. But translation is not loading Here is the function file code:

if( is_dir( get_stylesheet_directory() . '/languages' ) ) {
    load_theme_textdomain('adifier', get_stylesheet_directory() . '/languages');
} else{
    load_theme_textdomain('adifier', get_template_directory() . '/languages');
}

enter image description here

1
  • Is your code inside the after_setup_theme action hook?
    – leemon
    Commented Jan 6, 2020 at 23:41

2 Answers 2

0

Make sure you put your function inside after_setup_theme action hook

add_action( 'after_setup_theme', 'load_translation' );

function load_translation() {
    if( is_dir( get_stylesheet_directory() . '/languages' ) ) {
        load_theme_textdomain('adifier', get_stylesheet_directory() . '/languages');
} else {
    load_theme_textdomain('adifier', get_template_directory() . '/languages');
}

Also, you have to make sure your theme domain is matched with the translated file. For an easier method, I'd recommend you to use Loco Translate, with that plugin you can translate for themes nor plugins directly from wp-admin

Loco Translate Plugin

0

Salam, I had the same problem but I solved it, You should change the name of the file as you have in wordpress/wp-content-language For exemple me I had just : 'ar.po' not 'ar-Ma.po'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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