Skip to main content
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 for
ExtensibleMetadata language field in Archetypes.

This issue affects only contents created in languages which code are in
the form lc-cc(lc, language code; cc, contry code) and its effects appear when
you have a Lingua Plone installation and a combined language code is used as
default language for the site -- translations losing their reference to canonical
versions of the content.

Keep in mind this package is to be used until an Archetypes version with the
proper 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 the
default Archetypes types. The vocabulary field does not display combined
language codes, even when this option is set on portal_languages.

The default ExtensibleMetadata language field uses the method 'languages' as
vocabulary, 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 as
default 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 get
a large number of languages from the vocabulary, but it doesn't happen as we
have the same results::

>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> languagesCombined = getattr(foo,defaultVocabulary)()
>>> languages == languagesCombined
True

So, we now use our vocabulary method and see we will have the complete language
list::

>>> foo = portal.foo
>>> languageField = foo.getField('language')
>>> newVocabulary = 'languagesVoc'
>>> languagesCombined = getattr(foo,newVocabulary)()
>>> languages == languagesCombined
False
>>> 'pt-br' in languagesCombined
True

And 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 languagesCombined
False

Installing the fix
------------------

If your using a buildout-based installation all you need to do is declare
archetypes.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 the
original 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 argument
to getLanguageListing [erico_andrei]

Release files for archetypes.languagebugfix 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for archetypes.languagebugfix 1.0.2
File Size Uploaded
archetypes.languagebugfix-1.0.2.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for archetypes.languagebugfix 1.0.2
File Interpreter ABI Platform
archetypes.languagebugfix-1.0.2-py2.4.egg Legacy Egg format - - Details

Total release size: 21.5 kB

Release files / archetypes.languagebugfix-1.0.2.tar.gz

Download URL archetypes.languagebugfix-1.0.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7faa57ecf3a2129b745a23d8fac5676a9b34efdf6bf0ca2ee19ca5c42dfce785
BLAKE2b-256 checksum
How to use checksums
c8a95ba536372b45cc396fc2686dc0660f24ca9871678616a30e8e035cf8cb34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / archetypes.languagebugfix-1.0.2-py2.4.egg

Download URL archetypes.languagebugfix-1.0.2-py2.4.egg
Size 10.6 kB
Tags Egg
SHA-256 checksum
How to use checksums
8f467af331937124dd40a417d1b2d6aecd71aef9ec7996b991e12f7801dfa1a2
BLAKE2b-256 checksum
How to use checksums
37458a19855ebd39d635e708d67beb7c377a3655d43eb4608f4d4bd66063bcb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page