This method allows us to inject code directly into a
document header.
Imagine we want to add a comment to the document header:
$comment = '';
$document->addCustomTag($comment);
??? ???
Customizing the Page
[ 264 ]
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.
This 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.
Pages:
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363