Wednesday, June 03, 2020

Sunday, January 12, 2020

Wordpress DIVI Theme internationalization - evaluation and issues

Website localization is better done when websites are internationalized. Wordpress uses the GNU Translation Project gettext utility for internationalization (i18n) and at the time of this writing most professional plugins and themes use gettext .po files to define localization (l10n) strings (AKA localizable text) in plain text and .mo files that are a machine representation of the .po files to aid gettext with the optimal replacement of the strings.

The main issue with current plugins and themes is that they fail to localize all their pieces driving most developers to look for alternatives that would instead push them to duplicate websites. But we, as software engineers, know that most of the time reusability is king and to achieve it we need to get back to the roots: be simple (use gettext) and precise (help the theme or plugin author to internationalize).

Here is what I patched this weekend in the Divi plugin. I hope the Divi team will read this and incorporate these fixes (or alike). There are so many people looking for answers to these problems and at the end the solution is not simple for them (as they have to go out there and purchase yet another plugin) neither precise (as no patch is offered to work with these themes and plugins as they are without the need to add a Wordpress translation plugin).

I am all for the use of translation plugins but one size does not fit all and being able to control your own destiny is sometimes (arguably all times) very important.

For those Wordpress Divi users that want to control their own destiny here are the patches needed to make some of the most common Wordpress Divi modules fully localized:
  1. Divi Tabs module: The tab title is not internationalized. To fix it file includes/builder/module/Tabs.php needs to use esc_html__ on each value of each $tab_title array inside function get_tabs_nav()
  2. Divi Button Module: The button title is not internationalized. To fix it, file includes/builder/module/Button.php, function render() should assign to button_text the i18n value using the esc_html__() function:
  3. Divi Blurb Module: The Blurb title is not internationalized. To fix it, file includes/builder/module/Blurb.php, function render() should assign to the blurb title the i18n value using the esc_html__() function (and others because for this case the actual plain text title is a protected member of an object):
  4. Divi Post Title Module: The Post Title title is not internationalized. To fix it, file includes/builder/module/PortTitle.php, function render() should assign to $post_title the i18n value using the esc_html__() function: BTW if you are looking to translate your website, internationalized or not, and do not have the workforce to do it (engineers, linguists etc) I strongly recommend Protranslating. Not only you will get full support from very talented people, but you will be in very good hands from a security and privacy standpoint.

    Full Disclosure: I work for Protranslating but the opinions expressed in all of my posts are not necessarily those of my employer.

Followers