Make WordPress Core

Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#54875 closed defect (bug) (invalid)

WordPress not honoring translations of _x() label functions of custom post type

Reported by: twinpictures's profile twinpictures Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: I18N Keywords:
Focuses: Cc:

Description (last modified by sabernhardt)

_x() is not working although properly formatted and translated. changing to __() resolves the issue. More on this issue:
https://stackoverflow.com/questions/58154024/wordpress-not-honoring-translations-of-x-label-functions-of-custom-post-type

Change History (5)

#1 @swissspidy
23 months ago

Hi there and welcome to WordPress Trac

Could you please share the POT and PO files you have generated?

I assume that the culprit is with those, not WordPress

#2 @sabernhardt
23 months ago

  • Description modified (diff)

#3 @twinpictures
23 months ago

to set it:

<?php
_x( 'Event Category', 'taxonomy general name', 'my_domain' ),

in the .po file:

#: inc/file.php:120
msgid "Event Category"
msgstr "Veranstaltung Kategorie"

I now assume that the context of taxonomy general name needs to be provided, however I have found no documentation on this under https://developer.wordpress.org/reference/functions/_x/
I look forward to finding the error of my ways.

#4 @twinpictures
23 months ago

  • Resolution set to invalid
  • Status changed from new to closed

found the issue. _x needs to have the 'context' defined using msgctxt like so:

#: inc/file.php:120
msgctxt "taxonomy general name"
msgid "Event Category"
msgstr "Veranstaltung Kategorie"

Issues is resolved, just not well documented.

#5 @SergeyBiryukov
23 months ago

  • Milestone Awaiting Review deleted

Thanks for the follow-up!

Note: See TracTickets for help on using tickets.