[Zope3-checkins] CVS: Zope3/src/zope/app/i18n - metadirectives.py:1.1 meta.zcml:1.3 metaconfigure.py:1.3

Philipp von Weitershausen philikon at philikon.de
Sun Aug 3 17:59:14 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/i18n
In directory cvs.zope.org:/tmp/cvs-serv10743

Modified Files:
	meta.zcml metaconfigure.py 
Added Files:
	metadirectives.py 
Log Message:
Converted yet another set of ZCML directives.


=== Added File Zope3/src/zope/app/i18n/metadirectives.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""
$Id: metadirectives.py,v 1.1 2003/08/03 20:58:38 philikon Exp $
"""

from zope.interface import Interface
from zope.configuration.fields import GlobalObject, Tokens, Path
from zope.schema import TextLine

class IRegisterTranslationsDirective(Interface):

    directory = Path(
        title=u"Directory",
        description=u"Directory containing the translations",
        required=True
        )

class IDefaultLanguagesDirective(Interface):

    languages = Tokens(
        title=u"Languages",
        description=u"Use these as default languages",
        required=True,
        value_type=TextLine()
        )


=== Zope3/src/zope/app/i18n/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/i18n/meta.zcml:1.2	Wed Dec 25 09:12:53 2002
+++ Zope3/src/zope/app/i18n/meta.zcml	Sun Aug  3 16:58:38 2003
@@ -1,14 +1,22 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
-  <!-- zope.i18n -->
-  <directives namespace="http://namespaces.zope.org/gts">
+<configure
+    xmlns='http://namespaces.zope.org/zope'
+    xmlns:meta="http://namespaces.zope.org/meta"
+    >
 
-    <directive name="registerTranslations"
-               attributes="directory"
-               handler="zope.app.i18n.metaconfigure.registerTranslations" />
+  <meta:directives namespace="http://namespaces.zope.org/gts">
 
-    <directive name="defaultLanguages"
-               attributes="languages"
-               handler="zope.app.i18n.metaconfigure.defaultLanguages" />
+    <meta:directive
+        name="registerTranslations"
+        schema=".metadirectives.IRegisterTranslationsDirective"
+        handler=".metaconfigure.registerTranslations"
+        />
 
-  </directives>
-</zopeConfigure>
+    <meta:directive
+        name="defaultLanguages"
+        schema=".metadirectives.IDefaultLanguagesDirective"
+        handler=".metaconfigure.defaultLanguages"
+        />
+
+  </meta:directives>
+
+</configure>


=== Zope3/src/zope/app/i18n/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/i18n/metaconfigure.py:1.2	Wed Dec 25 09:12:53 2002
+++ Zope3/src/zope/app/i18n/metaconfigure.py	Sun Aug  3 16:58:38 2003
@@ -18,16 +18,11 @@
 """
 
 import os
-from zope.configuration.action import Action
 from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
 from zope.i18n.globaltranslationservice import translationService
 
 def registerTranslations(_context, directory):
-    """ """
-    actions = []
-
-    path = _context.path(directory)
-    path = os.path.normpath(path)
+    path = os.path.normpath(directory)
 
     for language in os.listdir(path):
         lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
@@ -39,15 +34,15 @@
                     catalog = GettextMessageCatalog(language, domain,
                                                     domain_path)
 
-                    actions.append(Action(
+                    _context.action(
                         discriminator = catalog.getIdentifier(),
                         callable = translationService.addCatalog,
-                        args = (catalog,) ))
-    return actions
-
+                        args = (catalog,)
+                        )
 
 def defaultLanguages(_context, languages):
-    langs = [L.strip() for L in languages.split()]
-    return [Action(discriminator = ('gts', languages),
-                   callable = translationService.setLanguageFallbacks,
-                   args = (langs,))]
+    return _context.action(
+        discriminator = ('gts', tuple(languages)),
+        callable = translationService.setLanguageFallbacks,
+        args = (languages,)
+        )




More information about the Zope3-Checkins mailing list