Quantcast

plone domain translations in add-ons for Plone 3 and 4

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

plone domain translations in add-ons for Plone 3 and 4

Maurits van Rees-3
Hi,

Say you have created an add-on that has a few extra translations for the
plone domain.

If this add-on only targets Plone 3 you should add the translations to
the i18n directory.
If this add-on only targets Plone 4 you should add the translations to
the locales directory.

See my blog about that from last year:
http://maurits.vanrees.org/weblog/archive/2010/10/i18n-plone-4#extra-translations-for-an-existing-domain

But what should an add-on author do when he wants to support both Plone
3 and Plone 4 in the same code base?  My blog points to some dangers there.

One option that works is to use the i18n directory and to conditionally
register translations from the plonelocales directory when on Plone 4,
like this:

   <i18n:registerTranslations directory="plonelocales"
       xmlns:zcml="http://namespaces.zope.org/zcml"
       zcml:condition="have plone-4" />

See the example in this revision of collective.sortmyfolder:
http://dev.plone.org/browser/collective/collective.sortmyfolder/trunk/collective/sortmyfolder?rev=246304

Note that I removed it later because the plone domain was ultimately not
needed in this package.  And note that in this case we have a normal
locales directory with translations for our own domain and this should
*always* be registered, so we cannot add the plone domain translations
there.

An obvious downside to this approach is that plone domain translations
are then done in two spots.  Dutch plone translations would be both in
i18n/collective.sortmyfolder-plone-nl.po and
plonelocales/nl/LC_MESSAGES/plone.po.  Picking one of those as the
master and copying that to the other location works fine, as long as the
plone specific headers are set in the po file, which i18ndude takes care of.


Another option is of course to drop support for Plone 3 in that add-on
and stick to the (plone)locales solution.  If wanted you can add a note
that it still works on Plone 3 except that it misses a few translations.


Are there other options out there?


BTW, I am considering the first approach for Products.PloneGlossary.  If
you care about your language in that package you should already take a
look at trunk and update your po files (plone domain and ploneglossary
domain), as I have cleaned things up two days ago.


--
Maurits van Rees   http://maurits.vanrees.org/
Web App Programmer at Zest Software: http://zestsoftware.nl
"Logical thinking shows conclusively that logical thinking
is inconclusive." - My summary of Gödel, Escher, Bach


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plone domain translations in add-ons for Plone 3 and 4

Vincent Fretin
Hi,

I thought that translations in i18n folder worked on both Plone 3 and 4, is it not the case?
In Plone 4, the po files in the the i18n directory are loaded with the same engine as po files in the locales folder, right?
It should merge translations if there is several po files with the same domain. If not, I think it's a bug.

Vincent

On Fri, Nov 18, 2011 at 1:01 PM, Maurits van Rees <[hidden email]> wrote:
Hi,

Say you have created an add-on that has a few extra translations for the
plone domain.

If this add-on only targets Plone 3 you should add the translations to
the i18n directory.
If this add-on only targets Plone 4 you should add the translations to
the locales directory.

See my blog about that from last year:
http://maurits.vanrees.org/weblog/archive/2010/10/i18n-plone-4#extra-translations-for-an-existing-domain

But what should an add-on author do when he wants to support both Plone
3 and Plone 4 in the same code base?  My blog points to some dangers there.

One option that works is to use the i18n directory and to conditionally
register translations from the plonelocales directory when on Plone 4,
like this:

  <i18n:registerTranslations directory="plonelocales"
      xmlns:zcml="http://namespaces.zope.org/zcml"
      zcml:condition="have plone-4" />

See the example in this revision of collective.sortmyfolder:
http://dev.plone.org/browser/collective/collective.sortmyfolder/trunk/collective/sortmyfolder?rev=246304

Note that I removed it later because the plone domain was ultimately not
needed in this package.  And note that in this case we have a normal
locales directory with translations for our own domain and this should
*always* be registered, so we cannot add the plone domain translations
there.

An obvious downside to this approach is that plone domain translations
are then done in two spots.  Dutch plone translations would be both in
i18n/collective.sortmyfolder-plone-nl.po and
plonelocales/nl/LC_MESSAGES/plone.po.  Picking one of those as the
master and copying that to the other location works fine, as long as the
plone specific headers are set in the po file, which i18ndude takes care of.


Another option is of course to drop support for Plone 3 in that add-on
and stick to the (plone)locales solution.  If wanted you can add a note
that it still works on Plone 3 except that it misses a few translations.


Are there other options out there?


BTW, I am considering the first approach for Products.PloneGlossary.  If
you care about your language in that package you should already take a
look at trunk and update your po files (plone domain and ploneglossary
domain), as I have cleaned things up two days ago.


--
Maurits van Rees   http://maurits.vanrees.org/
Web App Programmer at Zest Software: http://zestsoftware.nl
"Logical thinking shows conclusively that logical thinking
is inconclusive." - My summary of Gödel, Escher, Bach


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plone domain translations in add-ons for Plone 3 and 4

