[Zope3-Users] Re: translation domains and their scope
Philipp von Weitershausen
philipp at weitershausen.de
Thu Feb 22 18:11:53 EST 2007
On 22 Feb 2007, at 23:59 , Giovannetti, Mark wrote:
>> From: Philipp von Weitershausen [mailto:philipp at weitershausen.de]
>> Giovannetti, Mark wrote:
> [snip]
>>>
>>> However, using http://localhost:8080/ to display the same
>>> generic page (as another ISite), the translations do not happen.
>>>
>>> I want to use the 'common' translation domain (TD) across more than
>>> one site (i.e. the use case above would allow me to have a
>>> splash page at the site root using common translations with
>>> a choice among subsites).
>>>
>>> So, thinking I should move the 'common' TD to the zope instance
>>> root I use the ZMI cut and paste functions to move the 'common'
>>> domain from MYSITE to the root/global(?) site. I also checked,
>>> unregistered, and registered where appropriate.
>>>
>>> Now the translations for common, formerly functional under
>>> MYSITE, no longer work under MYSITE, nor do they work under the
>>> root site, nor anywhere else.
>>>
>>> What gives? Is there something bad about using cut and paste
>>> to move a translation domain?
>>>
>>> How are translation domains looked up and used? What are their
>>> scopes?
>>
>> The scope of any local utility (and that includes translation
>> domains) is the site that it was registered for. It's therefore
>> not surprising that a translation domain you added and
>> registered in MYSITE are not available outside that folder.
>
> Ok, fair enough. That still doesn't explain why moving the 'common'
> TD to the [top] 'site' (in the ZMI) didn't 'globalize' it. Oh well, I
> guess it's just another of those unexplained head scratchers that
> zope3 seems to be infused with.
Normally this works. You simply have to make sure you unregister the
translation domain as a utility, move it, and then re-register it in
the root site again. Even if those steps are messed up, it should
work if you remember to re-register it with the root site. I wouldn't
be surprised if you simply forgot that last step.
> I was under the impression that
> a utility that wasn't found in a local site was searched up-the-stack
> to the global site.
Yes, utilities are searched up the stack. If not found in the local-
most site, then perhaps in the next site, etc, until the root site is
reached. If that doesn't have it, the global registry isn't searched
for.
>> Why aren't you going for global translation domains that are
>> maintained as gettext PO files on the filesystem and registered
>> using ZCML? My book (also the 1st edition) explains how to do that.
>>
>
> I have reread the chapter on i18n and will try the ZCML
> registerTranslations directive. Does this guarantee that
> all translation domains registered via this directive will
> be available *everywhere* in the zope instance? If so then
> I thank you for reminding me about it. If not, wtf?
Of course they will. That's the point of global components.
Next time I suggest you read the book first ;).
> I had wanted to use the GUI in the ZMI for simple testing
> before getting to the gettext formalization for the app.
That's fine, though I don't find the gettext way is neither
"formalized" nor is it particularly more complicated than the local
utility stuff (well, ok, you have to compile the .po files
to .mo...). In the end you're just going to have to write code to
export your persistent translation domains to .po files on the
filesystem...
More information about the Zope3-users
mailing list