[wp-trac] [WordPress Trac] #56059: register_post_type()'s "description" argument can't be translated (gettext)

WordPress Trac noreply at wordpress.org
Sat Jun 25 22:30:14 UTC 2022


#56059: register_post_type()'s "description" argument can't be translated (gettext)
-------------------------------+------------------------------
 Reporter:  andreacalligaris   |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  6.0
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by andreacalligaris):

 > At what time exactly does the register_post_type() call run?
 ''init'', like it's supposed to.
 > Can you check whether that string is translated by the time it is
 assigned to description?
 Just checked, it is not. Morever, the labels for the custom type, which
 are correctly translated on the website, are not translated too if I
 debug-print them in init:
 {{{#!php
 <?php
 function add_custom_post_types() {
         register_post_type( ... );
         ...
         error_log(print_r(esc_html__('Example string.',
 'my_child_theme_domain'), TRUE)); // doesn't translate
 }
 add_action('init', 'add_custom_post_types');
 ?>
 }}}

 So that's where the bug lies. And it's definitely a bug because the labels
 are correctly translated, so it makes sense to be able to translate the
 description too.

 > I think this might be a priority issue, e.g. the post type is being
 registered before the locale is set up or the text domain is loaded.
 It's weird that the labels are correctly translated, though, only the
 description fails. Anyway, it's something like that for sure.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56059#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list