O'Reilly logo

Mastering Joomla! 1.5 Extension and Framework Development by Chuck Lanham, James Kennard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Translating

A major strength of Joomla! is its built-in multilingual support. Joomla! has special language handling classes that translate strings. The default language is configured in the Language Manager. The language can be overridden by a logged-in user's preferences.

Translating text

We use the static JText class to translate text. JText has three methods for translating text: _(), sprintf(), and printf(). The method that we use most is _(). This method is the most basic; it simply translates a string.

The next example outputs the translation of Monday; if a translation cannot be found, the original text is returned:

echo JText::_('Monday');

The JText::sprintf() method is comparable to the PHP sprintf() function. We pass one string to translate, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required