Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#54875 closed defect (bug) (invalid)

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

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

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
5 years 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
5 years ago

  • Description modified (diff)

#3 @twinpictures
5 years 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
5 years ago

  • Resolution → invalid
  • Status new → 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
5 years ago

  • Milestone Awaiting Review

Thanks for the follow-up!

Note: See TracTickets for help on using tickets.