In the past, I’ve had some difficulty getting all of the text used in the Book Review plugin into the book-review.pot file, which is the file translators use to translate the plugin into other languages. This is a pretty important step, as having the plugin available in as many languages as possible means that it will appeal to a much wider audience.

I had tried both the built-in translation tool on wordpress.org, as well as the WordPress i18n tools, without success – some strings, although properly wrapped in __ or _e function calls, just weren’t being picked up.

The Bane of Concatenation

Upon investigating, I found that only the longer pieces of text were missing. After digging a little deeper and trying different things, I spotted the problem. The code was concatenating longer strings like so:

_e( 'Configure the links that you would like to display with every ' .
'book review. For every link added here, a new field will be shown ' .
'in the Book Info section when editing a post.', $this->plugin_name );

Unfortunately, this completely confused the tools I was using to create the translation file. To resolve it, I got rid of those naughty concatenation operators and just used a single string:

_e( 'Configure the links that you would like to display with every book review. For every link added here, a new field will be shown in the Book Info section when editing a post.', $this->plugin_name );

Sure enough, this change ensured that the next time I ran the plugin through the i18n tool, the generated book-review.pot file included all of the translatable text, even those pesky long strings.

I suppose the lesson here is to never assume that the tools you’re using are smarter than they actually are!

Interested in translating the Book Review plugin to another language? To get started, please follow the instructions available in the documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *