最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

translation - My theme is not translated

programmeradmin1浏览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');
}

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');
}

Share Improve this question edited Jan 7, 2020 at 5:39 leemon 2,0324 gold badges25 silver badges51 bronze badges asked Jan 6, 2020 at 23:31 Viral UniverseViral Universe 11 bronze badge 1
  • Is your code inside the after_setup_theme action hook? – leemon Commented Jan 6, 2020 at 23:41
Add a comment  | 

2 Answers 2

Reset to default 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

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'

发布评论

评论列表(0)

  1. 暂无评论