Commit b6e30aa3 authored by Bartek Górny's avatar Bartek Górny

Made lang an explicit named argument (to make it cleaner). Added a docstring.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17526 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c133d266
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -68,11 +65,17 @@ ...@@ -68,11 +65,17 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.CMFCore.utils import getToolByName\n <value> <string>"""\n
Translate message into another language.\n
If \'lang\' is omitted a selected user interface language is used.\n
Can use any of existing message catalogs (default is \'ui\').\n
"""\n
\n
from Products.CMFCore.utils import getToolByName\n
translation_service = getToolByName(context, \'Localizer\', None)\n translation_service = getToolByName(context, \'Localizer\', None)\n
if translation_service is not None :\n if translation_service is not None :\n
try:\n try:\n
return translation_service.translate(catalog, msg, **kw).encode(encoding)\n return translation_service.translate(catalog, msg, lang, **kw).encode(encoding)\n
except AttributeError: # This happens in unit testing, because it is not able to find something with get_context()\n except AttributeError: # This happens in unit testing, because it is not able to find something with get_context()\n
pass\n pass\n
return msg\n return msg\n
...@@ -98,7 +101,7 @@ return msg\n ...@@ -98,7 +101,7 @@ return msg\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>msg, catalog="ui", encoding=\'utf8\', **kw</string> </value> <value> <string>msg, catalog="ui", encoding=\'utf8\', lang=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -118,7 +121,7 @@ return msg\n ...@@ -118,7 +121,7 @@ return msg\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>3</int> </value> <value> <int>4</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -127,6 +130,7 @@ return msg\n ...@@ -127,6 +130,7 @@ return msg\n
<string>msg</string> <string>msg</string>
<string>catalog</string> <string>catalog</string>
<string>encoding</string> <string>encoding</string>
<string>lang</string>
<string>kw</string> <string>kw</string>
<string>Products.CMFCore.utils</string> <string>Products.CMFCore.utils</string>
<string>getToolByName</string> <string>getToolByName</string>
...@@ -150,6 +154,7 @@ return msg\n ...@@ -150,6 +154,7 @@ return msg\n
<tuple> <tuple>
<string>ui</string> <string>ui</string>
<string>utf8</string> <string>utf8</string>
<none/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment