Re: Multi-language and Smarty
| From: | Valerio Santinelli | Date: | Tue, 29 Jan 2002 09:52:54 +0000 |
| Subject: | Re: Multi-language and Smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2592@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Alain Fontaine - Consultant and developer" <alain@valain.com>
> I will shortly begin work on a very large portal-type site for a local
> city that has to be made available in at least 2, but probably more,
> languages. I will be using Smarty for this site. Have you already
developed
> multi-language sites using Smarty? What is the best approach?
Sure!
I've already developed a whole framework around Smarty and I created a
multi-language system that works nicely.
The core system detects your browser language and it stores it in a $lang
variable. (You can also override the language by passing the lang variable
in your URL). Next it loads a file containing the language strings
definition, with content like this:
$portal_lang["username"] = "Username:";
$portal_lang["password"] = "Password:";
$portal_lang["password_verify"] = "Password (verify):";
..and so on..
My core library has a set of functions to handle special collections like
$portal_lang, that are always available in templates, so you can place them
wherever you want them in your html with a string like
{$portal_lang.username}
I use a similar way to manage images, since you can have localized images,
too. In this case, the location of images is made up like this:
{$portal_info.server.url}templates/{$portal_info.app.theme}
You can see a working version of the library (called Portal API) on
http://portalapi.sourceforge.net/
--
Valerio Santinelli
HateSeed.com Founder (http://www.hateseed.com)
In Flames Italia Webmaster (http://www.inflames.it)
My Lab (http://tanis.hateseed.com)