This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This package provides an implementation wich let’s you implement your own i18n aware content types.

Detailed Documentation

Langauge Switcher

Let’s show how z3c.language.switch works:

Imports and placeless setup:

>>> import zope.component
>>> from zope.app.testing import placelesssetup
>>> from z3c.language.switch import II18nLanguageSwitch
>>> from z3c.language.switch.testing import IContentObject
>>> from z3c.language.switch.testing import II18nContentObject
>>> from z3c.language.switch.testing import I18nContentObject
>>> from z3c.language.switch.testing import I18nContentObjectLanguageSwitch
>>> from z3c.language.switch.testing import ContentObject
>>> placelesssetup.setUp()

Setup test object:

>>> en_title = u'en_title'
>>> obj = I18nContentObject(en_title)
>>> obj.title
u'en_title'

Add additional languages:

>>> de_title = u'de_title'
>>> fr_title = u'fr_title'
>>> deObj = obj.addLanguage('de', de_title)
>>> frObj = obj.addLanguage('fr', fr_title)

Switch default language:

>>> obj.title
u'en_title'
>>> obj.setDefaultLanguage('de')
>>> obj.title
u'de_title'

Remove the ‘en’ language object:

>>> obj._data.keys()
['de', 'en', 'fr']
>>> obj.removeLanguage('en')
>>> obj._data.keys()
['de', 'fr']

Remove default language object will end in a ValueError error:

>>> obj.removeLanguage('de')
Traceback (most recent call last):
...
ValueError: cannot remove default language (de)

Remove nonexistent language object will end in a ValueError error:

>>> obj.removeLanguage('undefined')
Traceback (most recent call last):
...
ValueError: cannot remove nonexistent language (undefined)

Set default language to a non existent language will end in a ValueError:

>>> obj.setDefaultLanguage('en')
Traceback (most recent call last):
...
ValueError: cannot set nonexistent language (en) as default

Access the language directly via the II18nLanguageSwitch adapter, first register the adapter for the I18nContentObject:

>>> zope.component.provideAdapter(I18nContentObjectLanguageSwitch,
...     (II18nContentObject,), provides=II18nLanguageSwitch)

The adapter is set to the default language in the init method:

>>> adapted = II18nLanguageSwitch(obj)
>>> adapted.title
u'de_title'

Change the default language and access the title again, the title should not switch to another language:

>>> obj.setDefaultLanguage('fr')
>>> adapted.title
u'de_title'

Switch the language to ‘fr’ via the adapter:

>>> adapted.setLanguage('fr')
>>> adapted.title
u'fr_title'

Finally, clean up:

>>> placelesssetup.tearDown()

AvailableLanguagesVocabulary Vocabulary

Use this vocabulary for get the available languages from the object itself.

>>> from z3c.language.switch import vocabulary
>>> vocab = vocabulary.AvailableLanguagesVocabulary(obj)
>>> len(vocab._terms)
2
>>> vocab._terms[0].value
'de'
>>> vocab._terms[0].token
'de'
>>> vocab._terms[0].title
'de'
>>> vocab._terms[1].value
'fr'
>>> vocab._terms[1].token
'fr'
>>> vocab._terms[1].title
'fr'

CHANGES

1.1.0 (2009-11-29)

  • adjust dependencies, reflect changes in zope packages

1.0.2 (2008-05-21)

  • Bug: Fix typo + exception handling

1.0.1 (2008-01-24)

  • Bug: Corrected meta-data.

1.0.0 (2008-01-21)

  • Restructure: Moved zope.language.switch to it’s namespace package.
Release History

Release History

1.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
z3c.language.switch-1.1.0.zip (26.0 kB) Copy SHA256 Checksum SHA256 Source Nov 29, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting