Embedding translatable strings in the template
From Joomla! Documentation
Revision as of 04:52, 24 August 2008 by Chris Davenport
In the template itself translations are handled using the JText static class. It is referred to as “static” because it does not require instantiation as an object before its methods may be used.
Simple text strings
Most text strings can be translated using the “_” (underscore) method. For example, suppose your template contains the English text “Welcome” which needs to be made translatable.
<?php echo 'Welcome'; ?>
Then you would replace the static string like this
<?php echo JText::_( 'Welcome' ); ?>
This would cause the translation system to search the appropriate language file for “WELCOME” on the left-hand side of an equals sign. The search is case-insensitive. If this language definition string is encountered
then the effect will be to output the string “Welcome!” to the browser. If the user switches to the German language then the German language definition file will be search for “WELCOME” and this time might encounter the string
and so “Wilkommen” will be sent to the browser. Importantly, if the user switches to German but there is no German language file present, or the appropriate string does not appear in the German language file, then Joomla will fall back to sending the untranslated string “Welcome” to the browser. <ninclude>