Help Center

Find answers or browse our knowledge base.

Add Languages

Ship your add-on with a language file and it will be auto-added to your main languages if /modules/{addonid}/languages/messages.po exists.

This function lets your addon ship its own messages.po file and automatically merge those translations into the site’s language files when the addon is activated.


 

How it works

  1. Checks if /modules/{addonid}/languages/messages.po is present.
  2. If found, reads its content and wraps it between markers:

# BEGIN {addonid} Addon Strings
...strings here...
# END {addonid} Addon Strings
  1. Loops through all locales under /content/languages/locale/*/LC_MESSAGES/messages.po.
  2. Appends the block into each file (skipping if already injected).

 

Where to place translations

  • Create /modules/{addonid}/languages/messages.po.
  • Fill it with msgid/msgstr pairs for every string you want to translate.

Example:


msgid "Author"
msgstr "Author"

msgid "Books"
msgstr "Books"

msgid "View Book"
msgstr "View Book"

 

How to use in code

In templates:


{__("Author")}: John Doe

{__("View Book")}

In PHP:


echo __("Author") . ": " . $author_name;

Important: For translations to work, all addon text must be wrapped in {__("")} in templates or __() in PHP, and the exact string must exist in your messages.po.


 

Best Practices

  • Keep msgid values exactly as they appear in your code ("Author", "Books", etc.).
  • Always provide at least an English messages.po as a fallback.
  • Use consistent text so translators don’t see duplicates (avoid mixing “Author” and “author”).
  • On deactivation, uninject_po_strings($plugin_name) removes the block between markers to keep language files clean.
Was this answer helpful?
You must login to vote.
0 found this helpful, 0 did not
Thank you for your feedback!

Related Articles