Re: [Zope] five i18n

2006-01-18 Thread Jürgen Herrmann
me again :)

some more things i found out:
1. MyLanguages is instantiated on every http request but
regardless of what i return (['DE'] or ['de']) i always get the
english translation. weird?!

2. seems that only page templates served through an http request
trigger the i18n stuff at all. if so, how can i circumvent this?
(i want to generate xml and run it through trml2pdf to produce
pdf output, which works excellent - but not with i18n)

thanks for your help.
regards, juergen

On Wed, January 18, 2006 15:41, Martijn Faassen wrote:
> Jürgen Herrmann wrote:
>> just tried this:
>>
>> hacked in a MyLanguages in five's i18n.py:
>>
>> class MyLanguages(object):
>> """ fake """
>> implements(IUserPreferredLanguages)
>>
>> def __init__(self, context):
>> self.context = context
>>
>> def getPreferredLanguages(self):
>> return ('DE')
>>
>> and in my overrides.zcml added:
>> > for="zope.publisher.interfaces.http.IHTTPRequest"
>> provides="zope.i18n.interfaces.IUserPreferredLanguages"
>> factory="Products.Five.i18n.MyLanguages" />
>
> Oh, I see you already did what I did in the sample code above.
>
> Regards,
>
> Martijn
>
>


___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Martijn Faassen

Jürgen Herrmann wrote:

just tried this:

hacked in a MyLanguages in five's i18n.py:

class MyLanguages(object):
""" fake """
implements(IUserPreferredLanguages)

def __init__(self, context):
self.context = context

def getPreferredLanguages(self):
return ('DE')

and in my overrides.zcml added:



Oh, I see you already did what I did in the sample code above.

Regards,

Martijn

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Martijn Faassen

Lennart Regebro wrote:

On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:



- how can i set the target language for the translation in the zpt?



That's tricky! :) You need either Localizer or the plone tool for that
now, I think. But it's mentioned in the documentation. By default it
just picks the language from the list of languages in your browser, I
think?



Yeah, it does. In Silva 1.5, under development, I've overridden an 
adapter that negotates the language to also consult a cookie 
('silva_language') and this appears to work.


Here's the code:

from zope.publisher.browser import BrowserLanguages

# new language extractor that looks in the silva_language cookie first,
# then fall back on browser setting
class SilvaLanguages(BrowserLanguages):
def getPreferredLanguages(self):
languages = super(
SilvaLanguages, self).getPreferredLanguages()
cookie_language = self.request.cookies.get('silva_language')
if cookie_language is not None:
languages = [cookie_language] + languages
return languages

and then some ZCML in overrides.zcml in the product:

  

It's not perfect that this override is global now, but I guess 
eventually we could make it a local adapter override for the Silva site..


Regards,

Martijn
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Lennart Regebro
On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> 2. does the translation also work with page template files?

Yes. The work either when you use i18n.translate() from python, or
when you do i18n:something in ZPT.

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n (addendum)

2006-01-18 Thread Jürgen Herrmann
i added a print statement in registerTranslations()
and it shows me that it finds my message catalogs.

