Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#40172 closed defect (bug) (invalid)

Search form is not translated.

Reported by: dreamsorcerer's profile Dreamsorcerer Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.3
Component: I18N Keywords:
Focuses: ui Cc:


There are 3 translatable strings for the form field found here:

But, testing against Esperanto, which is 100% translated, these strings are not getting translated.

I can see that the label and input box will be translated if you remove the context (using __() instead of _x()), but I can see there is no translation for the placeholder in the .mo file.

Change History (6)

#1 @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hello @Dreamsorcerer, welcome to Trac!

Thanks for you report. I couldn't reproduce this issue. Please make sure that you have the latest translations installed. You can replace yours with the ones from

Themes like Twenty Seventeen are also using their own search form template so make sure that the theme translation is also updated (

#2 @Dreamsorcerer
7 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

OK, I've updated the translations, and I can see the translation exists in the .mo file. But, it is still not working, in fact, it doesn't look like the admin is translated either.

I've edited (temporarily) the form in general-template.php file, and can see the changes appear on the site, so it is definitely pulling the form from there.

I've tried disabling all plugins to no effect. Which theme are you using to test this on, so I can see if it is a problem with the theme? Or, any other suggestions where I might look for this?

#3 @SergeyBiryukov
7 years ago

  • Milestone set to Awaiting Review

#4 @Dreamsorcerer
6 years ago

OK, took some more time digging into this and finally got an idea of what is breaking. It seems that the parsing of the MO files is incorrect when a translation includes a msgctxt.

In regard to my original bug report, you will see in the eo.po file the below translation:

#: wp-includes/general-template.php:213
msgctxt "placeholder"
msgid "Search …"
msgstr "Serĉi …"

What happens is that at wp-includes/pomo/mo.php:265, $original is set to placeholder\x04Search ….

Which means that calling __('Search …') fails, as that key does not exist, however __('placeholder\x04Search …') works correctly.

Likewise, Contact and Blog appear under Theme starter content\x04Contact and Theme starter content\x04Blog respectively.

So, this explains why random parts of my site are not translated. It may also explain why you were unable to reproduce the issue, if your theme is using the Search string, as that translation works correctly for me. So, please confirm if you are now able to reproduce the issue by testing if __('Search …') returns the correct translation: Serĉi ….

This latest debugging session was done on WP 4.9.

Last edited 6 years ago by Dreamsorcerer (previous) (diff)

#5 @Dreamsorcerer
6 years ago

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

OK, I figured it out. The _x() function handles the context. But, something was hooked on gettext_with_context and messing up the translation.

#6 @dd32
6 years ago

  • Milestone Awaiting Review deleted

Thanks for following up @Dreamsorcerer!

Note: See TracTickets for help on using tickets.