Re: [SMARTY] Multilangual support for websites
| From: | Ubaldo Huerta | Date: | Fri, 31 May 2002 16:19:11 +0000 |
| Subject: | Re: [SMARTY] Multilangual support for websites | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4485@lists.php.net to get a copy of this message | ||
A variation on this theme that has proved very useful for me is
the following:
foo.tpl
{ config_load file=_foo.conf section=$lang }
{#copyright#}
_foo.conf
copyright = untranslated
[english]
copyright = Copyright 2002 All rights reserved
[spanish]
copyright = Copyright 2002 Todos los derechos reservados
[catala]
copyright = Copyright 2002 Todos los derechos sin traducir
foo.php
$smarty->assign("lang","spanish");
$smarty->display("foo.tpl");
Mucha suerte
Ubaldo
From: Ben Godfrey <ben@hypothetical.co.uk> To: smarty-general@lists.php.net CC: smarty-general@lists.php.net Subject: Re: [SMARTY] Multilangual support for websites Date: Fri, 31 May 2002 11:45:42 +0100 This isn't a best practice suggestion, it's just a random idea, but I think that config files sound like a great solution to localisation. Stick all your data in there and load the right one by assigning a language template variable from the PHP: $smarty->assign("language_config", "config/$language.cfg"); {config_load file=$language_config} Ben On Friday, May 31, 2002, at 11:06 AM, LIMBOURG Arnaud wrote:_________________________________________________________________ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.comOne way is to have templates for each language and structure them like: mytemplatesdir/ en/ main.tpl fr/ main.tpl es/ main.tpl You define a var on script execution like $mylang and do $smarty->display($mylang . "/main.tpl); Arnaud.-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpAre there any best practices or code-examples on supporting multilangual templates? The kind of solution I'm working on at the moment is as follows:-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php[ show_users.tpl ] include [ app_header.tpl ] include [ app_footer.tpl ]Every tpl contains certain language-specific elements. However, I don't like to create a tpl for every language (and any browser). Instead I created a Smarty-function that retrieves content for the language elements in the requested language. This function uses tpl-specific files for caching, which are exported managed from a central database. This database is managed by the client using a webfrontend. In this way * templates are not language-specific, just define layout and interaction * language elements are bind to a specific (included) template If anyone is busy working on the same topic and like to exchange thoughts, feel free to toss your ideas this way =) Grtz! -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php