Updated package include to add translations
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Dec 2016 15:41:11 +0100
changeset 17 5a04bf80d3d9
parent 16 9a029b3a5cd1
child 18 2760efac78bc
Updated package include to add translations
src/pyams_catalog/__init__.py
src/pyams_catalog/configure.zcml
src/pyams_catalog/include.py
--- a/src/pyams_catalog/__init__.py	Thu Oct 08 09:50:57 2015 +0200
+++ b/src/pyams_catalog/__init__.py	Tue Dec 27 15:41:11 2016 +0100
@@ -20,5 +20,9 @@
 def includeme(config):
     """Pyramid include"""
 
+    # add translations
+    config.add_translation_dirs('pyams_catalog:locales')
+
+    # load components
     from .include import include_package
     include_package(config)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_catalog/configure.zcml	Tue Dec 27 15:41:11 2016 +0100
@@ -0,0 +1,10 @@
+<configure
+	xmlns="http://pylonshq.com/pyramid"
+	xmlns:i18n="http://namespaces.zope.org/i18n">
+
+	<include package="pyramid_zcml" />
+	<include package="zope.i18n" file="meta.zcml" />
+
+	<i18n:registerTranslations directory="locales" />
+
+</configure>
--- a/src/pyams_catalog/include.py	Thu Oct 08 09:50:57 2015 +0200
+++ b/src/pyams_catalog/include.py	Tue Dec 27 15:41:11 2016 +0100
@@ -24,4 +24,12 @@
     """Pyramid include"""
 
     # load registry components
-    config.scan()
+    try:
+        import pyams_zmi
+    except ImportError:
+        config.scan(ignore='pyams_catalog.zmi')
+    else:
+        config.scan()
+
+    if hasattr(config, 'load_zcml'):
+        config.load_zcml('configure.zcml')