> You should know, that the translation of
> the Message does only happen implicitly if it is
rendered inside a
Page
> Template and it asks for it by using the usual
i18n:translate or
> i18n:attributes statements.
> If you use it outside a Page Template you have to
translate it
> explicitly by using either the context.translate Python
script or
> calling the translation service directly:
D'oh! I was under the impression that _(u'some string')
would dig the
translation (if any) out of the .po file and I would be on
my way. I see
now that MessageFactory only creates a Message, which you
have helpfully
pointed out must be explicitly translated. (Thank You)
Ultimately, I just want to be able to look up the
replacement for the
string to be translated and have that translated text
available in my
.py script. I am hoping that this is possible. Can you
confirm or deny
the feasibility of this?
> translate it explicitly by using either the
context.translate Python
script
I am not sure where to get access to this script from within
a .py file.
The python fragments in .cpy files seem to get for free and
just have to
bind it. Any hints?
> from Products.PageTemplates.GlobalTranslationService
import
> getGlobalTranslationService
>
> getGlobalTranslationService().translate
I've tried using "from zope.i18n import translate"
as well as what you
recommended (I'll go with your approach as I am starting to
clue in to
the fact that Five seems to be the way forward). In either
case the code
ends up in same place.
role = _(u'Reviewer')
from Products.PageTemplates.GlobalTranslationService import
getGlobalTranslationService
transRole =
getGlobalTranslationService().translate('openengagementdms',
role)
The code ends up looking for a TranslationDomain that
corresponds to
'openengagementdms' in e:plone
2zopelibpythonzopecomponentsite.py(96)queryUtility(),
but the only
domain that it can find is
{u'zope': <zope.i18n.translationdomain.TranslationDomain
object at
0x03435770>}
I was hoping that PTS would load the .po file into there for
me. Any
idea as to how I could find the right TanslationDomain? Am I
looking in
the right place?
As for the .po file, the translations for the page templates
are being
found and substituted. It's just getting the translation in
the python
code that I am having trouble with.
------------------------------------------------------------
-------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Plone-i18n mailing list
Plone-i18n lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-i18n
a>
|