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.
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, and any number of extra parameters to insert into the translated string.
The extra parameters are inserted into the translated string at the defined points. We define these points using type specifiers; this is identical to using the PHP sprintf...