[Checkins] SVN: grok/branches/ulif-i18n/ Renamed grok.i18n.registerTranslations to grok.localesdir.

Uli Fouquet uli at gnufix.de
Mon Sep 17 18:52:36 EDT 2007


Log message for revision 79727:
  Renamed grok.i18n.registerTranslations to grok.localesdir.

Changed:
  U   grok/branches/ulif-i18n/CHANGES.txt
  U   grok/branches/ulif-i18n/doc/reference/directives.tex
  U   grok/branches/ulif-i18n/src/grok/__init__.py
  U   grok/branches/ulif-i18n/src/grok/ftests/i18n/register_translations.py
  U   grok/branches/ulif-i18n/src/grok/i18n.py
  U   grok/branches/ulif-i18n/src/grok/meta.py
  U   grok/branches/ulif-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py
  U   grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales.py
  U   grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py
  U   grok/branches/ulif-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py

-=-
Modified: grok/branches/ulif-i18n/CHANGES.txt
===================================================================
--- grok/branches/ulif-i18n/CHANGES.txt	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/CHANGES.txt	2007-09-17 22:52:35 UTC (rev 79727)
@@ -14,7 +14,7 @@
 
 * The admin UI now displays and offers deletion of broken objects.
 
-* Add grok.i18n.registerTranslations directive.
+* Add grok.localesdir directive.
 
 Bug fixes
 ---------

Modified: grok/branches/ulif-i18n/doc/reference/directives.tex
===================================================================
--- grok/branches/ulif-i18n/doc/reference/directives.tex	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/doc/reference/directives.tex	2007-09-17 22:52:35 UTC (rev 79727)
@@ -213,10 +213,10 @@
         foobar
         \end{funcdesc}
 
