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

  • Is your code inside the after_setup_theme action hook? – leemon Jan 6 at 23:41
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

|improve this answer|||||

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.