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

Proposed by Mohammed Shekha(Open ERP)
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) Pending
Martin Trigaux (OpenERP) 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)

[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
=== modified file 'openerp/service/wsgi_server.py'
--- openerp/service/wsgi_server.py 2013-03-01 12:07:44 +0000
+++ openerp/service/wsgi_server.py 2014-03-27 11:27:33 +0000
@@ -44,6 +44,7 @@
44import openerp44import openerp
45import openerp.modules45import openerp.modules
46import openerp.tools.config as config46import openerp.tools.config as config
47from openerp.tools.translate import _
47import websrv_lib48import websrv_lib
4849
49_logger = logging.getLogger(__name__)50_logger = logging.getLogger(__name__)
@@ -123,17 +124,18 @@
123 return response124 return response
124125
125def xmlrpc_handle_exception_legacy(e):126def xmlrpc_handle_exception_legacy(e):
127 code_string = u"%s -- %s\n\n%s"
126 if isinstance(e, openerp.osv.osv.except_osv):128 if isinstance(e, openerp.osv.osv.except_osv):
127 fault = xmlrpclib.Fault('warning -- ' + e.name + '\n\n' + e.value, '')129 fault = xmlrpclib.Fault(code_string % (_("warning"), e.name, e.value), '')
128 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)130 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
129 elif isinstance(e, openerp.exceptions.Warning):131 elif isinstance(e, openerp.exceptions.Warning):
130 fault = xmlrpclib.Fault('warning -- Warning\n\n' + str(e), '')132 fault = xmlrpclib.Fault(code_string % (_("warning"), _("Warning"), e), '')
131 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)133 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
132 elif isinstance(e, openerp.exceptions.AccessError):134 elif isinstance(e, openerp.exceptions.AccessError):
133 fault = xmlrpclib.Fault('warning -- AccessError\n\n' + str(e), '')135 fault = xmlrpclib.Fault(code_string % (_("warning"), _("AccessError"), e), '')
134 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)136 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
135 elif isinstance(e, openerp.exceptions.AccessDenied):137 elif isinstance(e, openerp.exceptions.AccessDenied):
136 fault = xmlrpclib.Fault('AccessDenied', str(e))138 fault = xmlrpclib.Fault(_('AccessDenied'), str(e))
137 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)139 response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
138 elif isinstance(e, openerp.exceptions.DeferredException):140 elif isinstance(e, openerp.exceptions.DeferredException):
139 info = e.traceback141 info = e.traceback
140142
=== modified file 'openerp/tools/translate.py'
--- openerp/tools/translate.py 2014-02-06 10:51:41 +0000
+++ openerp/tools/translate.py 2014-03-27 11:27:33 +0000
@@ -196,7 +196,7 @@
196 lang = ctx.get('lang')196 lang = ctx.get('lang')
197 s = frame.f_locals.get('self', {})197 s = frame.f_locals.get('self', {})
198 if not lang:198 if not lang:
199 c = getattr(s, 'localcontext', None)199 c = getattr(s, 'localcontext', None) or getattr(s, 'context', None)
200 if c:200 if c:
201 lang = c.get('lang')201 lang = c.get('lang')
202 if not lang:202 if not lang:
@@ -851,7 +851,7 @@
851 path_list = [root_path,] + apaths851 path_list = [root_path,] + apaths
852852
853 # Also scan these non-addon paths853 # Also scan these non-addon paths
854 for bin_path in ['osv', 'report' ]:854 for bin_path in ['osv', 'report', 'tools', 'service' ]:
855 path_list.append(os.path.join(config.config['root_path'], bin_path))855 path_list.append(os.path.join(config.config['root_path'], bin_path))
856856
857 _logger.debug("Scanning modules at paths: ", path_list)857 _logger.debug("Scanning modules at paths: ", path_list)