[stringtemplate-interest] Re: ST & I18N
Terence Parr
parrt at cs.usfca.edu
Tue Nov 15 11:40:21 PST 2005
On Nov 7, 2005, at 9:28 PM, polina orechko wrote:
> I would like to add my 0.02c to this topic since I was about to ask
> questions similar to Frank's ones.
>
> I was thinking about suggesting
> 1) adding a special option/flag to StringTemplate (or a special
> attribute) - Locale, which would make ST do some i18n-aware things,
> more specifically
Hi. It's possible, but remember that usually the controller should
be sensitive to locale and either push in different data or
specifically tell ST to render things with a new renderer object.
> 2) use the standard Java approach for loading locale-specific
> resources (in our case templates) - try first the most specific
> localized template (again, several options are possible, one of
> them would be to use a naming convention, such as
> myTemplate_en_US.st and the naming convention would be activated
> only by presence of Locale), if not found, try to load
> myTemplate_en.st, and if not found, then use myTemplate.st.
This could work, but isn't it easier to just have a different
StringTemplateGroup directory for each locale and then the controller
(the web server) can simply set the pointer to the appropriate group
depending on locale. ST should not even know that something has
changed. :)
> The reasons for this suggestion as opposed to using locale-specific
> groups with messages as Ter has suggested are:
> 1) in a web app we sometimes would want to localize entire
> templates, not just messages (sometimes we may need layout changes,
> etc. and it would be simpler to do that on "template" level, as
> opposed to factoring out all messages and other locale-dependent
> things into another level of templates and setting a "locale"
> attribute to switch on it)
Yep, with the group you can have ALL templates associated with a site
translated. You don't have to factor out the stuff that can change. :)
> 2) sometimes we would want to translate only some templates, and
> some templates would be locale independent (such as "a" tag
> generation)
You can use template group inheritance to make this work. Just
define a new group as it differs from the supergroup :)
> As far as I understand, this approach would impact only template
> resolution (i.e loading) mechanism.
Yep, but I have the group thing to handle all this for you. Note
that jGuru has radically different looks for premium members and
guests; only the group pointer changes :)
> Just an idea, do you think something along this lines would make
> sense?
Makes sense, but what do you think of my suggestion above?
Ter
More information about the stringtemplate-interest
mailing list