Make WordPress Core

Opened 8 weeks ago

Last modified 8 weeks ago

#43864 new defect (bug)

A comment inside an i18n function will cause makepot/extract.php to miss the string

Reported by: julesaus Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: I18N Keywords: has-patch has-unit-tests
Focuses: Cc:


If you put a comment inside a translation function, makepot misses the entire string. For example, none of these strings will appear in a generated pot file:

__( /* */ 'missing' );

  'multiline missing'

  // translators: This seems like a reasonable place to put a comment
  'A reasonable looking example'

You might pop the attached test-file.php into test-dir/ and run php ../makepot.php generic $PWD /dev/stdout; echo; if you'd like to see it yourself.

This is valid PHP and gettext handles this syntax fine, so it can be quite tricky to recognize the problem when it occurs.

Attachments (2)

extract-inline-translator-comments.patch (2.4 KB) - added by julesaus 8 weeks ago.
test-file.php (238 bytes) - added by julesaus 8 weeks ago.
Some example problematic strings

Download all attachments as: .zip

Change History (3)

8 weeks ago

Some example problematic strings

#1 @julesaus
8 weeks ago

  • Version set to trunk

Props @akirk for test_find_function_calls_with_inline_c_style_comment()

Note: See TracTickets for help on using tickets.