$smarty
| From: | Aapo Laakkonen | Date: | Thu, 28 Feb 2002 13:10:18 +0000 |
| Subject: | $smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2891@lists.php.net to get a copy of this message | ||
Is this easy to fix in smarty?
{assign var="lang" value=$smarty.request.lang|lower|default:"fi"}
Gives me error:
Warning: Undefined index: lang in XXX on line X.
I think that it would be possible to do lang translations like this:
file: translations.conf
[en]
hello=Hello
[fi]
hello=Terve
file: index.php
<?php
require "Smarty.class.php";
$smarty = new Smarty;
$smarty->display("index.tpl");
?>
file: index.tpl
{assign var="lang" value=$smarty.request.lang|lower|default:"en"}
{config_load file="translations.conf" section=$lang}
{#hello#}
But it doesn't work. Do you have any other opinions on how to do site
with multiple languages using smarty. I have seen one example with
Pre-filters, but I did not like it, because those translations were not
located on centralized place.