Source code for pyams_i18n.include

#
# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
# 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


[docs]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() PageTemplateFile.expression_types['i18n'] = I18nExpr Z3cPageTemplateFile.expression_types['i18n'] = I18nExpr