Changed package include
authorThierry Florac <tflorac@ulthar.net>
Sat, 28 Mar 2015 19:27:23 +0100
changeset 6 08740e98e109
parent 5 7a354809b65b
child 7 0e4957081cd1
Changed package include
src/pyams_i18n/__init__.py
src/pyams_i18n/include.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)
--- /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 <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
+
+
+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