Translation For Developers

This guide is aimed at Jaws core and gadget developers, if you are just translating Jaws you don’t need to read this. As a Jaws developer you don’t need to do much to get your strings translated into different languages thanks to the excellent translation team.

There are a few things that you need to do though, and a couple more to make life easier on the translators.

The Basics

The main element of Jaws translation is system is the _t function, which will take a string identifier such as BLOG_NAME and load the correct translation for the current user. Any strings that will be displayed in to end users should be given an ID and translated. The basic usage is:


_t will return the translated string, or the English version if it has not been translated.

String IDs are made up of the gadget name, followed by whatever you feel fits, such as:

  • CONTROLPANEL_PLUGINS: The plugins item in the control panel
  • BLOG_NEW_ENTRY: “New Entry” menu item for the blog
  • BLOG_ENTRY_NOT_DELETED: “There was a problem deleting the entry”

You then need to place the new string in html/gadgets/YourGadget/languages/en/YourGadget.php, prefixed with _EN, so _YOURGADGET_NAME becomes _EN_YOURGADGET_NAME. Each string is a constant definition, so the full code for creating YOURGADGET_NAME is:

define('_EN_YOURGADGET_NAME', "Your Gadget"); // Gadget name


You can use placeholders in your strings to insert custom strings into a translation, for example if you wanted to include the title of an item in the string.

You can do this using {0}, {1}, {2} etc. where you want the replacement to be made. You then pass the strings you want included as extra arguments to _t(), such as _t(’_YOURGADGET_DISPLAY_ITEM_LINK’, $itemTitle);

If _YOURGADGET_DISPLAY_ITEM_LINK was “Display {0}”, then it may come out as “Display Summary” if the item was called Summary.

You can also translate items to be replaced, such as _t(’YOURGADGET_DISPLAY_TITLE’, _t(’YOURGADGET_HOME’)), which will place the translation of YOURGADGET_HOME in {0}.

Helping Translators

When you are writing the English translation files try to make things easy on the translation team and comment your translation, describing where each string can be found, and what any placeholders are. For example:

define('_EN_YOURGADGET_NAME', "Your Gadget"); // Gadget name
define('_EN_YOURGADGET_DISPLAY_ITEM_LINK', "Display {0}"); // The text for item links. {0}: The title of the item.
  /var/www/wiki/htdocs/data/jaws/development/languages/fordevelopers.txt · Last modified: 2007/11/02 16:27