Package: archetypes.languagebugfix
Archetypes Language Field Bug Fix=================================Introduction------------archetypes.languagebugfix package aims to fix an `issue<https://dev.plone.org/plone/ticket/8907>`_ with the default vocabulary forExtensibleMetadata language field in Archetypes.This issue affects only contents created in languages which code are inthe form lc-cc(lc, language code; cc, contry code) and its effects appear whenyou have a Lingua Plone installation and a combined language code is used asdefault language for the site -- translations losing their reference to canonicalversions of the content.Keep in mind this package is to be used until an Archetypes version with theproper fix is released, so, probably there won't be another release.Testing the issue-----------------Let's setup our basic test variables::>>> from Products.CMFPlone.utils import getToolByName>>> self.loginAsPortalOwner()>>> portal = self.portal>>> lt = getToolByName(portal,'portal_languages')>>> pp = getToolByName(portal,'portal_properties')This issue is related to the vocabulary used for the language field on thedefault Archetypes types. The vocabulary field does not display combinedlanguage codes, even when this option is set on portal_languages.The default ExtensibleMetadata language field uses the method 'languages' asvocabulary, so we will create a new content and check the returned values.>>> id = portal.invokeFactory(type_name='Document',id='foo', title='Foo')>>> foo = portal.foo>>> languageField = foo.getField('language')>>> defaultVocabulary = 'languages'>>> languages = getattr(foo,defaultVocabulary)()Then we enable combined language codes on our portal. Also we set pt-br asdefault language and disable "Start as Neutral"::>>> defaultLanguage = 'pt-br'>>> supportedLanguages = ['pt-br', 'en','de','no']>>> lt.manage_setLanguageSettings(defaultLanguage,...                              supportedLanguages,...                              setUseCombinedLanguageCodes=True,...                              startNeutral=False)After setting portal_languages to allow combined language codes we should geta large number of languages from the vocabulary, but it doesn't happen as wehave the same results::>>> foo = portal.foo>>> languageField = foo.getField('language')>>> languagesCombined = getattr(foo,defaultVocabulary)()>>> languages == languagesCombinedTrueSo, we now use our vocabulary method and see we will have the complete languagelist::>>> foo = portal.foo>>> languageField = foo.getField('language')>>> newVocabulary = 'languagesVoc'>>> languagesCombined = getattr(foo,newVocabulary)()>>> languages == languagesCombinedFalse>>> 'pt-br' in languagesCombinedTrueAnd if we go back to use only simple language codes ::>>> defaultLanguage = 'en'>>> supportedLanguages = ['en','de','no']>>> lt.manage_setLanguageSettings(defaultLanguage,...                              supportedLanguages,...                              setUseCombinedLanguageCodes=False,...                              startNeutral=False)It must work as planned::>>> foo = portal.foo>>> languageField = foo.getField('language')>>> newVocabulary = 'languagesVoc'>>> languagesCombined = getattr(foo,newVocabulary)()>>> 'pt-br' in languagesCombinedFalseInstalling the fix------------------If your using a buildout-based installation all you need to do is declarearchetypes.languagebugfix in eggs and zcml sections for you instance.Credits-------Development and tests:* `Simples Consultoria <http://www.simplesconsultoria.com.br/>`_(products at simplesconsultoria dot com dot br)Efforts to research and fix this issue were sponsored by:* `TV1 <http://www.tv1.com.br/>`_Changelog=========1.0.2 (2010-03-13)------------------* Explicitly include folder docs [erico_andrei]1.0.1 (2009-12-17)------------------* In some cases our patch is applied after other content types alredy copied theoriginal schema from ExtensibleMetadata, so we patched method itself [erico_andrei]1.0 - (2009-12-17)------------------* fix `issue 8907 <https://dev.plone.org/plone/ticket/8907>`_ by passing argumentto getLanguageListing [erico_andrei]