SV: translation patch
| From: | Tomas Sanchez Romani | Date: | Thu, 10 May 2001 10:37:20 +0000 |
| Subject: | SV: translation patch | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-715@lists.php.net to get a copy of this message | ||
Hi!
Look below for my comments
>> a) is smarty-configfiles a good place to put multiple-language-support,
or
>> do you have any better ideas for that.
>I send a patch to the smarty list a few months ago, when smarty-1.2 just
>came out, that added multiple-language support to smarty. It never got
>applied, but if you search in the archives you'll probably find it; it
>should not be too hard to port it to smarty 1.4. If you do, maybe you
>can submit it again to the list, maybe that it will be applied now.
>cheers,
>roel
Ok, after this introduction to the issue I have now created a custom
function 'translate' that (after the recomendations I read in the
mailing-list-archives) uses STPhp to translate the specified 'strId' (see
below).
---start of code:
--the function, to put in the end of Smarty.addons.php
function smarty_func_translate() {
extract(func_get_arg(0));
include ("../stphp/code/st/st.php");
global $LocalePath, $LocaleMechanism;
$LocalePath = $locPath ;//$args["locPath"];
$LocaleMechanism = $locMech ;//$args["locMech"];
eval (ST ($strId, "\$toStr", $locLang));
echo $toStr;
}
--how to make calls for it:
-in the script:
$smarty->assign("locLang", "sv");
$smarty->assign("locMech", "internalfile");
$smarty->assign("locPath", "c:/program/apache
group/apache/htdocs/cz2/inc/locale/");
-in the template:
{translate strId="hello" locLang=$locLang locMech=$locMech locPath=$locPath}
---end of code
Ok, this is problably not even close to the best solution, so is some one
feels like helping me out on this one, please do.
What I would like to improve is:
a) not needing to ' include ("../stphp/code/st/st.php"); ' every time.
b) some system to be able to automaticly generate static template files for
the different localed-versions of the static text, which the could easliy be
included depending on the users profile (or something).
thanks, sorry for the long letter, a&l, tomas