Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why for plone domain we specify only $SOURCE/configure.zcml $SOURCE/profiles/default in rebuild_i18n-sh? (TODO: Search for profiles and *.zcml in the script) #49

Open
idgserpro opened this issue Aug 7, 2019 · 9 comments

Comments

@idgserpro
Copy link
Member

idgserpro commented Aug 7, 2019

For reference:

bin/i18ndude rebuild-pot --pot $LOCALES/plone.pot --create plone $merge_plone $SOURCE/configure.zcml $SOURCE/profiles/default

In https://maurits.vanrees.org/weblog/archive/2010/10/i18n-plone-4:

Domains in GenericSetup xml files
workflows: use the plone domain

is this why we only search for plone domain in the profile? Or there are more motivations for treating plone domain different from the package? Which situations are you trying to avoid by being specific to configure.zcml and profiles/default?

bin/i18ndude rebuild-pot --pot $LOCALES/$I18NDOMAIN.pot $merge --create $I18NDOMAIN $SOURCE

TODO: #49 (comment)

@mauritsvanrees
Copy link
Member

i18ndude can search for an explicit domain without problems in zcml and xml files and in page templates. But not in Python files. In Python files it will look for any code like _(...). It has no idea whether this is a message in the plone domain or in a different domain. So if you call rebuild-pot on all files and do this for two domains, then the messages from Python files will end up in both pot files.

@idgserpro
Copy link
Member Author

But is there a specific reason to search only profiles/default and only configure.zcml? Maybe there's a profiles/initial, or a dependencies.zcml...

@mauritsvanrees
Copy link
Member

No specific reason. *.zcml and profiles should be fine. Maybe */*.zcml too, if that syntax is supported.

@idgserpro
Copy link
Member Author

@mauritsvanrees I have the following code in my package:

from Products.CMFPlone import PloneMessageFactory as _
search = _(u'Search')

When I run ./bin/rebuild_i18n.sh, it adds Search to the pot and po of the domain of my package . Is there any way to avoid this? Does this cause any problems?

@mauritsvanrees
Copy link
Member

You can avoid this by not importing it as underscore. Just use the original PloneMessageFactory, or if you want it shorter:

from Products.CMFPlone import PloneMessageFactory as PMF
search = PMF(u'Search')

Then i18ndude will not pick it up, but translation in Plone will happen just fine.

@idgserpro
Copy link
Member Author

@mauritsvanrees do we have this hint somewhere in the documentation?

Just a question since you develop in i18ndude as well.

To run i18ndude we specify a domain ($I18NDOMAIN). Is it possible to do a check: when finding from Products.CMFPlone import PloneMessageFactory as _, since Products.CMFPlone is different than $I18NDOMAIN, ignore?

@mauritsvanrees
Copy link
Member

I don't think we have that hint anywhere.

The code in extract.py has a comment about this limitation. We would need to import the module and inspect where the underscore comes from. Even if that worked (requiring an i18ndude which has access to Products.CMPlone in its Python path) it would mean each run would take much longer because importing from Plone means importing lots and lots of packages.
Most of that file was copied from zope.app.locales 13 years ago. Since then no one has implemented this bit, so I doubt it will happen now. But if you want to try it, it could be cool.
I don't know if for example babel supports this.

@idgserpro
Copy link
Member Author

I don't think we have that hint anywhere.

Where do you think this should be added? A hint in i18ndude itself?

@mauritsvanrees
Copy link
Member

We can add it in i18ndude rebuild-pot --help. See collective/i18ndude#73

@idgserpro idgserpro changed the title Why for plone domain we specify only $SOURCE/configure.zcml $SOURCE/profiles/default in rebuild_i18n-sh? Why for plone domain we specify only $SOURCE/configure.zcml $SOURCE/profiles/default in rebuild_i18n-sh? (TODO: Search for profiles and *.zcml in the script) Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants