Merge lp:~savoirfairelinux-openerp/openobject-server/translate_warnings_1297525 into lp:openobject-server/7.0

Status: Needs review
Proposed branch: lp:~savoirfairelinux-openerp/openobject-server/translate_warnings_1297525
Merge into: lp:openobject-server/7.0
Diff against target: 69 lines (+9/-7)
3 files modified
openerp/osv/orm.py (+1/-1)
openerp/service/wsgi_server.py (+6/-4)
openerp/tools/translate.py (+2/-2)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/openobject-server/translate_warnings_1297525
Reviewer Review Type Date Requested Status
OpenERP Core Team 2014-03-25 Pending
Review via email: mp+212733@code.launchpad.net

Description of the change

When searching a frame for context, the _() looks for self.localcontext but misses self.context.
The integration of this patch allows for web warnings (such as except_orm) to be translated by _()

To post a comment you must log in.
5266. By Mohammed Shekha(Open ERP) on 2014-04-06

[FIX]Base, Tools Translation: Fixed the issue of translation, warnings, except_orm and which is raised through OpenERPSession class send method or raised xmlrpclib.Fault in xmlrpc_handle_exception_legacy will also not be translatanble, also there is no way through which translation terms which are used outside any module like used in tools and service will not be registered in pot when translation is exported, we need to add those path explicitly.

5267. By El Hadji Dem (http://www.savoirfairelinux.com) on 2014-04-06

[FIX] Fixed instance of ValidateError not being translated

Unmerged revisions

5267. By El Hadji Dem (http://www.savoirfairelinux.com) on 2014-04-06

[FIX] Fixed instance of ValidateError not being translated

5266. By Mohammed Shekha(Open ERP) on 2014-04-06

[FIX]Base, Tools Translation: Fixed the issue of translation, warnings, except_orm and which is raised through OpenERPSession class send method or raised xmlrpclib.Fault in xmlrpc_handle_exception_legacy will also not be translatanble, also there is no way through which translation terms which are used outside any module like used in tools and service will not be registered in pot when translation is exported, we need to add those path explicitly.

5265. By Sandy Carter (http://www.savoirfairelinux.com) on 2014-03-25

Also look for context in self

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/osv/orm.py'
2--- openerp/osv/orm.py 2014-03-05 14:30:50 +0000
3+++ openerp/osv/orm.py 2014-04-06 00:09:30 +0000
4@@ -1554,7 +1554,7 @@
5 )
6 self._invalids.update(fields)
7 if error_msgs:
8- raise except_orm('ValidateError', '\n'.join(error_msgs))
9+ raise except_orm(_('ValidateError'), '\n'.join(error_msgs))
10 else:
11 self._invalids.clear()
12
13
14=== modified file 'openerp/service/wsgi_server.py'
15--- openerp/service/wsgi_server.py 2013-03-01 12:07:44 +0000
16+++ openerp/service/wsgi_server.py 2014-04-06 00:09:30 +0000
17@@ -44,6 +44,7 @@
18 import openerp
19 import openerp.modules
20 import openerp.tools.config as config
21+from openerp.tools.translate import _
22 import websrv_lib
23
24 _logger = logging.getLogger(__name__)
25@@ -123,17 +124,18 @@
26 return response
27
28 def xmlrpc_handle_exception_legacy(e):
29+ code_string = u"%s -- %s\n\n%s"
30 if isinstance(e, openerp.osv.osv.except_osv):
31- fault = xmlrpclib.Fault('warning -- ' + e.name + '\n\n' + e.value, '')
32+ fault = xmlrpclib.Fault(code_string % (_("warning"), e.name, e.value), '')
33 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
34 elif isinstance(e, openerp.exceptions.Warning):
35- fault = xmlrpclib.Fault('warning -- Warning\n\n' + str(e), '')
36+ fault = xmlrpclib.Fault(code_string % (_("warning"), _("Warning"), e), '')
37 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
38 elif isinstance(e, openerp.exceptions.AccessError):
39- fault = xmlrpclib.Fault('warning -- AccessError\n\n' + str(e), '')
40+ fault = xmlrpclib.Fault(code_string % (_("warning"), _("AccessError"), e), '')
41 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
42 elif isinstance(e, openerp.exceptions.AccessDenied):
43- fault = xmlrpclib.Fault('AccessDenied', str(e))
44+ fault = xmlrpclib.Fault(_('AccessDenied'), str(e))
45 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
46 elif isinstance(e, openerp.exceptions.DeferredException):
47 info = e.traceback
48
49=== modified file 'openerp/tools/translate.py'
50--- openerp/tools/translate.py 2014-02-06 10:51:41 +0000
51+++ openerp/tools/translate.py 2014-04-06 00:09:30 +0000
52@@ -196,7 +196,7 @@
53 lang = ctx.get('lang')
54 s = frame.f_locals.get('self', {})
55 if not lang:
56- c = getattr(s, 'localcontext', None)
57+ c = getattr(s, 'localcontext', None) or getattr(s, 'context', None)
58 if c:
59 lang = c.get('lang')
60 if not lang:
61@@ -851,7 +851,7 @@
62 path_list = [root_path,] + apaths
63
64 # Also scan these non-addon paths
65- for bin_path in ['osv', 'report' ]:
66+ for bin_path in ['osv', 'report', 'tools', 'service' ]:
67 path_list.append(os.path.join(config.config['root_path'], bin_path))
68
69 _logger.debug("Scanning modules at paths: ", path_list)