Skip to content

Commit

Permalink
Add i18n to errorviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Jun 28, 2011
1 parent 5218c75 commit b64298a
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 6 deletions.
12 changes: 12 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parts =
test
coverage-test
coverage-report
i18n

[test]
recipe = zc.recipe.testrunner
Expand All @@ -20,3 +21,14 @@ recipe = zc.recipe.egg
eggs = z3c.coverage
scripts = coverage=coverage-report
arguments = ('coverage', 'coverage/report')

[i18n]
recipe = z3c.recipe.i18n:i18n
eggs =
zope.i18n
zope.errorview
packages = zope.errorview
domain = zope.errorview
output = src/zope/errorview/i18n/locales
zcml =
<include package="zope.i18n" file="meta.zcml" />
13 changes: 8 additions & 5 deletions src/zope/errorview/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
from zope.errorview.http import UnauthorizedView
from zope.publisher.browser import BrowserPage

# XXX i18n-ing?

from zope.errorview.i18n import _
from zope.i18n import translate

class ExceptionView(ExceptionViewBase, BrowserPage):

def render(self):
return u'A system error occurred.'
msg = _(u'A system error occurred.')
return translate(msg, context=self.request, default=msg)


class NotFoundView(ExceptionViewBase, BrowserPage):
Expand All @@ -33,7 +34,8 @@ def update(self):
self.request.response.setStatus(404)

def render(self):
return u'The requested resource can not be found.'
msg = _(u'The requested resource can not be found.')
return translate(msg, context=self.request, default=msg)


class UnauthorizedView(UnauthorizedView, BrowserPage):
Expand All @@ -54,5 +56,6 @@ def update(self):

def render(self):
if self.request.response.getStatus() not in (302, 303):
return u'Access to the requested resource is forbidden.'
msg = _(u'Access to the requested resource is forbidden.')
return translate(msg, context=self.request, default=msg)
return ''
6 changes: 5 additions & 1 deletion src/zope/errorview/browser.zcml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="zope.errorview">

<include package="zope.browserpage" file="meta.zcml" />
<include package="." file="http.zcml" />

<i18n:registerTranslations directory="i18n/locales" />

<browser:page
for="zope.interface.common.interfaces.IException"
Expand Down
15 changes: 15 additions & 0 deletions src/zope/errorview/i18n/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##############################################################################
#
# Copyright (c) 2011 Zope Foundation 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.
#
##############################################################################
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('zope.errorview')
Binary file not shown.
37 changes: 37 additions & 0 deletions src/zope/errorview/i18n/locales/en/LC_MESSAGES/zope.errorview.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
#
# Copyright (c) 2011 Zope Foundation 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: Meaningless\n"
"POT-Creation-Date: Fri Jun 24 07:59:16 2011\n"
"PO-Revision-Date: 2011-06-24 O7:59+CET\n"
"Last-Translator: Jan-Jaap Driessen <janjaapdriessen@gmail.com>\n"
"Language-Team: Zope 3 Developers <zope-dev@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"

#: zope/errorview/browser.py:26
msgid "A system error occurred."
msgstr "A system error occurred."

#: zope/errorview/browser.py:35
msgid "The requested resource can not be found."
msgstr "The requested resource can not be found."

#: zope/errorview/browser.py:56
msgid "Access to the requested resource is forbidden."
msgstr "Access to the requested resource is forbidden."

Binary file not shown.
37 changes: 37 additions & 0 deletions src/zope/errorview/i18n/locales/nl/LC_MESSAGES/zope.errorview.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
#
# Copyright (c) 2011 Zope Foundation 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: Meaningless\n"
"POT-Creation-Date: Fri Jun 24 07:59:16 2011\n"
"PO-Revision-Date: 2011-06-24 O7:59+CET\n"
"Last-Translator: Jan-Jaap Driessen <janjaapdriessen@gmail.com>\n"
"Language-Team: Zope 3 Developers <zope-dev@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"

#: zope/errorview/browser.py:26
msgid "A system error occurred."
msgstr "Er is een systeem fout opgetreden."

#: zope/errorview/browser.py:35
msgid "The requested resource can not be found."
msgstr "De opgevraagde pagina kan niet worden gevonden."

#: zope/errorview/browser.py:56
msgid "Access to the requested resource is forbidden."
msgstr "Toegang geweigerd."

37 changes: 37 additions & 0 deletions src/zope/errorview/i18n/locales/zope.errorview.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
#
# Copyright (c) 2011 Zope Foundation 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: Meaningless\n"
"POT-Creation-Date: Mon Jun 27 11:18:10 2011\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Zope 3 Developers <zope-dev@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"

#: zope/errorview/browser.py:26
msgid "A system error occurred."
msgstr "A system error occurred."

#: zope/errorview/browser.py:35
msgid "The requested resource can not be found."
msgstr "The requested resource can not be found."

#: zope/errorview/browser.py:56
msgid "Access to the requested resource is forbidden."
msgstr "Access to the requested resource is forbidden."

9 changes: 9 additions & 0 deletions src/zope/errorview/tests/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<include package="zope.component" file="meta.zcml"/>
<include package="zope.security" file="meta.zcml"/>
<include package="zope.i18n" file="meta.zcml"/>

<include package="zope.component"/>
<include package="zope.security"/>
<include package="zope.publisher"/>
<include package="zope.i18n"/>

<include package="zope.errorview" file="browser.zcml" />

<utility
Expand Down

0 comments on commit b64298a

Please sign in to comment.