On Wed, January 18, 2006 15:27, Jürgen Herrmann wrote:
> just tried this:
>
> hacked in a MyLanguages in five's i18n.py:
>
> class MyLanguages(object):
> """ fake """
> implements(IUserPreferredLanguages)
>
> def __init__(self, context):
> self.context = context
>
> def getPreferredLanguages(self):
> return ('DE')
>
> and in my overrides.zcml added:
>  for="zope.publisher.interfaces.http.IHTTPRequest"
> provides="zope.i18n.interfaces.IUserPreferredLanguages"
> factory="Products.Five.i18n.MyLanguages" />
>
> 1. is the return value correct? i.e. is a tuple ok?
>should it be ('DE') or ('de') - tried both to no avail :(
> 2. does the translation also work with page template files?
>
> regards, juergen
>
> On Wed, January 18, 2006 14:28, Lennart Regebro wrote:
>> On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>>> does the zope/five/i18n machinery tell anything about it's startup
>>> phase (finding message catalogs etc.) in the logs or while watching
>>> runzope output?
>>
>> Nope. It would probably be good if the registerTranslations statement
>> printed logs of what it found.
>>
>>> - how can i set the target language for the translation in the zpt?
>>
>> That's tricky! :) You need either Localizer or the plone tool for that
>> now, I think. But it's mentioned in the documentation. By default it
>> just picks the language from the list of languages in your browser, I
>> think?
>>
>>> - do i have to compile the .pos to .mos by hand?
>>
>> Yes.
>>
>> --
>> Lennart Regebro, Nuxeo http://www.nuxeo.com/
>> CPS Content Management http://www.cps-project.org/
>> ___
>> Zope maillist  -  Zope@zope.org
>> http://mail.zope.org/mailman/listinfo/zope
>> **   No cross posts or HTML encoding!  **
>> (Related lists -
>>  http://mail.zope.org/mailman/listinfo/zope-announce
>>  http://mail.zope.org/mailman/listinfo/zope-dev )
>>
>
>
> ___
>
>>> XLhost.de - eXperts in Linux hosting <<
>
> Jürgen Herrmann
> Bruderwöhrdstraße 15b, DE-93051 Regensburg
>
> Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
> Fax:  +49 (0)721 151 463027
> WEB:  http://www.XLhost.de
>
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Jürgen Herrmann
just tried this:

hacked in a MyLanguages in five's i18n.py:

class MyLanguages(object):
""" fake """
implements(IUserPreferredLanguages)

def __init__(self, context):
self.context = context

def getPreferredLanguages(self):
return ('DE')

and in my overrides.zcml added:


1. is the return value correct? i.e. is a tuple ok?
   should it be ('DE') or ('de') - tried both to no avail :(
2. does the translation also work with page template files?

regards, juergen

On Wed, January 18, 2006 14:28, Lennart Regebro wrote:
> On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>> does the zope/five/i18n machinery tell anything about it's startup
>> phase (finding message catalogs etc.) in the logs or while watching
>> runzope output?
>
> Nope. It would probably be good if the registerTranslations statement
> printed logs of what it found.
>
>> - how can i set the target language for the translation in the zpt?
>
> That's tricky! :) You need either Localizer or the plone tool for that
> now, I think. But it's mentioned in the documentation. By default it
> just picks the language from the list of languages in your browser, I
> think?
>
>> - do i have to compile the .pos to .mos by hand?
>
> Yes.
>
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management http://www.cps-project.org/
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Jürgen Herrmann
On Wed, January 18, 2006 14:28, Lennart Regebro wrote:
> On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>> does the zope/five/i18n machinery tell anything about it's startup
>> phase (finding message catalogs etc.) in the logs or while watching
>> runzope output?
>
> Nope. It would probably be good if the registerTranslations statement
> printed logs of what it found.
>
>> - how can i set the target language for the translation in the zpt?
>
> That's tricky! :) You need either Localizer or the plone tool for that
> now, I think. But it's mentioned in the documentation. By default it
> just picks the language from the list of languages in your browser, I
> think?
ok, first one. will investigate that.
>
>> - do i have to compile the .pos to .mos by hand?
>
> Yes.
second one. i'll report back :)
>
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management http://www.cps-project.org/
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Lennart Regebro
On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> does the zope/five/i18n machinery tell anything about it's startup
> phase (finding message catalogs etc.) in the logs or while watching
> runzope output?

Nope. It would probably be good if the registerTranslations statement
printed logs of what it found.

> - how can i set the target language for the translation in the zpt?

That's tricky! :) You need either Localizer or the plone tool for that
now, I think. But it's mentioned in the documentation. By default it
just picks the language from the list of languages in your browser, I
think?

> - do i have to compile the .pos to .mos by hand?

Yes.

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-18 Thread Jürgen Herrmann
does the zope/five/i18n machinery tell anything about it's startup
phase (finding message catalogs etc.) in the logs or while watching
runzope output? i don't see anything here, and still didn't get it to
work.

- what are the preconditions to get it working? i use plain zope page
templates (no cmf/plone or cps)...
- how can i set the target language for the translation in the zpt?
- my configure.zcml:
http://namespaces.zope.org/zope";
  xmlns:i18n="http://namespaces.zope.org/i18n";>


  (must get parsed, because zope doesnt start up if i put some crap in :)
- my subdir layout under the product dir for message catalogs:
./locales/
./locales/de/LC_MESSAGES/blisspro.po
./locales/en/LC_MESSAGES/blisspro.po

- do i have to compile the .pos to .mos by hand? or is it done
automatically like PTS did?

must be missing something...

thanks in advance for your answers!
regards, juergen

On Tue, January 17, 2006 17:45, Lennart Regebro wrote:
> On 1/17/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>> hi all!
>>
>> does anybody have a five product that uses i18n that i can have a look
>> at?
>> i don't seem to get it right...
>
> Yeah, the CalZope trunk does it:
> http://svn.nuxeo.org/trac/pub/browser/CalZope/trunk/
>
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management http://www.cps-project.org/
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>
___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-17 Thread Martijn Pieters
On 1/17/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> does anybody have a five product that uses i18n that i can have a look at?
> i don't seem to get it right...

See Philipps tutorial on the subject:

  http://worldcookery.com/files/fivei18n/

--
Martijn Pieters
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] five i18n

2006-01-17 Thread Lennart Regebro
On 1/17/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> hi all!
>
> does anybody have a five product that uses i18n that i can have a look at?
> i don't seem to get it right...

Yeah, the CalZope trunk does it:
http://svn.nuxeo.org/trac/pub/browser/CalZope/trunk/

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] five i18n

2006-01-17 Thread Jürgen Herrmann
hi all!

does anybody have a five product that uses i18n that i can have a look at?
i don't seem to get it right...

thanks & regards,
juergen
___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )