plone.app.multilingual/master: Fix to make assets folder creationg i18n aware
Asko Soukka <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: plone.app.multilingual Branch: refs/heads/master Date: 2017-07-07T09:37:54+03:00 Author: Asko Soukka (datakurre) <[email protected]> Commit: https://github.com/plone/plone.app.multilingual/commit/7f441bdeb899347e30d1052e7cda8db2d7b03be2 Fix to make assets folder creationg i18n aware Files changed: M CHANGES.rst M README.rst M src/plone/app/multilingual/browser/setup.py diff --git a/CHANGES.rst b/CHANGES.rst index 6a40e79..da791e3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,8 +10,9 @@ Breaking changes: New features: -- Rename ``media``folder to a more generic name ``assets`` - [agitator] +- Rename ``media`` folder to a more generic name ``assets`` by default and + add i18nize it to be localization aware + [agitator, datakurre] Bug fixes: diff --git a/README.rst b/README.rst index a084d88..6265881 100644 --- a/README.rst +++ b/README.rst @@ -101,15 +101,15 @@ While browsing the site, the language selector viewlet allows users to switch si * Shows the user an informative view that shows the current available translations for the current content. -The "Assets" folder - a shared "Language Independent Folder" ------------------------------------------------------------- +The assets folder - a shared "Language Independent Folder" +---------------------------------------------------------- -The root language folders are used to house the content tree for the corresponding language. However, there are some use cases where we need content that does not belong to any language. For example, for assets or side resources like images, videos and documents. For this reason PAM supplies a special Language Independent Folder to house these kind of objects. After PAM setup, there is a special folder called "Assets", which can be accessed through the "Go to shared folder" item of the "Translate" menu. All items placed in this folder will have neutral as their default language and will be visible from the other root language folders as if they were placed there as well. +The root language folders are used to house the content tree for the corresponding language. However, there are some use cases where we need content that does not belong to any language. For example, for assets or side resources like images, videos and documents. For this reason PAM supplies a special Language Independent Folder to house these kind of objects. After PAM setup, there is a special folder called "Assets" (folder title may depend on the language), which can be accessed through the "Go to Assets folder" item of the "Translate" menu. All items placed in this folder will have neutral as their default language and will be visible from the other root language folders as if they were placed there as well. Note: * Language Independent Folder's have also been historically known as "Neutral root folder", "language neutral folder" and "language shared (folder)". * Also don't confuse Language Independent Folders with Language Independent Fields - * The Language Independent Folder formerly known as ``Media`` folder, was renamed to the more generic name ``Assets``. + * The Language Independent Folder formerly known as ``Media`` folder, was renamed to the more generic name ``Assets`` (the name may depend on the language). Translation map diff --git a/src/plone/app/multilingual/browser/setup.py b/src/plone/app/multilingual/browser/setup.py index ca529d6..99e74b4 100644 --- a/src/plone/app/multilingual/browser/setup.py +++ b/src/plone/app/multilingual/browser/setup.py @@ -7,6 +7,7 @@ from plone.app.layout.navigation.interfaces import INavigationRoot from plone.app.multilingual.dx.interfaces import IDexterityTranslatable from Products.CMFPlone.interfaces import ILanguage +from plone.app.multilingual import _ from plone.app.multilingual.interfaces import ITranslatable from plone.app.multilingual.interfaces import ITranslationManager from plone.app.multilingual.interfaces import LANGUAGE_INDEPENDENT @@ -16,6 +17,7 @@ from plone.i18n.locales.languages import _languagelist from zope.component.hooks import getSite from zope.event import notify +from zope.i18n import translate from zope.interface import alsoProvides from zope.lifecycleevent import modified @@ -134,18 +136,25 @@ def setUpLanguage(self, code, name): folder = getattr(self.context, folderId, None) wftool = getToolByName(self.context, 'portal_workflow') + assets_folder_id = translate(_('assets_folder_id', + default='assets'), + target_language=folderId) + assets_folder_title = translate(_('assets_folder_title', + default=u'Assets'), + target_language=folderId) + if folder is None: _createObjectByType(self.folder_type, self.context, folderId) _createObjectByType(self.folder_type_language_independent, - self.context[folderId], 'assets') + self.context[folderId], assets_folder_id) folder = self.context[folderId] ILanguage(folder).set_language(code) folder.setTitle(name) - ILanguage(folder['assets']).set_language(code) - folder['assets'].setTitle(u'Assets') + ILanguage(folder[assets_folder_id]).set_language(code) + folder[assets_folder_id].setTitle(assets_folder_title) # This assumes a direct 'publish' transition from the initial state # We are going to check if its private and has publish action for @@ -156,24 +165,25 @@ def setUpLanguage(self, code, name): if state != 'published' and 'publish' in available_transitions: wftool.doActionFor(folder, 'publish') - state = wftool.getInfoFor(folder['assets'], 'review_state', None) + state = wftool.getInfoFor(folder[assets_folder_id], + 'review_state', None) available_transitions = [t['id'] for t in - wftool.getTransitionsFor(folder['assets'])] + wftool.getTransitionsFor(folder[assets_folder_id])] # noqa if state != 'published' and 'publish' in available_transitions: - wftool.doActionFor(folder['assets'], 'publish') + wftool.doActionFor(folder[assets_folder_id], 'publish') # Exclude folder from navigation (if applicable) adapter = IExcludeFromNavigation(folder, None) if adapter is not None: adapter.exclude_from_nav = True - adapter = IExcludeFromNavigation(folder['assets'], None) + adapter = IExcludeFromNavigation(folder[assets_folder_id], None) if adapter is not None: adapter.exclude_from_nav = True # We've modified the object; reindex. notify(modified(folder)) - notify(modified(folder['assets'])) + notify(modified(folder[assets_folder_id])) doneSomething = True logger.info(u"Added '%s' folder: %s" % (code, folderId)) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot