html-template-users Mailing List for HTML::Template (Page 32)
Brought to you by:
samtregar
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(42) |
Jul
(80) |
Aug
(77) |
Sep
(97) |
Oct
(65) |
Nov
(80) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(63) |
Feb
(47) |
Mar
(45) |
Apr
(63) |
May
(67) |
Jun
(51) |
Jul
(78) |
Aug
(37) |
Sep
(45) |
Oct
(59) |
Nov
(50) |
Dec
(70) |
2004 |
Jan
(23) |
Feb
(90) |
Mar
(37) |
Apr
(53) |
May
(111) |
Jun
(71) |
Jul
(35) |
Aug
(58) |
Sep
(35) |
Oct
(35) |
Nov
(35) |
Dec
(20) |
2005 |
Jan
(51) |
Feb
(19) |
Mar
(20) |
Apr
(8) |
May
(26) |
Jun
(14) |
Jul
(49) |
Aug
(24) |
Sep
(20) |
Oct
(49) |
Nov
(17) |
Dec
(53) |
2006 |
Jan
(12) |
Feb
(26) |
Mar
(45) |
Apr
(19) |
May
(19) |
Jun
(13) |
Jul
(11) |
Aug
(9) |
Sep
(10) |
Oct
(16) |
Nov
(17) |
Dec
(13) |
2007 |
Jan
(9) |
Feb
(12) |
Mar
(28) |
Apr
(33) |
May
(12) |
Jun
(12) |
Jul
(19) |
Aug
(4) |
Sep
(4) |
Oct
(5) |
Nov
(5) |
Dec
(13) |
2008 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(16) |
May
(3) |
Jun
(1) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
(9) |
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
(6) |
Jul
(5) |
Aug
(3) |
Sep
(7) |
Oct
(1) |
Nov
(15) |
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(3) |
Mar
|
Apr
(28) |
May
|
Jun
|
Jul
(3) |
Aug
(4) |
Sep
(3) |
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Mathew R. <mat...@re...> - 2005-06-28 22:39:18
|
> HTML::Template works for anything as you all know. The trouble I'm > having is that WML needs more escaping than good old HTML (WML turned > out to be a templating language in itself with user agent performing > simple variable substituition in the document). >=20 > As far as I understand the only way to add an ESCAPE filter is to > hack _parse method (subclassing or just patching). Looks like > ESCAPE filters are all hardwired and spread over the code of the = method. >=20 > Did anyone face these problems? Or is WML that dead and no one cares > about it anymore? :) I also found that it was quite hard to plugin custom ESCAPE types - so I = modified my copy of H::T so that the escaping code is handled by = subclasses of a new H::T::ESCAPE module. The idea is that you subclasss H::T::ESCAPE, then submit the new = escape-type back for everyone else to use. You can download my version of H::T here: = http://members.optusnet.com.au/mathew Hope this helps, Mathew |
From: Kapoor, N. <nis...@xc...> - 2005-06-28 17:20:51
|
I am looking to populate my template loop by assigning it the entire = resultset in one shot as follows: =20 my $str =3D "SELECT \@row:=3D\@row+1 as row, <fields> FROM <tables> = WHERE ..."; my $sth =3D $conn->prepare($st); $sth->execute(); my $dataArr =3D $sth->fetchall_arrayref( {} ); $template->param(dataLoop =3D> $dataArr); I am getting NULL for row. The solution suggested by following thread = does it for command line, but I need to run it from inside my perl = script. http://lists.mysql.com/mysql/185626 a) SET @row=3D0; b) SELECT (@row:=3D@row+1) AS row, ename, empno FROM emp ORDER BY empno; And I don't know how to run both (a) and (b) together in one statement. = Running just (b) is what is producing NULL for row. Thanks for your help, Nishi |
From: Philip T. <phi...@gm...> - 2005-06-28 17:09:43
|
Sometime Today, RR cobbled together some glyphs to say: > The problem I am facing is, If the user refreshes or does anything, > nothing will happen and everything works fine, but when the user > places cursor at the address bar and presses Enter, then the page is > getting redirected to login page asking the user to login again. > > Can someone help me in this regard? I guess you've got to learn to deal with sessions and cookies. CGI::Session could help. CGI:Application, built over HTML::Template could also help. -- Immobility is often mistaken for peace. -- EMPEROR ELROOD CORRINO IX |
From: Rajesh R. <raj...@gm...> - 2005-06-28 14:51:05
|
Hi I am using HTML::Templating system for my project and the requirement is,= =20 URL given at the address bar should not be changed throughout the=20 application, I could able to achieve this and works fine for me (I have a= =20 login page and users have to login to access the application). The problem I am facing is, If the user refreshes or does anything, nothing= =20 will happen and everything works fine, but when the user places cursor at= =20 the address bar and presses Enter, then the page is getting redirected to= =20 login page asking the user to login again. Can someone help me in this regard? Thanks, Rajesh |
From: Alex K. <ka...@ra...> - 2005-06-28 14:29:31
|
Good day. HTML::Template works for anything as you all know. The trouble I'm having is that WML needs more escaping than good old HTML (WML turned out to be a templating language in itself with user agent performing simple variable substituition in the document). As far as I understand the only way to add an ESCAPE filter is to hack _parse method (subclassing or just patching). Looks like ESCAPE filters are all hardwired and spread over the code of the method. Did anyone face these problems? Or is WML that dead and no one cares about it anymore? :) -- Alex Kapranoff, $n=["1another7Perl213Just3hacker49"=~/\d|\D*/g]; $$n[0]={grep/\d/,@$n};print"@$n{1..4}\n" |
From: Dave W. S. <dw...@da...> - 2005-06-26 05:24:23
|
Mathew Robertson writes: > You could sub-class H::T then overload param() to do whatever you > needed to do. > > Would this help? Sometimes params are destined for an ESCAPE=HTML tag, and sometimes they're headed for one that's ESCAPE=0, and param() isn't in a position to know which. If you override param() to use HTML::Entities::encode_entities(), you have to stick with ESCAPE=0 in your templates, lest you get double encoding of '&'. We opted to patch HTML::Template to do the escaping for us. I submitted a patch for this a while back (and a co-worker submitted a corrected patch to fix the detail I missed). The patch will be in the archives somewhere. We've been using the patch in production for nearly a year, and are happy with it. An alternative would be to run the ->output() through HTML::Entities::encode_entities() before printing (taking care to not mangle HTML). Dave |
From: Dan H. <dan...@re...> - 2005-06-23 23:46:34
|
Could do. I'll look into it... cheers Dan > -----Original Message----- > From: Mathew Robertson [mailto:mat...@re...] > Sent: Friday, 24 June 2005 11:44 > To: dan...@re... > Cc: HTML::Template users > Subject: Re: [htmltmpl] Encode parameters (feature request?) > > > You could sub-class H::T then overload param() to do whatever > you needed to do. > > Would this help? > Mathew > > ----- Original Message ----- > From: "Dan Horne" <dan...@re...> > To: "'Mathew Robertson'" <mat...@re...> > Sent: Friday, June 24, 2005 9:07 AM > Subject: RE: [htmltmpl] Encode parameters (feature request?) > > > > My understanding is that this belongs in the template tags. > I'm hoping > > for an option that can help simplify things in one place... > > > > Dan > > > > > -----Original Message----- > > > From: Mathew Robertson [mailto:mat...@re...] > > > Sent: Friday, 24 June 2005 11:01 > > > To: dan...@re... > > > Subject: Re: [htmltmpl] Encode parameters (feature request?) > > > > > > > > > have you tried using the ESCAPE option to TMPL_VAR? > > > > > > Mathew > > > > > > ----- Original Message ----- > > > From: "Dan Horne" <dan...@re...> > > > To: <htm...@li....> > > > Sent: Friday, June 24, 2005 8:39 AM > > > Subject: [htmltmpl] Encode parameters (feature request?) > > > > > > > > > > I guess this is a new feature request, but I'd like to > be able to > > > > encode the parameters passed to HTML::Template > automatically. So > > > > instead of > > > > > > > > use HTML::Entities; > > > > .. etc .. > > > > > > > > $template->param('my_content', encode_entities($my_content)); > > > > > > > > I'd like to be able to do: > > > > > > > > my $template = HTML::Template->new( > > > > filename => 'file.tmpl', > > > > encode => 1 > > > > ); > > > > > > > > Regards > > > > > > > > Dan > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > SF.Net email is sponsored by: Discover Easy Linux Migration > > > Strategies > > > > from IBM. Find simple to follow Roadmaps, straightforward > > > > articles, > > > > informative Webcasts and more! Get everything you need > to get up to > > > > speed, fast. > http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > > > > _______________________________________________ > > > > Html-template-users mailing list > > > > Htm...@li... > > > > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > > > > > > > > > > |
From: Mathew R. <mat...@re...> - 2005-06-23 23:45:13
|
You could sub-class H::T then overload param() to do whatever you needed = to do. Would this help? Mathew ----- Original Message -----=20 From: "Dan Horne" <dan...@re...> To: "'Mathew Robertson'" <mat...@re...> Sent: Friday, June 24, 2005 9:07 AM Subject: RE: [htmltmpl] Encode parameters (feature request?) > My understanding is that this belongs in the template tags. I'm hoping = for > an option that can help simplify things in one place... >=20 > Dan >=20 > > -----Original Message----- > > From: Mathew Robertson [mailto:mat...@re...]=20 > > Sent: Friday, 24 June 2005 11:01 > > To: dan...@re... > > Subject: Re: [htmltmpl] Encode parameters (feature request?) > >=20 > >=20 > > have you tried using the ESCAPE option to TMPL_VAR? > >=20 > > Mathew > >=20 > > ----- Original Message -----=20 > > From: "Dan Horne" <dan...@re...> > > To: <htm...@li....> > > Sent: Friday, June 24, 2005 8:39 AM > > Subject: [htmltmpl] Encode parameters (feature request?) > >=20 > >=20 > > > I guess this is a new feature request, but I'd like to be able to=20 > > > encode the parameters passed to HTML::Template automatically. So=20 > > > instead of > > >=20 > > > use HTML::Entities; > > > .. etc .. > > >=20 > > > $template->param('my_content', encode_entities($my_content)); > > >=20 > > > I'd like to be able to do: > > >=20 > > > my $template =3D HTML::Template->new(=20 > > > filename =3D> 'file.tmpl',=20 > > > encode =3D> 1 > > > ); > > >=20 > > > Regards > > >=20 > > > Dan > > >=20 > > >=20 > > >=20 > > > ------------------------------------------------------- > > > SF.Net email is sponsored by: Discover Easy Linux Migration=20 > > Strategies=20 > > > from IBM. Find simple to follow Roadmaps, straightforward = articles,=20 > > > informative Webcasts and more! Get everything you need to get up = to=20 > > > speed, fast. = http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dclick > > > _______________________________________________ > > > Html-template-users mailing list=20 > > > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/html-template-users > > >=20 > >=20 >=20 > |
From: Dan H. <dan...@re...> - 2005-06-23 22:39:56
|
I guess this is a new feature request, but I'd like to be able to encode the parameters passed to HTML::Template automatically. So instead of use HTML::Entities; .. etc .. $template->param('my_content', encode_entities($my_content)); I'd like to be able to do: my $template = HTML::Template->new( filename => 'file.tmpl', encode => 1 ); Regards Dan |
From: Rajesh R. <raj...@gm...> - 2005-06-08 05:43:12
|
I am learnign the HTML Templating system. Can anyone guide me how to user= =20 multiple loops, I could able to use one loop and get the data, I would like= =20 to use multiple loops, Plase suggest Rajesh |
From: Paul S. <wre...@ya...> - 2005-06-02 12:17:20
|
Ok. I see that the latest version of H:T 2.7 references the loop context vars as all lower case, which is on point. It's the documentation on sourceforge, which google lists first for HTML::Template :-), that is misleading - I guess sourceforge will catch up to the recent documentation or fade away... Anyway, I did happen to find an error in the documentation while copying and pasting code. Under loop_context_vars section, there's a closing TMPL_IF that is missing the slash. Here's a patch for the 2.7 docs (I'm not sure if this is the place to post such patches): @@ -762,7 +762,7 @@ Example: <TMPL_IF NAME="__last__"> This only outputs on the last pass. - <TMPL_IF> + </TMPL_IF> </TMPL_LOOP> BTW, I've been using H:T for a number of years. It's perfect. Thanks. Paul --- Sam Tregar <sa...@tr...> wrote: > On Wed, 1 Jun 2005, Paul Simon wrote: > > > The HTML::Template doc says to use __FIRST__, > > __LAST__, __INNER__, __ODD__ as the loop context > vars. > > They did not work for me until I used the > > (undocumented) lower case __first__, __last__ > etc. > > I'm guessing because I have case_sensitive set to > true > > that this may have affected things? > > Yup, there should be something in the docs to > explain what case > they'll be when case_sensitive is in effect. > > > What can I do to fix this? > > Patches welcome. > > -sam |
From: Sam T. <sa...@tr...> - 2005-06-02 04:13:14
|
On Wed, 1 Jun 2005, Paul Simon wrote: > The HTML::Template doc says to use __FIRST__, > __LAST__, __INNER__, __ODD__ as the loop context vars. > They did not work for me until I used the > (undocumented) lower case __first__, __last__ etc. > I'm guessing because I have case_sensitive set to true > that this may have affected things? Yup, there should be something in the docs to explain what case they'll be when case_sensitive is in effect. > What can I do to fix this? Patches welcome. -sam |
From: Paul S. <wre...@ya...> - 2005-06-02 03:29:35
|
Hi The HTML::Template doc says to use __FIRST__, __LAST__, __INNER__, __ODD__ as the loop context vars. They did not work for me until I used the (undocumented) lower case __first__, __last__ etc. I'm guessing because I have case_sensitive set to true that this may have affected things? Regardless, the documentation is misleading or the code needs to respect these vars as UPPER case all the time... I'm using $HTML::Template::VERSION = '2.7'; Anybody else notice this? What can I do to fix this? Paul |
From: Mathew R. <mat...@re...> - 2005-05-27 08:55:43
|
> For example you could use {{ ... }} to hide <TMPL_VAR = EXPR=3Dmaketext('...')>. This could yield to: > > <p>{{We have [quant,_1,visitor] today,, visitor_count}}></p> = </body> The syntax of: We have [quant,_1,visitor] today was one of the my dislikes of Locale::Maketext. Locale::Maketext assumes that the programmer knows: a) the method to call; this case 'quant' (is there ever any other method = to call?) b) that _1 applies to the word 'visitor' - in reality the sales = department may not like the wording that was chosen by the programmer. It also compile-caches the result so that the only way to change the = value, it to re-start the Perl interpreter. With Locale::MakePhrase, it contains an expression engine so that the = translator can do the equivalent of: _1 =3D=3D 0 : "No visitors" _1 =3D=3D 1 : "Only one visitor" ... ie: it scarifices CPU cycles, to allow the expressions to be changed at = runtime. Mathew |
From: Hugues de M. <hu...@ma...> - 2005-05-27 07:38:54
|
Hi, Just about <TMPL_xxx > tags in the template file: don't forget that you=20= can use H::T's 'filter' option and thus define your own syntax.=20 Personally, I've turned all the <TMPL_x > into a {%... %} notation, so=20= that '<TMPL_VAR NAME=3D"foo">' now reads '{%VAR NAME=3D"foo"%}' in my=20 templates. This works in Dreamweaver (at least a my translator's=20 version). As I suggested, you can use this kind of filter to "hide" calls to=20 maketext (or whatever localisation method) into a more web-designer=20 friendly way. For example you could use {{ ... }}=A0to hide <TMPL_VAR=20 EXPR=3Dmaketext('...')>. This could yield to: <!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> <!-- We could use H::T variables to have things like this : --> <p>{{We have [quant,_1,visitor] today,, visitor_count}}></p> </body> </html> (definition of the filter is left as an exercise to the reader ;-) A a side effect, this can help the designer keep in mind that all text=20= chunks will be localised independently, so that he/she should avoid=20 things like: <TR> <TD>{{Do you want}}</TD> <TD>{{to}} <select name=3D"action"><option = value=3D"del">{{delete}}</option><option=20 value=3D"keep">{{keep}}</option></select> </TD> <TR> Where "to" would have to be translated using some unambiguous=20 correspondence which doesn't exist for every languages (at least for=20 French, this "to" would disappear - in other contexts, not). Best, Hugues PS: I know that this doesn't solve the cache issue, as template is=20 re-evaluated for every display, so that you should mix this approach=20 with Mark's caching modifications.= |
From: Mathew R. <mat...@re...> - 2005-05-27 00:48:10
|
> The only real issue that the programmer has to do is to set a few = extra template variables: > > TMPL_VAR document_charset > TMPL_VAR document_direction > TMPL_VAR document_language > TMPL_VAR document_direction_default > TMPL_VAR document_direction_inverse > > The first three should be used in your document headers and = occasionaly in table headers. > The other two are used for formatting within tables, so that your = text/image alignment comes out correct for the language. I should clarify, the reason for the direction var's is that in some = languages, the text can be written lefto-to-right or right-to-left = depending on where the person comes from. As such, these variables = should be a user preference so that they can change them as appropriate. The values for them should be: document_direction : "LTR" or "RTL" document_direction_default : should be the same as = document_direction document_direction_inverse : should be the alternate of = document_direction_default cheers, Mathew |
From: Mathew R. <mat...@re...> - 2005-05-27 00:15:45
|
Translation issues aside, one of the best parts of storing translations = in a database is that you can quite easily build a web interface to the = database table. You write a script which greps your = source-code/templates so that it inserts the new strings, and deletes = any unused ones. This works really well for web pages as you simply set the encoding to = UTF8, provide a combobox of selectable languages / regions, provide a = textarea for the string input and a submit button. As a programmer I = never need to speak to the translators as they simply use the web = interface. The only real issue that the programmer has to do is to set a few extra = template variables: TMPL_VAR document_charset TMPL_VAR document_direction TMPL_VAR document_language TMPL_VAR document_direction_default TMPL_VAR document_direction_inverse The first three should be used in your document headers and occasionaly = in table headers. The other two are used for formatting within tables, = so that your text/image alignment comes out correct for the language. hope this helps Mathew |
From: Markus S. <m.s...@gm...> - 2005-05-26 20:20:30
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Johan Kuuse schrieb: > 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. The HTML::Parser based solution just avoids this mess: * You have simple XHTML in your template * Use <tmpl_var> only where necessary for program flow * Let Locale::Maketext or Locale::MakePhrase handle the translations in a filter process * A patched HTML::Template then has to cache the translated templates And for translation you can either * use a natural language as basis and have an AUTO entry in Locale::Maketext's dictionary for this language * or create artificial strings which get translated into *every* language (has advantages if you have many and very different languages) The web designer then only has to take care that the maximum space a translated string may require will be accommodated, but other than that can use the normal tools without having to take care of custom tags in the html code Kind regards Markus -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCli+RxxUzQSse11ARAkPgAJ4pn0M4h0P7kvEm2LnxghQVFvTYewCfWhvn WgGYWAorQDAhMQCmojFXJ0k= =AK78 -----END PGP SIGNATURE----- |
From: Mark A. F. <mar...@ea...> - 2005-05-26 18:36:34
|
> Anyone has used HTML::Template and Locale::Maketext together? Did you search the archives? I wrote a rather lengthy explanation of how to do it (with the help of Cees Hek). I agree with the various observations about how language-specific copies of templates become unmanageable. You also lose the caching capability if you fill in too many variables with language translated content. And, there are some things that are filled in once (such as pull-down list values which don't need to be set for each redisplay). My solution was to 1) set the template path to language-specific directories to include language fragments from (without duplicating markup). 2) Use Cees Hek's hack to make H:T's cache keyed on template and language. 3) Make a lot of use of H:T's filter mechanism to fill in one-time form values (like list values) so they become static to the cached template. Here is what I posted: http://sourceforge.net/mailarchive/message.php?msg_id=10644629 If you need clarification, let me know. Mark |
From: Johan K. <ku...@re...> - 2005-05-26 16:51:37
|
Hi, I haven't tested neither of your solutions/suggestions yet (Markus, Mathew,= =20 Hugues), even if they all look interesting. Anyway, what Markus mentioned about using HTML::Parser is an approach that = may=20 make things easier for the web designer. What I'm looking for is an approach that would be as painless as possible f= or=20 all parts - both the programmer, web designer and translator. On this list we're all programmers, so we know what's the best solution - f= or=20 the programmer. I don't really know at what degree one should think and plan of the web=20 designer's and translator's tasks. I do agree that storing the language phrases in a database is an elegant=20 solution. But to me, as an example, telling the translator: "Please fill in the Itali= an=20 (Greek, Swahili, Klingon, Whatever) column in this Excel sheet I just sent = to=20 you, export it as CSV, and then please upload the csv file to my database=20 server, which will incorproate your language in the application immediately= =2E"=20 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.=20 The role of the web designer if more complicated. Personally, I have only worked together with web designers who are very=20 focused on design, and not so much on HTML itself. My personal taste has been more minimalistic (a UNIX programmer's disease? = ;-)=20 than the web designer's, so the discussions/compromises have included=20 limiting graphics etc., but never programming issues related to the HTML=20 templates. One alternative is to: =2D Save a copy of the output from a web page in one language (in the=20 "undesigned" way I created the HTML template). =2D Pass the copy to the web designer. =2D Parse the re-designed page (through HTML::Parser) to replace the=20 words/phrases with the original <TMPL_VAR...> tags? =2D Optionally, save a copy of the output from the (now redesigned) web pag= e in=20 another language, and pass it to the web designer, just to assure her/him=20 that the same page looks fine in two different languages. The other alternative is to ask the web designer to work directly with the= =20 templates. In this case, using this document (my example)... =2D--------------------------------------- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title><TMPL_VAR NAME=3DHELLO_WORLD></title> </head> <body> <b><TMPL_VAR NAME=3DHELLO_WORLD></b> <p><TMPL_VAR NAME=3DWELCOME_TO_THIS_WEB_SITE></p> </body> </html> =2D--------------------------------------- =2E.. or this document (Hugues' example)... =2D--------------------------------------- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title><TMPL_VAR EXPR=3D"maketext('Hello, world!')"></title> </head> <body> <b><TMPL_VAR EXPR=3D"maketext('Hello, world!')"></b> <p><TMPL_VAR EXPR=3D"maketext('Welcome to this website.')"></p> <!-- We could use H::T variables to have things like this : --> <p><TMPL_VAR EXPR=3D"maketext('We have [quant,_1,visitor] today',=20 visitor_count)"></p> </body> </html> =2D--------------------------------------- =2E.. would both show a blank web page in Quanta's "preview mode", and some= =20 yellow highlighted <TMPL_..> tags in DreamWeaver's preview mode. While this may be enough for a more "HTML-focused" web designer, it is=20 definitely not the case for a more "design-focused" web designer. Of course, this discussion about <TMPL_...> tags for the web designer isn't= =20 only an issue for multiling=FCal web pages, but it is where it comes to an= =20 extreme, as there is no common text at all in the HTML document, only=20 template tags all over. Any comment and/or experiences (especially on working with web designers) a= re=20 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=3D"maketext('Hello, world!')"></title> > </head> > <body> > <b><TMPL_VAR EXPR=3D"maketext('Hello, world!')"></b> > <p><TMPL_VAR EXPR=3D"maketext('Welcome to this website.')"></p> > <!-- We could use H::T variables to have things like this : --> > <p><TMPL_VAR EXPR=3D"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 someo= ne > try this ? > > Best, > > Hugues > > > ----- Original Message ----- > From: "Mathew Robertson" <mat...@re...> > To: "Johan Kuuse" <ku...@re...> > Cc: <htm...@li...> > 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 tag= s. > > 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: =20 > http://members.optusnet.com.au/mathew > > Hope this helps, > Mathew > > > > ----- Original Message ----- > From: "Johan Kuuse" <ku...@re...> > To: <htm...@li...>; <cg...@li...= t> > 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 langua= ge > 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 string= s" > in one languages, but has to be filled up only with <TMPL_VAR NAME=3Dxxx> > 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 o= ne > template per language, which also is undesirable. > > Any suggestions are appreciated. > > I will try explaining details of the problem by using a couple of example= s: > > Approach 1, using one template for all languages: > hello.pl > # ---------------------------------------- > #!/usr/bin/perl -w > use HTML::Template; > use MyApp:I18N; > my $locale =3D $ARGV || 'en'; # Use English as default > my $lh =3D MyApp::I18N->get_handle($locale) || die "Can't get a language > handle!"; > # open the html template > my $template =3D HTML::Template->new(filename =3D> 'hello.world.tmpl.html= '); > # fill in some parameters > $template->param( > HELLO_WORLD =3D> $lh->maketext("Hello, world!"), > WELCOME_TO_THIS_WEB_SITE =3D> $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=3DHELLO_WORLD></title> > </head> > <body> > <b><TMPL_VAR NAME=3DHELLO_WORLD></b> > <p><TMPL_VAR NAME=3DWELCOME_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 =3D ( > # Message to translator: Start here! > "Hello, world!" =3D> "Hello, world!", > "Welcome to this website." =3D> "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 =3D ( > # Mensaje a traductor: =A1Empieza aqu=ED! > "Hello, world!" =3D> "=A1Hola, mundo!", > "Welcome to this website." =3D> "Bienvenido a este sitio web.", > # Mensaje a traductor: =A1Termina aqu=ED! > ); > # ---------------------------------------- > MyApp/I18N/se.pm > # ---------------------------------------- > package MyApp::I18N::es; > # Swedish language messages > use base qw(MyApp::I18N); > use strict; > use vars qw(%Lexicon); > %Lexicon =3D ( > # Meddelande till =F6vers=E4ttaren: B=F6rja h=E4r! > "Hello, world!" =3D> "Hej, v=E4rlden!", > "Welcome to this website." =3D> "V=E4lkommen till den h=E4r webbsajten.= ", > # Meddelande till =F6vers=E4ttaren: Sluta h=E4r! > ); > # ---------------------------------------- > > > Approach 2, using one template per language: > hello.pl > # ---------------------------------------- > #!/usr/bin/perl -w > use HTML::Template; > my $locale =3D $ARGV || 'en'; # Use English as default > my $filename =3D 'hello.world.tmpl.html.' . $locale; > # open the html template > my $template =3D HTML::Template->new(filename =3D> $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>=A1Hola, mundo!</title> > </head> > <body> > <b>=A1Hola, 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=E4rlden!</title> > </head> > <body> > <b>Hej, v=E4rlden!</b> > <p>V=E4lkommen till den h=E4r 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_id=16135&op= =3Dick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > 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_id=16135&op= =3Dick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > 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_id=16135&op=3DClick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users =2D-=20 Johan Kuuse ku...@re... Thu May 26 07:52:39 2005 |
From: Hugues de M. <hu...@ma...> - 2005-05-26 13:34:54
|
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=3D"maketext('Hello, world!')"></title> </head> <body> <b><TMPL_VAR EXPR=3D"maketext('Hello, world!')"></b> <p><TMPL_VAR EXPR=3D"maketext('Welcome to this website.')"></p> <!-- We could use H::T variables to have things like this : --> <p><TMPL_VAR EXPR=3D"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 -----=20 From: "Mathew Robertson" <mat...@re...> To: "Johan Kuuse" <ku...@re...> Cc: <htm...@li...> 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 -----=20 From: "Johan Kuuse" <ku...@re...> To: <htm...@li...>; = <cg...@li...> 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=20 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=20 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=20 different languages, the template itself cannot have any "fixed strings" = in=20 one languages, but has to be filled up only with <TMPL_VAR NAME=3Dxxx> = tags for=20 every single message. This makes the job tougher for the web designer (the web page preview = will be=20 almost unreadable). 2. If, on the other hand, one HTML::Template per language, the = translator has=20 to know some HTML to create a HTML::Template with "fixed strings" in = her/his=20 language. And this means that the web designer will end up with one = template=20 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 =3D $ARGV || 'en'; # Use English as default my $lh =3D MyApp::I18N->get_handle($locale) || die "Can't get a language = handle!"; # open the html template my $template =3D HTML::Template->new(filename =3D> = 'hello.world.tmpl.html'); # fill in some parameters $template->param( HELLO_WORLD =3D> $lh->maketext("Hello, world!"), WELCOME_TO_THIS_WEB_SITE =3D> $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=3DHELLO_WORLD></title> </head> <body> <b><TMPL_VAR NAME=3DHELLO_WORLD></b> <p><TMPL_VAR NAME=3DWELCOME_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 =3D ( # Message to translator: Start here! "Hello, world!" =3D> "Hello, world!", "Welcome to this website." =3D> "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 =3D ( # Mensaje a traductor: =A1Empieza aqu=ED! "Hello, world!" =3D> "=A1Hola, mundo!", "Welcome to this website." =3D> "Bienvenido a este sitio web.", # Mensaje a traductor: =A1Termina aqu=ED! ); # ---------------------------------------- MyApp/I18N/se.pm # ---------------------------------------- package MyApp::I18N::es; # Swedish language messages use base qw(MyApp::I18N); use strict; use vars qw(%Lexicon); %Lexicon =3D ( # Meddelande till =F6vers=E4ttaren: B=F6rja h=E4r! "Hello, world!" =3D> "Hej, v=E4rlden!", "Welcome to this website." =3D> "V=E4lkommen till den h=E4r = webbsajten.", # Meddelande till =F6vers=E4ttaren: Sluta h=E4r! ); # ---------------------------------------- Approach 2, using one template per language: hello.pl # ---------------------------------------- #!/usr/bin/perl -w use HTML::Template; my $locale =3D $ARGV || 'en'; # Use English as default my $filename =3D 'hello.world.tmpl.html.' . $locale; # open the html template my $template =3D HTML::Template->new(filename =3D> $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>=A1Hola, mundo!</title> </head> <body> <b>=A1Hola, 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=E4rlden!</title> </head> <body> <b>Hej, v=E4rlden!</b> <p>V=E4lkommen till den h=E4r 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_id=16135&op=3Dick _______________________________________________ Html-template-users mailing list Htm...@li... 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_id=16135&op=3Dick _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Mathew R. <mat...@re...> - 2005-05-26 10:51:40
|
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 -----=20 From: "Johan Kuuse" <ku...@re...> To: <htm...@li...>; = <cg...@li...> 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=20 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=20 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=20 different languages, the template itself cannot have any "fixed strings" = in=20 one languages, but has to be filled up only with <TMPL_VAR NAME=3Dxxx> = tags for=20 every single message. This makes the job tougher for the web designer (the web page preview = will be=20 almost unreadable). 2. If, on the other hand, one HTML::Template per language, the = translator has=20 to know some HTML to create a HTML::Template with "fixed strings" in = her/his=20 language. And this means that the web designer will end up with one = template=20 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 =3D $ARGV || 'en'; # Use English as default my $lh =3D MyApp::I18N->get_handle($locale) || die "Can't get a language = handle!"; # open the html template my $template =3D HTML::Template->new(filename =3D> = 'hello.world.tmpl.html'); # fill in some parameters $template->param( HELLO_WORLD =3D> $lh->maketext("Hello, world!"), WELCOME_TO_THIS_WEB_SITE =3D> $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=3DHELLO_WORLD></title> </head> <body> <b><TMPL_VAR NAME=3DHELLO_WORLD></b> <p><TMPL_VAR NAME=3DWELCOME_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 =3D ( # Message to translator: Start here! "Hello, world!" =3D> "Hello, world!", "Welcome to this website." =3D> "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 =3D ( # Mensaje a traductor: =A1Empieza aqu=ED! "Hello, world!" =3D> "=A1Hola, mundo!", "Welcome to this website." =3D> "Bienvenido a este sitio web.", # Mensaje a traductor: =A1Termina aqu=ED! ); # ---------------------------------------- MyApp/I18N/se.pm # ---------------------------------------- package MyApp::I18N::es; # Swedish language messages use base qw(MyApp::I18N); use strict; use vars qw(%Lexicon); %Lexicon =3D ( # Meddelande till =F6vers=E4ttaren: B=F6rja h=E4r! "Hello, world!" =3D> "Hej, v=E4rlden!", "Welcome to this website." =3D> "V=E4lkommen till den h=E4r = webbsajten.", # Meddelande till =F6vers=E4ttaren: Sluta h=E4r! ); # ---------------------------------------- Approach 2, using one template per language: hello.pl # ---------------------------------------- #!/usr/bin/perl -w use HTML::Template; my $locale =3D $ARGV || 'en'; # Use English as default my $filename =3D 'hello.world.tmpl.html.' . $locale; # open the html template my $template =3D HTML::Template->new(filename =3D> $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>=A1Hola, mundo!</title> </head> <body> <b>=A1Hola, 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=E4rlden!</title> </head> <body> <b>Hej, v=E4rlden!</b> <p>V=E4lkommen till den h=E4r 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_id=16135&op=3Dick _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Markus S. <m.s...@gm...> - 2005-05-25 21:28:38
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Johan, I stood in front of the same problem 2 years ago and came up with a solution that combines (in my eyes) the best of HTML::Template and Locale::Maketext. The principle is as such: The html-code of the template is parsed by HTML::Parser. Strings between tags and certain attribute values (title, alt) are translated by means of Locale::Maketext. A subclass of HTML::Templates caches the different translations through different keys. My solution is by all means not perfect, especially the HTML::Template subclass would much better be rewritten in form of a decent patch (Cees Heek has advised on this, but I never found time to realize this), and therefore was never published. However I put it on a university server where you can download it. Documentation for sure is optimal, but the test scripts explain very clearly the usage. The files are http://dream.lrrl.arch.tu-muenchen.de/~springm/CPAN/authors/id/MSPRING/HTML-Translator-0.03.tar.gz http://dream.lrrl.arch.tu-muenchen.de/~springm/CPAN/authors/id/MSPRING/HTML-I18Template-0.01.tar.gz I would be glad if my solution could be of any usage for you. Kind regards Markus Spring -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFClO4BxxUzQSse11ARAqV/AJsF+8rHcwClEJzF5w19JI+GWhBZgwCfR+sn cO/dmpSc/OBAl449Dfk1EFI= =A4qa -----END PGP SIGNATURE----- |
From: Johan K. <ku...@re...> - 2005-05-25 17:41:51
|
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=20 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= =20 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=20 different languages, the template itself cannot have any "fixed strings" in= =20 one languages, but has to be filled up only with <TMPL_VAR NAME=3Dxxx> tags= for=20 every single message. This makes the job tougher for the web designer (the web page preview will = be=20 almost unreadable). 2. If, on the other hand, one HTML::Template per language, the translator h= as=20 to know some HTML to create a HTML::Template with "fixed strings" in her/hi= s=20 language. And this means that the web designer will end up with one templat= e=20 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 =3D $ARGV || 'en'; # Use English as default my $lh =3D MyApp::I18N->get_handle($locale) || die "Can't get a language=20 handle!"; # open the html template my $template =3D HTML::Template->new(filename =3D> 'hello.world.tmpl.html'); # fill in some parameters $template->param( HELLO_WORLD =3D> $lh->maketext("Hello, world!"), WELCOME_TO_THIS_WEB_SITE =3D> $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=3DHELLO_WORLD></title> </head> <body> <b><TMPL_VAR NAME=3DHELLO_WORLD></b> <p><TMPL_VAR NAME=3DWELCOME_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 =3D ( # Message to translator: Start here! "Hello, world!" =3D> "Hello, world!", "Welcome to this website." =3D> "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 =3D ( # Mensaje a traductor: =A1Empieza aqu=ED! "Hello, world!" =3D> "=A1Hola, mundo!", "Welcome to this website." =3D> "Bienvenido a este sitio web.", # Mensaje a traductor: =A1Termina aqu=ED! ); # ---------------------------------------- MyApp/I18N/se.pm # ---------------------------------------- package MyApp::I18N::es; # Swedish language messages use base qw(MyApp::I18N); use strict; use vars qw(%Lexicon); %Lexicon =3D ( # Meddelande till =F6vers=E4ttaren: B=F6rja h=E4r! "Hello, world!" =3D> "Hej, v=E4rlden!", "Welcome to this website." =3D> "V=E4lkommen till den h=E4r webbsajten.", # Meddelande till =F6vers=E4ttaren: Sluta h=E4r! ); # ---------------------------------------- Approach 2, using one template per language: hello.pl # ---------------------------------------- #!/usr/bin/perl -w use HTML::Template; my $locale =3D $ARGV || 'en'; # Use English as default my $filename =3D 'hello.world.tmpl.html.' . $locale; # open the html template my $template =3D HTML::Template->new(filename =3D> $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>=A1Hola, mundo!</title> </head> <body> <b>=A1Hola, 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=E4rlden!</title> </head> <body> <b>Hej, v=E4rlden!</b> <p>V=E4lkommen till den h=E4r webbsajten.</p> </body> </html> # ---------------------------------------- Best Regards, Johan Kuuse |
From: Aaron D. <aa...@da...> - 2005-05-20 18:47:40
|
We're very pleased to announce that Krang v1.1025 is now available. Notable changes in this release: * Added ability for categories to be created or removed via the FTP interface. Added new group permission, ``Manage categories via FTP'' which defaults to OFF. Turn this on to permit your users to use this new feature. Fixed ASCII-mode bug in FTP interface. * Added new platform files for RedHat Enterprise Server ES3 and ES4. For more information about Krang, visit the Krang website: http://krang.sourceforge.net/ There you can download Krang, view screenshots, read documentation, join our mailing-lists and access the CVS tree. Detailed change-log here: http://krang.sf.net/docs/changelog.html Krang is an Open Source web-publisher / content-management system designed for large-scale magazine-style websites. It is a 100% Perl application using Apache/mod_perl and MySQL, as well as numerous CPAN modules. Krang provides a powerful and easy to use story and media editing environment for magazine editors, as well as a complete template development environment for web designers. On the back-end, Perl programmers can customize Krang to control the data entered in the story editor and add code to drive the templates to build output. Krang can be enhanced with add-ons containing new skins and other new features. Krang easily handles large data sets and can manage multiple websites in a single installation. - the Krang team ---- Aaron Dancygier |