Re: [SMARTY] i18n
| From: | Greg Stark | Date: | Fri, 25 Apr 2003 18:31:43 +0000 |
| Subject: | Re: [SMARTY] i18n | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9378@lists.php.net to get a copy of this message | ||
Linus McCabe <linus@mccabe.nu> writes:
> I use gettext for translations. This requires php with gettext extensions
> and can be a bit of a pin to get working if you never used gettext before.
> In php youll have functions like gettext() and dgettext() to do the
> translation, for smarty, you can make a function or compiler function that
> uses gettext. If you use a compiler function, translation will be dnoe att
> compile time and you must use your language identifier as a part of the
> compile key.
Ok, I'm starting to actually implement this here. But I have some questions.
How do you actually compile the catalog files? Since the templates won't have
_("foo") patterns in them how do you get gettext to recognize
{translate}foo{/translate} blocks.
Also, don't you find it cumbersome having to write out {translate} tags all
the time? Even when I do {_}foo{/_} or {_ text="foo"} I still find it too
cumbersoem.
I'm thinking of creating a prefilter to transform [[foo]] to the translated
version of "foo". This would be even better than a compiler function because
then i wouldn't have constructs like <% echo "foo" %> strewn through the
compiled templates. Instead I would just have "foo" and "fooé" in the compiled
templates themselves.
But then how do I get gettext to find all the [[..]] escapes, especially when
they span lines?
And ideally I would prefer to use just [..] but I can't because prefilters are
run before removing {literal} and {php} blocks and they include the smarty
tags, so I would have to check for them which would be a pain.
I think it would be useful if there was another kind of filter, say,
contentfilters that only got called on the non-{literal} non-{php} and
non-smarty-tag content.
--
greg