[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ More on MakeZopeAppSmaller:

Philipp von Weitershausen philikon at philikon.de
Fri Apr 7 12:47:43 EDT 2006


Log message for revision 66653:
  More on MakeZopeAppSmaller:
  * Moved i18n:registerTranslations directive handler from zope.app.i18n
    to zope.i18n.
  * Moved l10n-related directives next to the corresponding implementation.
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/app/i18n/configure.zcml
  D   Zope3/branches/jim-adapter/src/zope/app/i18n/locales.zcml
  D   Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml
  D   Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py
  U   Zope3/branches/jim-adapter/src/zope/app/meta.zcml
  A   Zope3/branches/jim-adapter/src/zope/i18n/locales/configure.zcml
  A   Zope3/branches/jim-adapter/src/zope/i18n/meta.zcml
  A   Zope3/branches/jim-adapter/src/zope/i18n/zcml.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/i18n/configure.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/configure.zcml	2006-04-07 16:44:42 UTC (rev 66652)
+++ Zope3/branches/jim-adapter/src/zope/app/i18n/configure.zcml	2006-04-07 16:47:41 UTC (rev 66653)
@@ -78,7 +78,7 @@
       provides="zope.i18n.interfaces.IMessageImportFilter"
       />
 
-  <include file="locales.zcml" />
+  <include package="zope.i18n.locales" />
   <include package=".xmlrpc" />
   <include package=".browser" />
 

Deleted: Zope3/branches/jim-adapter/src/zope/app/i18n/locales.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/locales.zcml	2006-04-07 16:44:42 UTC (rev 66652)
+++ Zope3/branches/jim-adapter/src/zope/app/i18n/locales.zcml	2006-04-07 16:47:41 UTC (rev 66653)
@@ -1,57 +0,0 @@
-<configure
-   xmlns="http://namespaces.zope.org/zope">
-
-  <class class="zope.i18n.format.NumberFormat">
-    <allow interface="zope.i18n.interfaces.INumberFormat" />
-  </class>
-
-  <class class="zope.i18n.format.DateTimeFormat">
-    <allow interface="zope.i18n.interfaces.IDateTimeFormat" />
-  </class>
-
-
-  <class class="zope.i18n.locales.LocaleIdentity">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleIdentity" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleVersion">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleVersion" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleDisplayNames">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleDisplayNames" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleTimeZone">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleTimeZone" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleFormat">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleFormat" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleFormatLength">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleFormatLength" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleCalendar">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleCalendar" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleDates">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleDates" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleCurrency">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleCurrency" />
-  </class>
-
-  <class class="zope.i18n.locales.LocaleNumbers">
-    <allow interface="zope.i18n.interfaces.locales.ILocaleNumbers" />
-  </class>
-
-  <class class="zope.i18n.locales.Locale">
-    <allow interface="zope.i18n.interfaces.locales.ILocale" />
-  </class>
-
-</configure>
\ No newline at end of file

Deleted: Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml	2006-04-07 16:44:42 UTC (rev 66652)
+++ Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml	2006-04-07 16:47:41 UTC (rev 66653)
@@ -1,16 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta"
-    >
-
-  <meta:directives namespace="http://namespaces.zope.org/i18n">
-
-    <meta:directive
-        name="registerTranslations"
-        schema=".metadirectives.IRegisterTranslationsDirective"
-        handler=".metaconfigure.registerTranslations"
-        />
-
-  </meta:directives>
-
-</configure>

Deleted: Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py	2006-04-07 16:44:42 UTC (rev 66652)
+++ Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py	2006-04-07 16:47:41 UTC (rev 66653)
@@ -1,57 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# 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.
-#
-##############################################################################
-"""This module handles the 'i18n' namespace directives.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import os
-
-from zope.app.component.metaconfigure import utility
-from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
-from zope.i18n.testmessagecatalog import TestMessageCatalog
-from zope.i18n.translationdomain import TranslationDomain
-from zope.i18n.interfaces import ITranslationDomain
-
-
-def registerTranslations(_context, directory):
-    path = os.path.normpath(directory)
-    domains = {}
-
-    # Gettext has the domain-specific catalogs inside the language directory,
-    # which is exactly the opposite as we need it. So create a dictionary that
-    # reverses the nesting.
-    for language in os.listdir(path):
-        lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
-        if os.path.isdir(lc_messages_path):
-            for domain_file in os.listdir(lc_messages_path):
-                if domain_file.endswith('.mo'):
-                    domain_path = os.path.join(lc_messages_path, domain_file)
-                    domain = domain_file[:-3]
-                    if not domain in domains:
-                        domains[domain] = {}
-                    domains[domain][language] = domain_path
-
-    # Now create TranslationDomain objects and add them as utilities
-    for name, langs in domains.items():
-        domain = TranslationDomain(name)
-
-        for lang, file in langs.items():
-            domain.addCatalog(GettextMessageCatalog(lang, name, file))
-
-        # make sure we have a TEST catalog for each domain:
-        domain.addCatalog(TestMessageCatalog(name))
-
-        utility(_context, ITranslationDomain, domain, name=name)

Modified: Zope3/branches/jim-adapter/src/zope/app/meta.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/meta.zcml	2006-04-07 16:44:42 UTC (rev 66652)
+++ Zope3/branches/jim-adapter/src/zope/app/meta.zcml	2006-04-07 16:47:41 UTC (rev 66653)
@@ -8,7 +8,7 @@
 <include package="zope.app.publisher" file="meta.zcml" />
 <include package="zope.app.security" file="meta.zcml" />
 <include package="zope.app.form.browser" file="meta.zcml" />
-<include package="zope.app.i18n" file="meta.zcml" />
+<include package="zope.i18n" file="meta.zcml" />
 <include package="zope.app.pagetemplate" file="meta.zcml" />
 <include package="zope.app.schema" file="meta.zcml" />
 <include package="zope.app.container.browser" file="meta.zcml" />

Copied: Zope3/branches/jim-adapter/src/zope/i18n/locales/configure.zcml (from rev 66532, Zope3/branches/jim-adapter/src/zope/app/i18n/locales.zcml)

Copied: Zope3/branches/jim-adapter/src/zope/i18n/meta.zcml (from rev 66532, Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/meta.zcml	2006-04-05 13:52:36 UTC (rev 66532)
+++ Zope3/branches/jim-adapter/src/zope/i18n/meta.zcml	2006-04-07 16:47:41 UTC (rev 66653)
@@ -0,0 +1,16 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta"
+    >
+
+  <meta:directives namespace="http://namespaces.zope.org/i18n">
+
+    <meta:directive
+        name="registerTranslations"
+        schema="zope.i18n.zcml.IRegisterTranslationsDirective"
+        handler="zope.i18n.zcml.registerTranslations"
+        />
+
+  </meta:directives>
+
+</configure>

Copied: Zope3/branches/jim-adapter/src/zope/i18n/zcml.py (from rev 66532, Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/i18n/metaconfigure.py	2006-04-05 13:52:36 UTC (rev 66532)
+++ Zope3/branches/jim-adapter/src/zope/i18n/zcml.py	2006-04-07 16:47:41 UTC (rev 66653)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# 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.
+#
+##############################################################################
+"""This module handles the 'i18n' namespace directives.
+
+$Id$
+"""
+__docformat__ = 'restructuredtext'
+
+import os
+
+from zope.interface import Interface
+from zope.configuration.fields import Path
+from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
+from zope.i18n.testmessagecatalog import TestMessageCatalog
+from zope.i18n.translationdomain import TranslationDomain
+from zope.i18n.interfaces import ITranslationDomain
+from zope.app.component.metaconfigure import utility
+
+class IRegisterTranslationsDirective(Interface):
+    """Register translations with the global site manager."""
+
+    directory = Path(
+        title=u"Directory",
+        description=u"Directory containing the translations",
+        required=True
+        )
+
+def registerTranslations(_context, directory):
+    path = os.path.normpath(directory)
+    domains = {}
+
+    # Gettext has the domain-specific catalogs inside the language directory,
+    # which is exactly the opposite as we need it. So create a dictionary that
+    # reverses the nesting.
+    for language in os.listdir(path):
+        lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
+        if os.path.isdir(lc_messages_path):
+            for domain_file in os.listdir(lc_messages_path):
+                if domain_file.endswith('.mo'):
+                    domain_path = os.path.join(lc_messages_path, domain_file)
+                    domain = domain_file[:-3]
+                    if not domain in domains:
+                        domains[domain] = {}
+                    domains[domain][language] = domain_path
+
+    # Now create TranslationDomain objects and add them as utilities
+    for name, langs in domains.items():
+        domain = TranslationDomain(name)
+
+        for lang, file in langs.items():
+            domain.addCatalog(GettextMessageCatalog(lang, name, file))
+
+        # make sure we have a TEST catalog for each domain:
+        domain.addCatalog(TestMessageCatalog(name))
+
+        utility(_context, ITranslationDomain, domain, name=name)



More information about the Zope3-Checkins mailing list