# HG changeset patch # User Thierry Florac # Date 1427567243 -3600 # Node ID 08740e98e10920142898c75329ad5c9a65e6c014 # Parent 7a354809b65b2f401cb050b7f8e087adeb7cf015 Changed package include diff -r 7a354809b65b -r 08740e98e109 src/pyams_i18n/__init__.py --- a/src/pyams_i18n/__init__.py Sat Mar 21 01:36:10 2015 +0100 +++ b/src/pyams_i18n/__init__.py Sat Mar 28 19:27:23 2015 +0100 @@ -12,6 +12,7 @@ __docformat__ = 'restructuredtext' + # import standard library from fanstatic import Library @@ -19,7 +20,6 @@ # import packages - from pyramid.i18n import TranslationStringFactory _ = TranslationStringFactory('pyams_i18n') @@ -30,21 +30,5 @@ def includeme(config): """pyams_i18n include features""" - # add translations - config.add_translation_dirs('pyams_i18n:locales') - - # add custom locale negotiator - from pyams_i18n.negotiator import locale_negotiator, get_locale - config.set_locale_negotiator(locale_negotiator) - config.add_request_method(get_locale, 'locale', reify=True) - - # load registry components - try: - import pyams_zmi - except ImportError: - config.scan(ignore='pyams_i18n.zmi') - else: - config.scan() - - if hasattr(config, 'load_zcml'): - config.load_zcml('configure.zcml') + from .include import include_package + include_package(config) diff -r 7a354809b65b -r 08740e98e109 src/pyams_i18n/include.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_i18n/include.py Sat Mar 28 19:27:23 2015 +0100 @@ -0,0 +1,49 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces + +# import packages +from chameleon import PageTemplateFile +from pyams_i18n.expr import I18nExpr +from z3c.pt.pagetemplate import PageTemplateFile as Z3cPageTemplateFile + + +def include_package(config): + """Pyramid package include""" + + # add translations + config.add_translation_dirs('pyams_i18n:locales') + + # add custom locale negotiator + from pyams_i18n.negotiator import locale_negotiator, get_locale + config.set_locale_negotiator(locale_negotiator) + config.add_request_method(get_locale, 'locale', reify=True) + + # load registry components + try: + import pyams_zmi + except ImportError: + config.scan(ignore='pyams_i18n.zmi') + else: + config.scan() + + if hasattr(config, 'load_zcml'): + config.load_zcml('configure.zcml') + + PageTemplateFile.expression_types['intl'] = I18nExpr + Z3cPageTemplateFile.expression_types['intl'] = I18nExpr