Hi,
I haven't tested neither of your solutions/suggestions yet (Markus, Mathew,
Hugues), even if they all look interesting.
Anyway, what Markus mentioned about using HTML::Parser is an approach that may
make things easier for the web designer.
What I'm looking for is an approach that would be as painless as possible for
all parts - both the programmer, web designer and translator.
On this list we're all programmers, so we know what's the best solution - for
the programmer.
I don't really know at what degree one should think and plan of the web
designer's and translator's tasks.
I do agree that storing the language phrases in a database is an elegant
solution.
But to me, as an example, telling the translator: "Please fill in the Italian
(Greek, Swahili, Klingon, Whatever) column in this Excel sheet I just sent to
you, export it as CSV, and then please upload the csv file to my database
server, which will incorproate your language in the application immediately."
is just equally one important part of an elegant solution.
Use a database to avoid .po files - easy for the programmer.
Tell the translator what to do, without assuming any programming skills.
The role of the web designer if more complicated.
Personally, I have only worked together with web designers who are very
focused on design, and not so much on HTML itself.
My personal taste has been more minimalistic (a UNIX programmer's disease? ;-)
than the web designer's, so the discussions/compromises have included
limiting graphics etc., but never programming issues related to the HTML
templates.
One alternative is to:
- Save a copy of the output from a web page in one language (in the
"undesigned" way I created the HTML template).
- Pass the copy to the web designer.
- Parse the re-designed page (through HTML::Parser) to replace the
words/phrases with the original <TMPL_VAR...> tags?
- Optionally, save a copy of the output from the (now redesigned) web page in
another language, and pass it to the web designer, just to assure her/him
that the same page looks fine in two different languages.
The other alternative is to ask the web designer to work directly with the
templates.
In this case, using this document (my example)...
----------------------------------------
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title><TMPL_VAR NAME=HELLO_WORLD></title>
</head>
<body>
<b><TMPL_VAR NAME=HELLO_WORLD></b>
<p><TMPL_VAR NAME=WELCOME_TO_THIS_WEB_SITE></p>
</body>
</html>
----------------------------------------
... or this document (Hugues' example)...
----------------------------------------
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title><TMPL_VAR EXPR="maketext('Hello, world!')"></title>
</head>
<body>
<b><TMPL_VAR EXPR="maketext('Hello, world!')"></b>
<p><TMPL_VAR EXPR="maketext('Welcome to this website.')"></p>
<!-- We could use H::T variables to have things like this : -->
<p><TMPL_VAR EXPR="maketext('We have [quant,_1,visitor] today',
visitor_count)"></p> </body>
</html>
----------------------------------------
... would both show a blank web page in Quanta's "preview mode", and some
yellow highlighted <TMPL_..> tags in DreamWeaver's preview mode.
While this may be enough for a more "HTML-focused" web designer, it is
definitely not the case for a more "design-focused" web designer.
Of course, this discussion about <TMPL_...> tags for the web designer isn't
only an issue for multiling�al web pages, but it is where it comes to an
extreme, as there is no common text at all in the HTML document, only
template tags all over.
Any comment and/or experiences (especially on working with web designers) are
appreciated.
Regards,
Johan
On Thursday 26 May 2005 07:31, Hugues de Mazancourt wrote:
> Hi all,
>
> I just finished the translation of web pages in our product (which uses
> H::T) from French to English, and now I'm *sure* that having as many
> template files as languages is definitely a bad idea (except if your
> product/site doesn't evolve anymore, which could not be a good news ;-). So
> i was looking for a different way of localizing my H::T
>
> I was thinking about a solution using HTML::Template::Expr and adding a
> function that would directly call maketext. I'm not sure it's really
> different from Matthew's solution (except for the difference between
> Locale::Maketext and Locale::Makephrase). In my idea, the template could
> look like:
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title><TMPL_VAR EXPR="maketext('Hello, world!')"></title>
> </head>
> <body>
> <b><TMPL_VAR EXPR="maketext('Hello, world!')"></b>
> <p><TMPL_VAR EXPR="maketext('Welcome to this website.')"></p>
> <!-- We could use H::T variables to have things like this : -->
> <p><TMPL_VAR EXPR="maketext('We have [quant,_1,visitor] today',
> visitor_count)"></p> </body>
> </html>
>
> With an appropriate H::T filter, the template could be more readable, for
> example using a {{ ... }} notation which would result in:
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title>{{Hello, world!}}></title>
> ...and so on.
>
> I didn't had time to implement it, but I guess this could work. Did someone
> try this ?
>
> Best,
>
> Hugues
>
>
> ----- Original Message -----
> From: "Mathew Robertson" <[EMAIL PROTECTED]>
> To: "Johan Kuuse" <[EMAIL PROTECTED]>
> Cc: <[email protected]>
> Sent: Thursday, May 26, 2005 12:50 PM
> Subject: Re: [htmltmpl] HTML::Template and Locale::Maketext
>
>
> Hi Johan,
>
> About 18 months ago I had a similar requirement, and thus eventually got
> around to looking at Locale::Maketext. One of the key points that the
> documentation makes, is that English is not a language that you should
> derive your second language from. One problem I had with L::M was that it
> still forces some of the "English is a base language" syndrome onto the
> programmer. I also like the idea of not needing to distribute .po files
> for every GUI change.
>
> So I created Locale::MakeText.
>
> Then I patch H::T so that it is capable of supporting custom TMPL_xxx tags.
>
> Then I wrote a module to combine the two.
>
> The end result is that my translations are:
> - stored in a database (whenever I do do a GUI update, translations can
> happen in real-time) - singular/plural aware (and the rest of the ideas
> mentioned in L::M) - I can create custom TMPL_xxx tags (which erally rocks
> for some situtations).
>
>
> You can find this information on my website:
> http://members.optusnet.com.au/mathew
>
> Hope this helps,
> Mathew
>
>
>
> ----- Original Message -----
> From: "Johan Kuuse" <[EMAIL PROTECTED]>
> To: <[email protected]>; <[email protected]>
> Sent: Thursday, May 26, 2005 3:40 AM
> Subject: [htmltmpl] HTML::Template and Locale::Maketext
>
>
> Hi,
>
> This is a long post, so feel free to stop reading now. :-)
>
> Anyone has used HTML::Template and Locale::Maketext together?
> Or HTML::Template in any I18N project?
>
> My doubts are mostly what approach I should use.
> The application I planning to start is not that big, but I always liked
> separating things:
> a. .pl files - For the Perl programmer.
> b. .html files - for the web designer
> c. .po and/or .pm files containing just languages hashes - for the language
> translator (ok, Perl hashes, but very readable even for a non-programmer)
>
> To keep things separated, there is a problem:
> 1. If, on one hand, I want to use one single HTML::Template for the output
> in different languages, the template itself cannot have any "fixed strings"
> in one languages, but has to be filled up only with <TMPL_VAR NAME=xxx>
> tags for every single message.
> This makes the job tougher for the web designer (the web page preview will
> be almost unreadable).
> 2. If, on the other hand, one HTML::Template per language, the translator
> has to know some HTML to create a HTML::Template with "fixed strings" in
> her/his language. And this means that the web designer will end up with one
> template per language, which also is undesirable.
>
> Any suggestions are appreciated.
>
> I will try explaining details of the problem by using a couple of examples:
>
> Approach 1, using one template for all languages:
> hello.pl
> # ----------------------------------------
> #!/usr/bin/perl -w
> use HTML::Template;
> use MyApp:I18N;
> my $locale = $ARGV || 'en'; # Use English as default
> my $lh = MyApp::I18N->get_handle($locale) || die "Can't get a language
> handle!";
> # open the html template
> my $template = HTML::Template->new(filename => 'hello.world.tmpl.html');
> # fill in some parameters
> $template->param(
> HELLO_WORLD => $lh->maketext("Hello, world!"),
> WELCOME_TO_THIS_WEB_SITE => $lh->maketext("Welcome to this web site."),
> );
> # send the obligatory Content-Type and print the template output
> print "Content-Type: text/html\n\n", $template->output;
> # ----------------------------------------
> hello.world.tmpl.html
> # ----------------------------------------
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title><TMPL_VAR NAME=HELLO_WORLD></title>
> </head>
> <body>
> <b><TMPL_VAR NAME=HELLO_WORLD></b>
> <p><TMPL_VAR NAME=WELCOME_TO_THIS_WEB_SITE></p>
> </body>
> </html>
> # ----------------------------------------
> MyApp/I18N/en.pm
> # ----------------------------------------
> package MyApp::I18N::es;
> # Spanish language messages
> use base qw(MyApp::I18N);
> use strict;
> use vars qw(%Lexicon);
> %Lexicon = (
> # Message to translator: Start here!
> "Hello, world!" => "Hello, world!",
> "Welcome to this website." => "Welcome to this website.",
> # Message to translator: Stop here!
> );
> # ----------------------------------------
> MyApp/I18N/es.pm
> # ----------------------------------------
> package MyApp::I18N::es;
> # Spanish language messages
> use base qw(MyApp::I18N);
> use strict;
> use vars qw(%Lexicon);
> %Lexicon = (
> # Mensaje a traductor: �Empieza aqu�!
> "Hello, world!" => "�Hola, mundo!",
> "Welcome to this website." => "Bienvenido a este sitio web.",
> # Mensaje a traductor: �Termina aqu�!
> );
> # ----------------------------------------
> MyApp/I18N/se.pm
> # ----------------------------------------
> package MyApp::I18N::es;
> # Swedish language messages
> use base qw(MyApp::I18N);
> use strict;
> use vars qw(%Lexicon);
> %Lexicon = (
> # Meddelande till �vers�ttaren: B�rja h�r!
> "Hello, world!" => "Hej, v�rlden!",
> "Welcome to this website." => "V�lkommen till den h�r webbsajten.",
> # Meddelande till �vers�ttaren: Sluta h�r!
> );
> # ----------------------------------------
>
>
> Approach 2, using one template per language:
> hello.pl
> # ----------------------------------------
> #!/usr/bin/perl -w
> use HTML::Template;
> my $locale = $ARGV || 'en'; # Use English as default
> my $filename = 'hello.world.tmpl.html.' . $locale;
> # open the html template
> my $template = HTML::Template->new(filename => $filename);
> # send the obligatory Content-Type and print the template output
> print "Content-Type: text/html\n\n", $template->output;
> # ----------------------------------------
> hello.world.tmpl.html.en
> # ----------------------------------------
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title>Hello, world!</title>
> </head>
> <body>
> <b>Hello, world!</b>
> <p>Welcome to this website.</p>
> </body>
> </html>
> # ----------------------------------------
> hello.world.tmpl.html.es
> # ----------------------------------------
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title>�Hola, mundo!</title>
> </head>
> <body>
> <b>�Hola, mundo!</b>
> <p>Bienvenido a este sitio web.</p>
> </body>
> </html>
> # ----------------------------------------
> hello.world.tmpl.html.se
> # ----------------------------------------
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <html>
> <head>
> <title>Hej, v�rlden!</title>
> </head>
> <body>
> <b>Hej, v�rlden!</b>
> <p>V�lkommen till den h�r webbsajten.</p>
> </body>
> </html>
> # ----------------------------------------
>
>
> Best Regards,
> Johan Kuuse
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
> online with coworkers and clients while avoiding the high cost of travel
> and communications. There is no equipment to buy and you can meet as often
> as you want. Try it free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=ick
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
> online with coworkers and clients while avoiding the high cost of travel
> and communications. There is no equipment to buy and you can meet as often
> as you want. Try it free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=ick
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
> online with coworkers and clients while avoiding the high cost of travel
> and communications. There is no equipment to buy and you can meet as often
> as you want. Try it
> free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=Click
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
--
Johan Kuuse
[EMAIL PROTECTED]
Thu May 26 07:52:39 2005
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users