-    \section{\function{grok.i18n.registerTranslations} -- register a
+    \section{\function{grok.localesdir} -- register a
       locales directory}
 
-        \begin{funcdesc}{grok.registerTranslations}{directory}
+        \begin{funcdesc}{grok.localesdir}{directory}
           A module-level directive, which can be used to register
           a locales directory. It is a Python based equivalent to the
           ZCML directive \code{i18n:registerTranslations}.
@@ -231,12 +231,12 @@
 
           A \class{GlobalGrokker} is called for every module in a
           grokked package. If a module does not provide a
-          \function{registerTranslations} directive, then
-          \code{locales} is assumed as default value and tried to be
+          \function{grok.localesdir} directive, then
+          \code{'locales'} is assumed as default value and tried to be
           registered.
 
           This means especially, that if you do no explicit call to
-          \function{registerTranslations}, but a local directory with
+          \function{localesdir}, but a local directory with
           name \code{locales} and translations exists, then this
           directory will be registered.
 
@@ -247,9 +247,13 @@
           The following example registers a local \code{locales}
           directory as a source for translations:
 
+          If this code resides in a location \code{/foo/bar.py}, then
+          Zope will look for translations in \code{/foo/locales}. The
+          example is a short form for the following:
+
           \begin{verbatim}
 import grok
-grok.i18n.registerTranslations()
+grok.localesdir()
           \end{verbatim}
 
           If this code resides in a location \code{/foo/bar.py}, then
@@ -258,16 +262,21 @@
 
           \begin{verbatim}
 import grok
-grok.i18n.registerTranslations('locales')
+grok.localesdir('locales')
           \end{verbatim}
 
+          This is the explicit form of the implicit behaviour, if no
+          \function{grok.localesdir} is defined explicitly. Different
+          to the default behaviour, grok will complain about a
+          non-exisiting \code{locales} directory.
+
           You can, given that the given directories exist, declare
           several locale-directories, which will all be parsed:
 
           \begin{verbatim}
 import grok
-grok.i18n.registerTranslations('savannah')
-grok.i18n.registerTranslations('landofoz')
+grok.localesdir('savannah')
+grok.localesdir('landofoz')
           \end{verbatim}
          
 

Modified: grok/branches/ulif-i18n/src/grok/__init__.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/__init__.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/__init__.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -39,7 +39,7 @@
 from grok.directive import (context, name, title, template, templatedir,
                             provides, baseclass, global_utility, local_utility,
                             permissions, require, site)
-from grok import i18n
+from grok.i18n import localesdir
 from grok._grok import do_grok as grok  # Avoid name clash within _grok
 from grok._grok import grok_component
 from grok._grok import SubscribeDecorator as subscribe

Modified: grok/branches/ulif-i18n/src/grok/ftests/i18n/register_translations.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/ftests/i18n/register_translations.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/ftests/i18n/register_translations.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -13,7 +13,7 @@
 ##############################################################################
 """
 ==============================
-grok.i18n.registerTranslations
+grok.localesdir
 ==============================
 
 With Grok a set of translations can be provided by using
@@ -28,7 +28,7 @@
 default value.
 
 The default locales dir, is also searched for translations, if no
-explicit call to ``registerTranslations`` was done. This means, that
+explicit call to ``localesdir`` was done. This means, that
 if you do not specify a locales directory in a module and a locales
 directory with translations exist, this directory will be registered
 and the translations therein are provided.
@@ -88,8 +88,10 @@
 _ = MessageFactory('mammoth')
 
 # Here we register the local translations dir using the default value
-# ('locales').
-grok.i18n.registerTranslations()
+# ('locales'). This is not neccessary, because the 'locales' dir would
+# be searched by default for translations. But calling it explicitly,
+# we provoke complains about missing directories.
+grok.localesdir()
 
 class I18nSavannah(grok.Application, grok.Container):
     """A place for mammoths.

Modified: grok/branches/ulif-i18n/src/grok/i18n.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/i18n.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/i18n.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -30,12 +30,11 @@
 
 DEFAULT_LOCALES_DIR = 'locales'
 
-class RegisterTranslationsDirective(MultipleTextDirective):
+class localesdirDirective(MultipleTextDirective):
     def check_arguments(self, directory=DEFAULT_LOCALES_DIR):
         if directory is None:
             raise GrokImportError(u"You must specify a locales directory "
-                                  u"when using "
-                                  u"grok.i18n.registerTranslations()"
+                                  u"when using grok.localesdir()"
                                   )
 
     def value_factory(self, *args, **kw):
@@ -82,6 +81,5 @@
     return
 
 
-registerTranslations = RegisterTranslationsDirective(
-    'grok.i18n.registerTranslations',
-    ModuleDirectiveContext())
+localesdir = localesdirDirective('grok.localesdir',
+                                 ModuleDirectiveContext())

Modified: grok/branches/ulif-i18n/src/grok/meta.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/meta.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/meta.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -653,11 +653,10 @@
 
 
 class I18nRegisterTranslationGrokker(martian.GlobalGrokker):
-    component_class = grok.i18n.RegisterTranslationsDirective
+    component_class = grok.i18n.localesdirDirective
     
     def grok(self, name, factory, context, module_info, templates):
-        dirslist = module_info.getAnnotation(
-            'grok.i18n.registerTranslations', [])
+        dirslist = module_info.getAnnotation('grok.localesdir', [])
         set_default = False
         if not dirslist:
             # This is the default, if a module does not declare a
@@ -680,8 +679,8 @@
                     return False
                 else:
                     raise GrokError(
-                        "Directory %r declared in %r as locales directory "
-                        "for translations does not exist." % (
+                        "localesdir: directory %r declared in %r as "
+                        "locales directory does not exist." % (
                         localedir, module_info.dotted_name),
                         None)
             grok.i18n.registerTranslationsDirectory(abs_path)

Modified: grok/branches/ulif-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -12,5 +12,5 @@
 #
 ##############################################################################
 import grok
-grok.i18n.registerTranslations('customlocales')
+grok.localesdir('customlocales')
 

Modified: grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -20,7 +20,7 @@
   >>> grok.grok('grok.tests.i18n.i18nillegallocales_fixture')
   Traceback (most recent call last):
    ...
-  GrokError: Directory 'land-of-oz' declared in 'grok.tests.i18n.i18nillegallocales_fixture' as locales directory for translations does not exist.
+  GrokError: localesdir: directory 'land-of-oz' declared in 'grok.tests.i18n.i18nillegallocales_fixture' as locales directory does not exist.
 
 """
 

Modified: grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -12,4 +12,4 @@
 #
 ##############################################################################
 import grok
-grok.i18n.registerTranslations('land-of-oz')
+grok.localesdir('land-of-oz')

Modified: grok/branches/ulif-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py
===================================================================
--- grok/branches/ulif-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py	2007-09-17 21:17:17 UTC (rev 79726)
+++ grok/branches/ulif-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py	2007-09-17 22:52:35 UTC (rev 79727)
@@ -12,6 +12,6 @@
 #
 ##############################################################################
 import grok
-grok.i18n.registerTranslations('customlocales')
-grok.i18n.registerTranslations('otherlocales')
+grok.localesdir('customlocales')
+grok.localesdir('otherlocales')
 



More information about the Checkins mailing list