[Checkins] SVN: Sandbox/ulif/grok-with-i18n/ Sketch of a
grok.registerTranslations directive.
Uli Fouquet
uli at gnufix.de
Sun Sep 16 20:45:52 EDT 2007
Log message for revision 79702:
Sketch of a grok.registerTranslations directive.
Changed:
U Sandbox/ulif/grok-with-i18n/CHANGES.txt
U Sandbox/ulif/grok-with-i18n/doc/reference/directives.tex
U Sandbox/ulif/grok-with-i18n/setup.py
U Sandbox/ulif/grok-with-i18n/src/grok/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.po
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.po
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/mammoth.pot
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations.py
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations_templates/
A Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations_templates/i18nmammothview.pt
U Sandbox/ulif/grok-with-i18n/src/grok/ftests/test_grok_functional.py
A Sandbox/ulif/grok-with-i18n/src/grok/i18n.py
U Sandbox/ulif/grok-with-i18n/src/grok/meta.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/de/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/de/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/de/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/en/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/en/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/en/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/locales/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/de/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/de/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/en/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/en/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/de/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/de/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/en/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/en/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/de/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/de/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/de/LC_MESSAGES/cave.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/en/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/en/LC_MESSAGES/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/en/LC_MESSAGES/cave.mo
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales.py
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales_fixture/
A Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales_fixture/__init__.py
U Sandbox/ulif/grok-with-i18n/src/grok/tests/test_grok.py
-=-
Modified: Sandbox/ulif/grok-with-i18n/CHANGES.txt
===================================================================
--- Sandbox/ulif/grok-with-i18n/CHANGES.txt 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/CHANGES.txt 2007-09-17 00:45:51 UTC (rev 79702)
@@ -14,6 +14,8 @@
* The admin UI now displays and offers deletion of broken objects.
+* Add grok.i18n.registerTranslations directive.
+
Bug fixes
---------
Modified: Sandbox/ulif/grok-with-i18n/doc/reference/directives.tex
===================================================================
--- Sandbox/ulif/grok-with-i18n/doc/reference/directives.tex 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/doc/reference/directives.tex 2007-09-17 00:45:51 UTC (rev 79702)
@@ -213,6 +213,66 @@
foobar
\end{funcdesc}
+ \section{\function{grok.i18n.registerTranslations} -- register a
+ locales directory}
+
+ \begin{funcdesc}{grok.registerTranslations}{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}.
+
+ If no value is given, the default \code{'locales'} is taken.
+
+ The directory must exist in the path given relative to the
+ package wherein the directive was used.
+
+ The directive takes at most one parameter and can be used
+ several times per module.
+
+ 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
+ registered.
+
+ This means especially, that if you do no explicit call to
+ \function{registerTranslations}, but a local directory with
+ name \code{locales} and translations exists, then this
+ directory will be registered.
+
+ You can avoid this behaviour by declaring a different
+ locales directory in every module of your package(s) which
+ also might be empty.
+
+ The following example registers a local \code{locales}
+ directory as a source for translations:
+
+ \begin{verbatim}
+import grok
+grok.i18n.registerTranslations()
+ \end{verbatim}
+
+ 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('locales')
+ \end{verbatim}
+
+ 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')
+ \end{verbatim}
+
+
+ \end{funcdesc}
+
\section{\function{grok.name}}
\begin{funcdesc}{grok.name}{*arg}
Modified: Sandbox/ulif/grok-with-i18n/setup.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/setup.py 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/setup.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -76,6 +76,7 @@
'zope.event',
'zope.formlib',
'zope.hookable',
+ 'zope.i18n',
'zope.i18nmessageid',
'zope.interface == 3.4.0',
'zope.lifecycleevent',
Modified: Sandbox/ulif/grok-with-i18n/src/grok/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/__init__.py 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/src/grok/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -39,6 +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._grok import do_grok as grok # Avoid name clash within _grok
from grok._grok import grok_component
from grok._grok import SubscribeDecorator as subscribe
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,14 @@
+##############################################################################
+#
+# Copyright (c) 2007 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 is a package
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.po
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.po (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/de/LC_MESSAGES/mammoth.po 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2003-2004 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.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Development/Unknown\n"
+"POT-Creation-Date: Fri Sep 14 12:14:56 2007\n"
+"PO-Revision-Date: 2007-09-14 14:23+0100\n"
+"Last-Translator: Uli Fouquet <uli at gnufix.de>\n"
+"Language-Team: Zope 3 Developers <zope3-dev at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: zope/app/locales/extract.py\n"
+
+#: src/grok/admin/mammoth.py:45
+msgid "Manfred"
+msgstr "Manni"
+
+#. Default: "This mammoth is called: ${name}"
+#: src/grok/admin/mammoth.py:48
+msgid "mammoth-is-called"
+msgstr "Dieses Mammut wird ${name} genannt."
+
+#: src/grok/admin/mammoth_templates/mammothview.pt:5
+msgid "mammoth"
+msgstr "Mammut"
+
+#: src/grok/admin/view_templates/inspect.pt:38
+msgid "<unnamed object>"
+msgstr "<unbennantes Objekt>"
+
+#: src/grok/admin/view_templates/inspect.pt:40
+msgid "${parent} <span>${DYNAMIC_CONTENT}</span>"
+msgstr "${parent} <span>${DYNAMIC_CONTENT}</span>"
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.po
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.po (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/en/LC_MESSAGES/mammoth.po 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2003-2004 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.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Development/Unknown\n"
+"POT-Creation-Date: Fri Sep 14 12:14:56 2007\n"
+"PO-Revision-Date: 2007-09-14 14:24+0100\n"
+"Last-Translator: Uli Fouquet <uli at gnufix.de>\n"
+"Language-Team: Zope 3 Developers <zope3-dev at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: zope/app/locales/extract.py\n"
+
+#: src/grok/admin/mammoth.py:45
+msgid "Manfred"
+msgstr "Manni"
+
+#. Default: "This mammoth is called: ${name}"
+#: src/grok/admin/mammoth.py:48
+msgid "mammoth-is-called"
+msgstr "This mammo is called ${name}"
+
+#: src/grok/admin/mammoth_templates/mammothview.pt:5
+msgid "mammoth"
+msgstr "A mammoth"
+
+#: src/grok/admin/view_templates/inspect.pt:38
+msgid "<unnamed object>"
+msgstr "<unnamed object>"
+
+#: src/grok/admin/view_templates/inspect.pt:40
+msgid "${parent} <span>${DYNAMIC_CONTENT}</span>"
+msgstr "${parent} <span>${DYNAMIC_CONTENT}</span>"
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/mammoth.pot
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/mammoth.pot (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/locales/mammoth.pot 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2003-2004 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.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Development/Unknown\n"
+"POT-Creation-Date: Fri Sep 14 14:22:03 2007\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: Zope 3 Developers <zope3-dev at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: zope/app/locales/extract.py\n"
+
+#: src/grok/admin/mammoth.py:45
+msgid "Manfred"
+msgstr ""
+
+#: src/grok/admin/mammoth.py:48
+#. Default: "This mammoth is called: ${name}"
+msgid "mammoth-is-called"
+msgstr ""
+
+#: src/grok/admin/mammoth_templates/mammothview.pt:5
+msgid "mammoth"
+msgstr ""
+
+#: src/grok/admin/view_templates/inspect.pt:38
+msgid "<unnamed object>"
+msgstr ""
+
+#: src/grok/admin/view_templates/inspect.pt:40
+msgid "${parent} <span>${DYNAMIC_CONTENT}</span>"
+msgstr ""
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,116 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+==============================
+grok.i18n.registerTranslations
+==============================
+
+With Grok a set of translations can be provided by using
+grok.i18n.registerTranslation(). The directive takes an [optional]
+directory path as only argument, which is computed relative to the
+defining module.
+
+The directive is a module-level single text directive, which can be
+used several times.
+
+If no translatios directory is given, `locales` will serve as
+default value.
+
+The default locales dir, is also searched for translations, if no
+explicit call to ``registerTranslations`` 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.
+
+ >>> from zope.testbrowser.testing import Browser
+ >>> browser = Browser()
+ >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+
+We fetch the ZMI translation overview, to check whether the mammoth
+domain is registered as translation domain::
+
+ >>> browser.open("http://localhost/++etc++process/@@TranslationDomain.html")
+ >>> contents = browser.contents
+ >>> '<a href="?RELOAD=&domain=mammoth&language=en">' in contents
+ True
+
+Now let's see, whether i18n really works. First we create an
+I18nSavannah, which will automatically contain an I18nMammoth called
+'manfred'::
+
+ >>> browser.open("http://localhost")
+ >>> subform = browser.getForm(name='I18nSavannah')
+ >>> subform.getControl('Name your new app:').value = 'mysavannah'
+ >>> subform.getControl('Create').click()
+
+ >>> print browser.contents
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ ...
+ ...<legend>Installed applications</legend>
+ ...
+ ...<a href="http://localhost/mysavannah">
+ ...
+
+We watch manfred::
+
+ >>> browser.open("http://localhost/mysavannah/manfred")
+ >>> print browser.contents
+ <html>
+ ...<div>A mammoth</div>
+ ...This mammo is called Manfred
+ ...
+
+This is the english translation. See, what we get, if we require
+German docs::
+
+ >>> browser.addHeader('Accept-Language', 'de_DE')
+ >>> browser.open("http://localhost/mysavannah/manfred")
+ >>> print browser.contents
+ <html>
+ ...<div>Mammut</div>
+ ...Dieses Mammut wird Manfred genannt.
+ ...
+
+"""
+import grok
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('mammoth')
+
+# Here we register the local translations dir using the default value
+# ('locales').
+grok.i18n.registerTranslations()
+
+class I18nSavannah(grok.Application, grok.Container):
+ """A place for mammoths.
+ """
+ def __init__(self, *args, **kw):
+ super(I18nSavannah, self).__init__(*args, **kw)
+ self['manfred'] = I18nMammoth()
+
+class I18nMammoth(grok.Model):
+ """An internationalized mammoth.
+ """
+ name = _(u'Manfred')
+
+ def getName(self):
+ return _(u'mammoth-is-called',
+ u"This mammoth is called: ${name}",
+ mapping={'name':self.name}
+ )
+
+class I18nMammothView(grok.View):
+ """An internationalized view.
+ """
+ grok.context(I18nMammoth)
+ grok.name('index')
Added: Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations_templates/i18nmammothview.pt
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations_templates/i18nmammothview.pt (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/i18n/register_translations_templates/i18nmammothview.pt 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,9 @@
+<html xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="mammoth">
+
+ <head />
+ <body>
+ <div i18n:translate="">mammoth</div>
+ <div tal:replace="view/context/getName" />
+ </body>
+</html>
Modified: Sandbox/ulif/grok-with-i18n/src/grok/ftests/test_grok_functional.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/ftests/test_grok_functional.py 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/src/grok/ftests/test_grok_functional.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -50,7 +50,7 @@
def test_suite():
suite = unittest.TestSuite()
for name in ['view', 'staticdir', 'xmlrpc', 'traversal', 'form', 'url',
- 'security', 'utility', 'catalog', 'admin']:
+ 'security', 'utility', 'catalog', 'admin', 'i18n']:
suite.addTest(suiteFromPackage(name))
return suite
Added: Sandbox/ulif/grok-with-i18n/src/grok/i18n.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/i18n.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/i18n.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,87 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""I18n support for grok.
+
+You can find a (more or less) complete i18n-example in ftests.i18n.
+"""
+
+import os
+import grok
+
+from zope.component import provideUtility
+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 martian.error import GrokImportError
+from martian.directive import MultipleTextDirective, ModuleDirectiveContext
+
+DEFAULT_LOCALES_DIR = 'locales'
+
+class RegisterTranslationsDirective(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()"
+ )
+
+ def value_factory(self, *args, **kw):
+ if len(args) == 0:
+ # The default dir. Should we really provide it?
+ return DEFAULT_LOCALES_DIR
+ return args
+
+
+def registerTranslationsDirectory(directory):
+ """A replacement for the ZCML registerTranslations directive.
+
+ Basically, this is the same code as in zope.i18n.zcml, but it
+ calls ``provideUtility()`` directly.
+ """
+ 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))
+ # TODO: We might do some permissions checking before.
+ provideUtility(domain, ITranslationDomain, name)
+ return
+
+
+registerTranslations = RegisterTranslationsDirective(
+ 'grok.i18n.registerTranslations',
+ ModuleDirectiveContext())
Modified: Sandbox/ulif/grok-with-i18n/src/grok/meta.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/meta.py 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/src/grok/meta.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -650,3 +650,39 @@
intids = IntIds()
setupUtility(site, intids, IIntIds)
return intids
+
+
+class I18nRegisterTranslationGrokker(martian.GlobalGrokker):
+ component_class = grok.i18n.RegisterTranslationsDirective
+
+ def grok(self, name, factory, context, module_info, templates):
+ dirslist = module_info.getAnnotation(
+ 'grok.i18n.registerTranslations', [])
+ set_default = False
+ if not dirslist:
+ # This is the default, if a module does not declare a
+ # locales dir.
+ dirslist = [grok.i18n.DEFAULT_LOCALES_DIR]
+ set_default = True
+ if not isinstance(dirslist, type([])):
+ dirslist = [dirslist]
+ for localedir in dirslist:
+ if isinstance(localedir, type(())):
+ localedir = localedir[0]
+ abs_path = module_info.getResourcePath(localedir)
+ if not os.path.isdir(abs_path):
+ if set_default:
+ # We silently ignore non-existing locale dirs,
+ # because we automatically set a default and
+ # cannot expect everybody to make use of this
+ # default locales dir. Maybe we should fail here
+ # loudly.
+ return False
+ else:
+ raise GrokError(
+ "Directory %r declared in %r as locales directory "
+ "for translations does not exist." % (
+ localedir, module_info.dotted_name),
+ None)
+ grok.i18n.registerTranslationsDirectory(abs_path)
+ return True
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1 @@
+# this is a package
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+If no locales dir is explicitly set and the default dir 'locales'
+contains translations, those are used automatically:
+
+ >>> from zope import component
+ >>> from zope.i18n.interfaces import ITranslationDomain
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ Traceback (most recent call last):
+ ...
+ ComponentLookupError: (<InterfaceClass ...ITranslationDomain>, 'mammoth')
+
+ >>> import grok
+ >>> grok.grok('grok.tests.i18n.i18ndefaultlocales_fixture')
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ <zope.i18n.translationdomain.TranslationDomain object at 0x...>
+
+"""
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1 @@
+# this is a package
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/de/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/de/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/en/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18ndefaultlocales_fixture/locales/en/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+It is *not* an error, to provide an empty locales dir:
+
+ >>> import grok
+ >>> grok.grok('grok.tests.i18n.i18nemptylocales_fixture')
+
+"""
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nemptylocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1 @@
+# this is a package
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,35 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+
+If a locales dir is set explicitly and contains translations, those
+are registered automatically:
+
+ >>> from zope import component
+ >>> from zope.i18n.interfaces import ITranslationDomain
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ Traceback (most recent call last):
+ ...
+ ComponentLookupError: (<InterfaceClass ...ITranslationDomain>, 'mammoth')
+
+Yet no mammoth domain available.
+
+ >>> import grok
+ >>> grok.grok('grok.tests.i18n.i18nexplicitlocales_fixture')
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ <zope.i18n.translationdomain.TranslationDomain object at 0x...>
+
+Here it is.
+
+"""
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+import grok
+grok.i18n.registerTranslations('customlocales')
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nexplicitlocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+
+If a non-existing directory is declared as locales dir, an error is
+raised:
+
+ >>> import grok
+ >>> 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.
+
+"""
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nillegallocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,15 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+import grok
+grok.i18n.registerTranslations('land-of-oz')
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+We can register two or more locale directories per module/package:
+
+Make sure, the domains 'mammoth' and 'cave' are not yet registered:
+
+ >>> from zope import component
+ >>> from zope.i18n.interfaces import ITranslationDomain
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ Traceback (most recent call last):
+ ...
+ ComponentLookupError: (<InterfaceClass ...ITranslationDomain>, 'mammoth')
+
+ >>> component.getUtility(ITranslationDomain, 'cave')
+ Traceback (most recent call last):
+ ...
+ ComponentLookupError: (<InterfaceClass ...ITranslationDomain>, 'cave')
+
+Yet no mammoth domain available.
+
+ >>> import grok
+ >>> grok.grok('grok.tests.i18n.i18nmultiplelocales_fixture')
+ >>> component.getUtility(ITranslationDomain, 'mammoth')
+ <zope.i18n.translationdomain.TranslationDomain object at 0x...>
+
+ >>> component.getUtility(ITranslationDomain, 'cave')
+ <zope.i18n.translationdomain.TranslationDomain object at 0x...>
+
+Here they are.
+
+"""
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+import grok
+grok.i18n.registerTranslations('customlocales')
+grok.i18n.registerTranslations('otherlocales')
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/de/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/customlocales/en/LC_MESSAGES/mammoth.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/de/LC_MESSAGES/cave.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/de/LC_MESSAGES/cave.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/en/LC_MESSAGES/cave.mo
===================================================================
(Binary files differ)
Property changes on: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nmultiplelocales_fixture/otherlocales/en/LC_MESSAGES/cave.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2007 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.
+#
+##############################################################################
+"""
+It is okay not to provide a locales directory:
+
+ >>> import grok
+ >>> grok.grok('grok.tests.i18n.i18nnolocales_fixture')
+
+
+"""
+
Added: Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales_fixture/__init__.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales_fixture/__init__.py (rev 0)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/i18n/i18nnolocales_fixture/__init__.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -0,0 +1 @@
+# this is a package
Modified: Sandbox/ulif/grok-with-i18n/src/grok/tests/test_grok.py
===================================================================
--- Sandbox/ulif/grok-with-i18n/src/grok/tests/test_grok.py 2007-09-16 23:55:55 UTC (rev 79701)
+++ Sandbox/ulif/grok-with-i18n/src/grok/tests/test_grok.py 2007-09-17 00:45:51 UTC (rev 79702)
@@ -45,7 +45,7 @@
for name in ['adapter', 'error', 'view', 'event', 'security', 'catalog',
'zcml', 'static', 'utility', 'xmlrpc', 'json', 'container',
'traversal', 'form', 'site', 'grokker', 'directive', 'util',
- 'baseclass', 'annotation', 'application']:
+ 'baseclass', 'annotation', 'application', 'i18n']:
suite.addTest(suiteFromPackage(name))
return suite
More information about the Checkins
mailing list