Re: [Phplib-users] Templates and i18n...
Brought to you by:
nhruby,
richardarcher
From: Aric C. <gre...@pe...> - 2002-12-03 01:12:26
|
> Hi Aric, > > What is the difference between: > > >I then ... put appropriate {} tags into the templates. > > and > > >A translatable string could be identified in the > >template like so: {"this is a string"}. > > > In both cases you are adding {} tags to the template file, > which seems to me like the same amount of work. Well, because right now, the template might look like this: <h1>{TITLELABEL}</h2> And the code would have this: $template->set_var(array("TITLELABEL" => getText("This is the page title"))); Now if there's a lot of text like that, your set_var() gets big. With the other method, it goes something like this: <h1>{"This is the page title"}</h2> Which for the template designer is a little nicer -- he sees the actual text at least. The template designer might also do the language translation file, so he could add text in both places and not have to bother the code guy to add more set_vars(). The code would then be something like this: class $mytemplate extends $template { function getText($str) { /* whatever code here you need to load a language file and index $str to get a new string */ return $str; // defaults to same } } And then that's it for your application. No more set_var() for all those strings, because the template class calls the getText method whenever it sees a {""}. Does that make more sense? |