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

translation - How to avoid override string by child theme mo files when the string is empty?

programmeradmin3浏览0评论

In my child theme, I copy files from the parent theme and do some changes. My problem is about translation.

In functions.php I load the child translation file like this :

if ( !defined( 'ST_CHILD_TEXTDOMAIN' ) )
    define( 'ST_CHILD_TEXTDOMAIN', 'traveler-child' );

function traveler_child_theme_setup() {
    load_child_theme_textdomain( ST_CHILD_TEXTDOMAIN, get_stylesheet_directory() . '/language' );
}
add_action( 'after_setup_theme', 'traveler_child_theme_setup' );

With Poedit, I generated the po files with all labels to translate but I translate only one label "My account", others labels are empty string.

In my php file, I change the text domain only for this string :

And the label is translated, BUT others labels with ST_TEXTDOMAIN, not binded with the child mo file, are not translated anymore.

when I do this :

<?php var_dump(ST_TEXTDOMAIN); echo __('Hi, ', ST_TEXTDOMAIN ) . TravelHelper::get_username($userdata->ID); ?>

The output is correct :

 'traveler' 

So,... What happens ? Someone can help me ?

发布评论

评论列表(0)

  1. 暂无评论