Merge lp:~openerp-dev/openobject-server/7.0-opw-605743-msh into lp:openobject-server/7.0

Proposed by Mohammed Shekha(Open ERP) on 2014-03-27
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/7.0-opw-605743-msh
Merge into: lp:openobject-server/7.0
Diff against target: 56 lines (+8/-6)
2 files modified
openerp/service/wsgi_server.py (+6/-4)
openerp/tools/translate.py (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-opw-605743-msh
Reviewer Review Type Date Requested Status
Naresh(OpenERP) 2014-03-27 Pending
Martin Trigaux (OpenERP) 2014-03-27 Pending
Review via email: mp+213024@code.launchpad.net

Description of the change

Hello,

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, also considered context attribute in get_lang.

There is also a fix for web-client, branch for web-client is: lp:~openerp-dev/openerp-web/7.0-opw-605743-msh

Demo: Raise any exception like except_osv or except_orm(Test it in any other language), web-client will show Title of dialog like "OpenERP Warning", Warning is not translated.

Also fixed some other translation issue while fixing this, like tools and service using GettextAlias(i.e. _) but these is not going to register in pot because this py files are outside module, it is not inside any module path so explicitly added those py's path.

Also consdiered context attribute of object if there is no localcontext found.

Thanks.

To post a comment you must log in.

Unmerged revisions

5267. By Mohammed Shekha(Open ERP) on 2014-03-27

[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, also considered context attribute in get_lang.

Preview Diff

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