admin管理员组文章数量:1415139
I have written and translated a theme and all is working fine, except the starter content. It seems that i am not able to translate the content and it is still displayed in English, even though I have included translation in another language and the default WordPress language is set to the other language. Here is my starter content array:
'posts' => array(
//Add pages
'home' => array(
'post_type' => 'page',
'post_title' => _x( 'Homepage', 'slug' ),
'post_content' => _x( 'Welcome to your site! This is your homepage, which is what most visitors will see when they come to your site for the first time. Use the customizer to choose between a static homepage or display the latest posts in a beautiful 2-column layout instead.', 'slug' ),
),
'about' => array(
'post_type' => 'page',
'post_title' => _x( 'About', 'slug' ),
'thumbnail' => '{{featured-image-about}}',
'post_content' => _x( 'Welcome on board! This is your about page, which is what most visitors will check to find out more information about yourself. Write here about your hobbies, work and passion.', 'slug' ),
),
'contacts' => array(
'post_type' => 'page',
'post_title' => _x( 'Contacts', 'slug' ),
'post_content' => _x( 'This is a good place to add some basic contact information, such as an address and a phone number. You can also add a contact form with contact form 7 or another plugin', 'slug' ),
),
),
P.S.: It seems like the pages (home, about, contacts) are stored in alphabetical order (about, contacts, home) and displayed alphabetically as menu items. I would also be interested to know if there is a way to sort the pages by the way they entered, e.g. home, about, contacts rather than about, contacts, home.
I have written and translated a theme and all is working fine, except the starter content. It seems that i am not able to translate the content and it is still displayed in English, even though I have included translation in another language and the default WordPress language is set to the other language. Here is my starter content array:
'posts' => array(
//Add pages
'home' => array(
'post_type' => 'page',
'post_title' => _x( 'Homepage', 'slug' ),
'post_content' => _x( 'Welcome to your site! This is your homepage, which is what most visitors will see when they come to your site for the first time. Use the customizer to choose between a static homepage or display the latest posts in a beautiful 2-column layout instead.', 'slug' ),
),
'about' => array(
'post_type' => 'page',
'post_title' => _x( 'About', 'slug' ),
'thumbnail' => '{{featured-image-about}}',
'post_content' => _x( 'Welcome on board! This is your about page, which is what most visitors will check to find out more information about yourself. Write here about your hobbies, work and passion.', 'slug' ),
),
'contacts' => array(
'post_type' => 'page',
'post_title' => _x( 'Contacts', 'slug' ),
'post_content' => _x( 'This is a good place to add some basic contact information, such as an address and a phone number. You can also add a contact form with contact form 7 or another plugin', 'slug' ),
),
),
P.S.: It seems like the pages (home, about, contacts) are stored in alphabetical order (about, contacts, home) and displayed alphabetically as menu items. I would also be interested to know if there is a way to sort the pages by the way they entered, e.g. home, about, contacts rather than about, contacts, home.
Share Improve this question asked Aug 30, 2019 at 18:41 BadanBadan 2251 silver badge7 bronze badges 1 |1 Answer
Reset to default 0As you're using _x()
as your translation function you should do one of the following.
1) If 'slug'
is supposed to be your text-domain, add context to the _x()
functions, e.g. _x( 'Homepage', 'page title', 'slug' )
.
2) If 'slug'
is your context, then add the text-domain, the third parameter, to your translation functions as the text strings you have don't seem to be default texts and most likely won't be found in the default text-domain.
3) Switch to using for example __()
or esc_html__()
translation function, which only needs string
and text-domain
as parameters.
本文标签: Theme starter content translation is not working
版权声明:本文标题:Theme starter content translation is not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745198377a2647249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
_x
requires context to specified – user145078 Commented Aug 30, 2019 at 20:43