From 97e3602f7be9f96803ff641025949ccc5b067eb3 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Mon, 20 Sep 2010 14:11:32 -0400 Subject: I18N of RPC Uses the HTTP header to perform set the LANG environment variable in Python, used for the gettext translations Author: adam --- ipaserver/rpcserver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ipaserver') diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py index 71d55445..f17fe7d2 100644 --- a/ipaserver/rpcserver.py +++ b/ipaserver/rpcserver.py @@ -34,7 +34,7 @@ from ipalib.util import make_repr from ipalib.compat import json from wsgiref.util import shift_path_info import base64 - +import os _not_found_template = """ 404 Not Found @@ -192,7 +192,10 @@ class WSGIExecutioner(Executioner): result = None error = None _id = None + lang= os.environ['LANG'] try: + if ('HTTP_ACCEPT_LANGUAGE' in environ): + os.environ['LANG']=environ['HTTP_ACCEPT_LANGUAGE'] if ( environ.get('CONTENT_TYPE', '').startswith(self.content_type) and environ['REQUEST_METHOD'] == 'POST' @@ -211,6 +214,8 @@ class WSGIExecutioner(Executioner): 'non-public: %s: %s', e.__class__.__name__, str(e) ) error = InternalError() + finally: + os.environ['LANG']=lang return self.marshal(result, error, _id) def simple_unmarshal(self, environ): -- cgit