# HG changeset patch # User Thierry Florac # Date 1479200228 -3600 # Node ID b32a124687850cf701f79bc4f0a7858c01a4f7be # Parent 1c56b32cb26d8e55eddc4069acac1d88d42fbb91 Updated vocabulary declaration diff -r 1c56b32cb26d -r b32a12468785 src/pyams_i18n/language.py --- a/src/pyams_i18n/language.py Thu Apr 28 14:36:56 2016 +0200 +++ b/src/pyams_i18n/language.py Tue Nov 15 09:57:08 2016 +0100 @@ -15,12 +15,11 @@ # import standard library # import interfaces -from zope.schema.interfaces import IVocabularyFactory # import packages from pyams_utils.request import check_request -from zope.interface import provider -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry +from pyams_utils.vocabulary import vocabulary_config +from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from pyams_i18n import _ @@ -212,7 +211,7 @@ 'zu': _('Zulu')} -@provider(IVocabularyFactory) +@vocabulary_config(name='PyAMS base languages') class BaseLanguagesVocabulary(SimpleVocabulary): """Base languages vocabulary, matching ISO 639-1 languages codes""" @@ -223,8 +222,6 @@ key=lambda x: x.title) super(BaseLanguagesVocabulary, self).__init__(terms) -getVocabularyRegistry().register('PyAMS base languages', BaseLanguagesVocabulary) - ISO_LANGUAGES = {'aa-ET': _("Afar (Ethiopia)"), 'ab-GE': _("Abkhazian"), @@ -460,7 +457,7 @@ 'zu-ZA': _('Zulu (South Africa)')} -@provider(IVocabularyFactory) +@vocabulary_config(name='PyAMS ISO languages') class ISOLanguagesVocabulary(SimpleVocabulary): def __init__(self, *args, **kw): @@ -469,5 +466,3 @@ terms = sorted([SimpleTerm(v, title=translate(t)) for v, t in ISO_LANGUAGES.items()]) terms.sort(key=lambda x: x.title) super(ISOLanguagesVocabulary, self).__init__(terms) - -getVocabularyRegistry().register('PyAMS ISO languages', BaseLanguagesVocabulary) diff -r 1c56b32cb26d -r b32a12468785 src/pyams_i18n/vocabulary.py --- a/src/pyams_i18n/vocabulary.py Thu Apr 28 14:36:56 2016 +0200 +++ b/src/pyams_i18n/vocabulary.py Tue Nov 15 09:57:08 2016 +0100 @@ -17,20 +17,19 @@ # import interfaces from pyams_i18n.interfaces import INegotiator, II18nManager -from zope.schema.interfaces import IVocabularyFactory # import packages from pyams_i18n.language import BASE_LANGUAGES from pyams_utils.registry import query_utility from pyams_utils.request import check_request from pyams_utils.traversing import get_parent -from zope.interface import provider -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry +from pyams_utils.vocabulary import vocabulary_config +from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from pyams_i18n import _ -@provider(IVocabularyFactory) +@vocabulary_config(name='PyAMS offered languages') class I18nOfferedLanguages(SimpleVocabulary): """I18n offered languages vocabulary""" @@ -43,10 +42,8 @@ terms.append(SimpleTerm(lang, title=translate(BASE_LANGUAGES.get(lang) or _("")))) super(I18nOfferedLanguages, self).__init__(terms) -getVocabularyRegistry().register('PyAMS offered languages', I18nOfferedLanguages) - -@provider(IVocabularyFactory) +@vocabulary_config(name='PyAMS content languages') class I18nContentLanguages(SimpleVocabulary): """I18n content languages vocabulary""" @@ -63,5 +60,3 @@ if (negotiator is None) or (lang != negotiator.server_language): terms.append(SimpleTerm(lang, title=translate(BASE_LANGUAGES.get(lang) or _("")))) super(I18nContentLanguages, self).__init__(terms) - -getVocabularyRegistry().register('PyAMS content languages', I18nContentLanguages)