This was one sort of scenario that prompted me to suggest and submit
the patch for search_path_on_include some time back.

My thoughts had been that I'd like messages to be customizable to the
language (or partner's site...) that the user was browsing on.  It
would require the application to set up the search path properly when
initializing the template object, but that seemed a fairly simple and
easy thing to do, as it was quite reasonable to assume the app would
know what site / language the user was browsing on.

The implementation would go something like this:

template files all exist in a "default" directory, and that directory
is always the last item in the search path.  If there is some
additional information available, say that the user is on a German
version of the site, you'd place that directory more forward in the
search path.

So, following that example, we'd have the ['german', 'default'] for the
search path, and the following files:

default/my_template.tmpl
default/errors/user_dne.tmpl
german/errors/user_dne.tmpl

default/my_template.tmpl would have something like the following in it:
"stuff before"
<TMPL_IF NAME="no_such_user">
  <TMPL_INCLUDE NAME="errors/user_dne.tmpl">
</TMPL_IF>
"stuff after"

default/errors/user_dne.tmpl would contain:
User Does Not Exist

and german/errors/user_dne.tmpl would contain (thanks Babelfish!):
Benutzer Besteht Nicht


when you load my_template.tmpl with the above search path and
search_path_on_include set to a true value, it will find the file
my_template.tmpl in default, see it's include, and grab the german
version of the included file, leaving you with an outputted page like:
"stuff before"
Benutzer Besteht Nicht
"stuff after"


If the german version of the error message didn't exist, the system
would then try searching in the default directory, so this setup makes
it very simple to slowly grow an existing site into a multilingual site
- if there's a translation available, it will use it, if not it will
keep to the default.

The downside, of course, is that if you've got a lot of pieces of text
on your site, you may end up with a whole lot of include files, which
may end up slowing your site down a bit.

hope you find that useful
 - Jody Biggs



--- simran <[EMAIL PROTECTED]> wrote:
> Hello All, 
> 
> I was curious to know how people are handling Localisation/Language
> support in HTML::Template's at the moment. 
> 
> The scenarios i can think of are:
> 
>
--------------------------------------------------------------------------
> 
> <tmpl_lang>User Does Not Exist</tmpl_lang>
> 
>
--------------------------------------------------------------------------
> 
> <tmpl_lang><tmpl_var name=error_msg></tmpl_lang>
> 
>
--------------------------------------------------------------------------
> 
> Both of the above should be translatable to the language via a data
> file
> of sorts that maps the strings to all the languages supported. 
> 
> How have people handled the above situation? 
> 
> Is there something inherit (or a sturucture) already in
> HTML::Tempalte
> that one can built on to build internationalisation? 
> 
> 
> simran.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to