Can AI-tools help WordPress developers write more translation-friendly code?

A WordPress plugin may pass all the usual mechanical internationalization checks and still be surprisingly difficult to translate.

The strings are included via the WordPress’ gettext wrapper. The text domain is correct. Everything looks fine – until translators get stuck when a sentence has been assembled from several fragments, the English article “the” has been translated separately from its noun, or the same English word is used in two places where another language needs two different translations.

These are problems I’ve encountered repeatedly during my years as a WordPress translation contributor and Polyglots mentor.

In my article about common i18n pitfalls and my WordCamp Europe presentation in Athens, I tried to explain why technically internationalized code isn’t necessarily easy to localize.

Now I’m experimenting with a different approach: can we help AI coding assistants to better recognize these problems and help developers avoid them?

I’ve created an open-source WordPress i18n Helper Skill.

It’s a set of instructions and examples intended for AI coding assistants. Rather than simply checking whether the correct WordPress functions are used, it encourages the assistant to consider linguistic issues: how their string might behave when it gets translated to other languages, with different grammar, word order, plural rules, and conventions.

The skill has two modes:

  • REVIEW: Examine existing code, identify potential translation problems, explain why they matter, and suggest improvements without changing anything.
  • IMPROVE: Help implement corrections while respecting existing functionality and asking the developer when a decision requires more context.

One important goal is educational. I don’t just want an AI assistant to replace one piece of code with another. I want it to explain why the original construction could cause trouble for translators.

I’d love your help testing it

This is an early version, and I don’t yet know how reliably different coding assistants will follow its guidance.

If you’re developing for WordPress, perhaps building a plugin or theme, I’d be interested to hear what happens when you ask your coding assistant to review its internationalization using this skill.

And if you’re a translator, I’d especially welcome examples of code that was technically internationalized but made natural translation difficult or impossible.

What did the assistant recognize? What did it miss? Did it suggest anything unnecessary or potentially harmful? Are there linguistic problems that deserve better explanations?

You can share questions and examples in GitHub Discussions, open an issue for specific problems and suggestions, or contact me on the WordPress Slack.

The project is licensed under GPL-2.0-or-later, and contributions are welcome.

My hope is that this can tool can help developers create better code, that translators will be able to translate better, and help us catch internationalization problems at an earlier stage, even before translators get stuck.

Explore the WordPress i18n Helper Skill on GitHub

Leave a Reply

Your email address will not be published.

1 + sixteen =