Maurits van Rees-3
Op 18-11-11 15:22, Vincent Fretin schreef:
> Hi,
>
> I thought that translations in i18n folder worked on both Plone 3 and 4,
> is it not the case?
> In Plone 4, the po files in the the i18n directory are loaded with the
> same engine as po files in the locales folder, right?
> It should merge translations if there is several po files with the same
> domain. If not, I think it's a bug.

An i18n directory still works in Plone 4.  But when one or more locales
directories have been registered for a domain, any po files for that
domain in an i18n directory are ignored.

Oh wait, I may have fooled myself.  Translations for the plone domain in
an i18n directory *are* picked up when the package is in the Products
namespace.

Hm, the same *should* probably be true for packages in a different
namespace as long as you register the package in zcml:

    <five:registerPackage package="." />

But that is not the case.  Seems a bug indeed.  I will see if I can find
out where the problem is.


To test:

- Make a checkout of this package, where I also did the change I
described in my initial mail:
https://svn.plone.org/svn/collective/collective.portlet.relateditems/trunk
- Run the bootstrap and bin/buildout.
- Comment out these lines in configure.zcml:
     <i18n:registerTranslations
         directory="plonelocales"
         zcml:condition="have plone-4" />
- Create a *Dutch* Plone Site, install the package.
- Optionally create French translations and try it with those and commit
them. :-)
- Go to @@manage-portlets and see that there is a 'Related Items' portlet.
- Revert the zcml change and restart Plone.
- Now @@manage-portlets shows 'Gerelateerde items'.


A fresh release of this package is welcome btw, in case any authors are
following this list.  I have sent a mail as well to kiorky.

Cheers,


--
Maurits van Rees   http://maurits.vanrees.org/
Web App Programmer at Zest Software: http://zestsoftware.nl
"Logical thinking shows conclusively that logical thinking
is inconclusive." - My summary of Gödel, Escher, Bach


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plone domain translations in add-ons for Plone 3 and 4

Vincent Fretin
On Fri, Nov 18, 2011 at 7:33 PM, Maurits van Rees <[hidden email]> wrote:
Op 18-11-11 15:22, Vincent Fretin schreef:
> Hi,
>
> I thought that translations in i18n folder worked on both Plone 3 and 4,
> is it not the case?
> In Plone 4, the po files in the the i18n directory are loaded with the
> same engine as po files in the locales folder, right?
> It should merge translations if there is several po files with the same
> domain. If not, I think it's a bug.

An i18n directory still works in Plone 4.  But when one or more locales
directories have been registered for a domain, any po files for that
domain in an i18n directory are ignored.

Oh wait, I may have fooled myself.  Translations for the plone domain in
an i18n directory *are* picked up when the package is in the Products
namespace.

Hm, the same *should* probably be true for packages in a different
namespace as long as you register the package in zcml:

   <five:registerPackage package="." />

But that is not the case.  Seems a bug indeed.  I will see if I can find
out where the problem is.

Ah! You're right, there is an issue here. Some translations in the plone domain in the i18n folder of plone.app.discussion doesn't show up in Plone 4.2, like the Commentators criteria and its description. :(

Vincent

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plone domain translations in add-ons for Plone 3 and 4

Vincent Fretin
On Fri, Nov 18, 2011 at 11:39 PM, Vincent Fretin <[hidden email]> wrote:
Ah! You're right, there is an issue here. Some translations in the plone domain in the i18n folder of plone.app.discussion doesn't show up in Plone 4.2, like the Commentators criteria and its description. :(

The translations do show up with plone.app.discussion 1.0b12 with Plone 4.0.9. The package does have <five:registerPackage package="." /> and the header of the po file didn't change. In Plone 4.1, it doesn't work.



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plone domain translations in add-ons for Plone 3 and 4

Maurits van Rees-3
Op 18-11-11 23:49, Vincent Fretin schreef:

> On Fri, Nov 18, 2011 at 11:39 PM, Vincent Fretin
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Ah! You're right, there is an issue here. Some translations in the
>     plone domain in the i18n folder of plone.app.discussion doesn't show
>     up in Plone 4.2, like the Commentators criteria and its description. :(
>
>
> The translations do show up with plone.app.discussion 1.0b12 with Plone
> 4.0.9. The package does have <five:registerPackage package="." /> and
> the header of the po file didn't change. In Plone 4.1, it doesn't work.

Bingo.  Products/CMFQuickInstallerTool/utils.py has the necessary code
that should be used in PlacelessTranslationService too:

try:
     # Zope 2.13+
     from OFS.metaconfigure import get_registered_packages
except ImportError:
     def get_registered_packages():
         import Products
         return getattr(Products, '_registered_packages', ())

The old code is still used in the spot in PTS that wants to look for
i18n directories in packages that have five:registerPackage.

I will make the change.


--
Maurits van Rees   http://maurits.vanrees.org/
Web App Programmer at Zest Software: http://zestsoftware.nl
"Logical thinking shows conclusively that logical thinking
is inconclusive." - My summary of Gödel, Escher, Bach


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Loading...