Skip to content

Commit

Permalink
merge trunk into branch (from 29979 to 30223)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Huber committed May 2, 2005
0 parents commit 53df4ec
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 0 deletions.
50 changes: 50 additions & 0 deletions browser/ftests/test_translationdomaincontrol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
##############################################################################
#
# 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.
#
##############################################################################
"""Translation Domain Control Tests
$Id$
"""
import unittest
from zope.app.testing.functional import BrowserTestCase

class ZODBControlTest(BrowserTestCase):

def testDomainOverview(self):
response = self.publish(
'/++etc++process/@@TranslationDomain.html',
basic='globalmgr:globalmgrpw')

body = response.getBody()
self.checkForBrokenLinks(body,
'/++etc++process/@@TranslationDomain.html',
basic='globalmgr:globalmgrpw')

def testReload(self):
response = self.publish('/++etc++process/@@TranslationDomain.html',
basic='globalmgr:globalmgrpw',
form={'language': u'de',
'domain': u'zope',
'RELOAD': u'Reload'})
body = response.getBody()
self.assert_('Message Catalog for de language in zope domain'
' successfully reloaded.' in body)


def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODBControlTest))
return suite

if __name__=='__main__':
unittest.main(defaultTest='test_suite')
48 changes: 48 additions & 0 deletions browser/translationdomaincontrol.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<html metal:use-macro="context/@@standard_macros/view"
i18n:domain="zope">
<head>
<title i18n:translate="">Translation Domains</title>
</head>
<body>
<div metal:fill-slot="body">

<p tal:define="status view/reloadCatalogs"
tal:condition="status"
tal:content="status" />

<div tal:repeat="domainInfo view/getCatalogsInfo">

<div class="row">
<div class="label" i18n:translate="">Domain</div>
<div class="field" tal:content="domainInfo/domain">domain</div>
</div>

<table class="listing">

<thead>
<tr>
<th i18n:translate="">Language</th>
<th i18n:translate="">Files</th>
<th>&nbsp;</th>
</tr>
</thead>

<tr tal:repeat="catalogInfo domainInfo/languagesInfo">
<td tal:content="catalogInfo/language"></td>
<td>
<div tal:repeat="fileName catalogInfo/fileNames"
tal:content="fileName"></div>
</td>
<td>
<a tal:attributes="href string:?RELOAD=&domain=${domainInfo/domain}&language=${catalogInfo/language}"
i18n:translate="reload-button">Reload</a>
</td>
</tr>

</table>

</div>

</div>
</body>
</html>
57 changes: 57 additions & 0 deletions browser/translationdomaincontrol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
##############################################################################
#
# 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.
#
##############################################################################
"""Server Control View
$Id$
"""
__docformat__ = 'restructuredtext'

from zope.i18n.interfaces import ITranslationDomain
from zope.app import zapi
from zope.app.i18n import ZopeMessageIDFactory as _


class TranslationDomainControlView(object):

def getCatalogsInfo(self):
info = []
for name, domain in zapi.getUtilitiesFor(ITranslationDomain):
if not hasattr(domain, 'getCatalogsInfo'):
continue
lang_info = []
info.append({'domain': name, 'languagesInfo': lang_info})
for language, fileNames in domain.getCatalogsInfo().items():
lang_info.append({'language': language,
'fileNames': fileNames})
return info

def reloadCatalogs(self):
"""Do the reloading !"""
status = ''

if 'RELOAD' in self.request:
language = self.request.get('language')
domain = self.request.get('domain')

domain = zapi.getUtility(ITranslationDomain, domain)
for lang, fileNames in domain.getCatalogsInfo().items():
if lang == language:
domain.reloadCatalogs(fileNames)

status = _('Message Catalog for ${language} language'
' in ${domain} domain successfully reloaded.')
status.mapping['language'] = language
status.mapping['domain'] = domain.domain

return status

0 comments on commit 53df4ec

Please sign in to comment.