Re: More ideas for translation support (long)

From: Date: Mon, 23 Jul 2001 21:17:25 +0000
Subject: Re: More ideas for translation support (long)
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1263@lists.php.net to get a copy of this message
Hans-Peter Oeri wrote:
yeah, but I set a smarty variable defining the current language, and always {include file="lang:$LANG.foo.tpl"}
OK, that should work. But what if you actually try to use the lang: resource AND something else than files? Wouldn't that mean to write a lang: handler for each other resource? I don't get it. What is your point?
What I think we must insist on, is a compiled version per language (for performance reasons).
I aggree.
Now let's say we change the main engine in a way that some "special" variables distinguish different compiled versions. Just a sketch of the idea: We define a list of variables that determine (somehow) distinctively pre-filtered versions... Let's say we call it prefilter_vars. We have then the following situations: a) prefilter_vars is empty Everything works as usual b) prefilter_vars is { "LANG" } smarty does compile distinct versions for each value of $LANG and stores them, let's say in different subdirectories ( en/foo.tpl, de/foo.tpl ) c) prefilter_vars is { "LANG", "X" } Now we can even enhance that scheme to multiple variables! (corresponding to a two level directory hierarchy...) What do you think of that? You wouldn't need to write different resource handlers as we don't touch them... filters won't work because there is one to one mapping between template
names and compiled scripts names. You would have to modify Smarty to compile results in different directories depending on the language setting. That should be relatively easy to do but would mean that a sort of half way support for translation: your application handles the actual translation and Smarty handles the compilation into specific directories. Not very clean IMHO Using resources as I described earlier, you have a single template file. And you say '->fetch("lang:en.foo.tpl")' or '{include file="lang:en.foo.tpl"}' to get it in english and so on. You could also do '->fetch("en:foo.tpl")' and have a resource handler for each language, but that would probably mean duplicate code. I'm not quite done yet, but I'll publish my code in HPE [1] by the end of the week... Mike [1] http://sourceforge.net/projects/hpe/

« previous php.smarty.general (#1263) next »