[support] Localizing a template

J-P Stacey jp.stacey at torchbox.com
Fri Feb 27 09:29:21 UTC 2009


Hi Francesco,

> I did an Italian language website, I need now to provide it a multi
> language system, the only issue is that I need to change something in the
> main page.tpl.php for both languages.

The keywords you want are "locale" or "localization" (abbreviated 
sometimes to "l10n"). This is the process of making a website's content 
"local" for a particular site visitor.

First turn on the Locale module. Then, if your text is hardcoded, wrap 
it in the t() PHP function as follows:

	<p>My text</p>
	... becomes ...
	<p><?php print t('My text') ?></p>

Then, visit the page (so that t() calls locale() and registers that 
there is some text to translate). You should see no difference right now.

If you now go to admin/settings/locale you should see that you can 
define different languages, including a default one which in your case 
will be Italian. Any string that passes through the t() function is then 
able to be translated into other non-default languages.

Further docs:

  Locale module and localization:
    http://drupal.org/node/290 (note all the links at the bottom)
  t() function (technical):
    http://api.drupal.org/api/function/t/5
  Locale module (technical):
    http://api.drupal.org/api/file/modules/locale/locale.module/5

Cheers,
J-P


More information about the support mailing list