-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge trunk into branch (from 29979 to 30223)
- Loading branch information
Dominik Huber
committed
May 2, 2005
0 parents
commit 53df4ec
Showing
3 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> </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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |