How to add WordPress Divi Theme localization?

916 views Asked by At

We're having trouble getting the localization to work on our WordPress site.

Our setup is as follows:

  • WordPress 4.0.1
  • Multi Site enabled
  • Divi Theme 2.1.4 (wanted to add Divi to tags, but Stack Overflow doesn't allow me)
  • Language Site 1: US English (en_US)
  • Language Site 2: Dutch (nl_NL)

Localization is working in the back-end, both in WordPress itself and the Divi Theme builder. However for example the search placeholder stays English. When I go and hack around in the code I find that I can change it in the header-file. But configuring it in the language file (both of WordPress itself and the Divi Language file) does not work.

1

There are 1 answers

3
O. Jones On

Without having access to this particular theme's codebase, it's difficult to know exactly what is going on.

But, in general, if a text string is to be localizable, it needs to show up in the template, or the plugin, or WordPress core as

__( 'Search by typing here...', 'divi' )

instead of

'Search by typing here....'

This explains it. https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/ It mentions plugins, but themes work the same.

If this theme implements the search placeholder, you may have discovered a defect in the theme. You can ask the developer to repair it, or you can make a child theme and repair it yourself. The developer will probably be happy to hear about your bug fix.

In a comment, you mentioned that there's a source code line saying:

esc_attr_x( 'Search …', 'placeholder', 'Divi' ),

If you look in the Divi plugin's source code directory, you will probably find a subdirectory called languages. Look in there for a nl-nl.po file, or perhaps a Divi.pot file containing the strings to be localized.

In there you will, hopefully, find some lines that look like this:

msgctxt "placeholder"
msgid "esc_attr_x( 'Search …"
msgstr ""

If you can fill in the msgstr string with the words you need (sorry, I don't know the Dutch language) then you can create or update your .mo file with poedit.

But many sites use a core-embedded Search widget to display the search box. Is it possible you're using a plugin of some kind to provide a custom search?