[Zope-dev] Re: [ZIP] Translator 0.1 released

Federico Di Gregorio fog@mixadlive.com
Fri, 24 Mar 2000 14:10:10 +0100


> <dtml-try>
>  <dtml-var name>
>  <dtml-except>default string
> </dtml-try>
> 
> The user who writes this dtml expects the "default string" to be
> displayed if the object "name" doesn't exists. But if it's called
> from a L10NFolder that has an entry for "name" then its translation
> is displayed instead.

right. but this is exactly what you want. if not don't put this code
in an l10nfolder.

> > lets add two different dtml tags:
> > 
> > dtml-translate - translates every single word. i don't think is a good
> >   idea to put such a beast inside zope, but somebody can need it, so why 
> >   not? we just need to arrange think so that the other tag doesn't need
> >   this stuff.
> > 
> > dtml-localize - this is a localized variable. normal acquisition does not work
> >   with it. just the url transversal. and even the transversal is limited to
> >   iso names. dtml-lvar looks for localized variables on the translator object
> >   it has access to (default acquisition to find them) and inside folders
> >   with iso names (as l10nfolder does at now.)
> > 
> 
> Yes, it looks better. Please, could you illustrate its use with an example?

ok. real example from the site we are building now. we put all the images
in an image folder (actually more than one because we have 300+ png, but
let's simplificate), the translator object is called translator and the page
i want to display is in a folder named foo. comment after #

images/
  translator
  head.png           # this images are not localized 
  logo.png
  ...
  menu.png           # this image need to be localized, this is the default
  it/                # the iso named folders contain the localized
    menu.png         # versions of the images
  en/
    menu.png
foo/
  translator
  bar.html           # DTML document with the page i want to display

inside bar.html i can put some code like this:

<dtml-with images>
    <dtml-var logo.png><dtml-var head.png>
    ...
    <dtml-localize menu.png>         # this includes the localized version of
                                     # menu.png or the default version if the
                                     # requested version is not available
</dtml-with>
...
The text you required in <dtml-var language> is: <dtml-localize text1>.


text1 is defined on the translator object inside the foo folder. the right
menu.png can be accessed through the dtml-localize tag because dtml-localize
looks for translator objects with the default acquisition rules and ask them
about the wanted object. the translator object in images knows about the
iso-named folders and returns the object translated in the right language or
the default.

i think i can implement it by merging translator and l10nfolder. can i go on?

ciao,
federico 

-- 
Federico Di Gregorio
MIXAD LIVE System Programmer                           fog@mixadlive.com
Debian GNU/Linux Developer & Italian Press Contact        fog@debian.org
                           Don't dream it. Be it. -- Dr. Frank'n'further