summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-09-20 14:11:32 -0400
committerAdam Young <ayoung@redhat.com>2010-09-20 15:20:58 -0400
commit97e3602f7be9f96803ff641025949ccc5b067eb3 (patch)
tree16b9d9475b2281de3be1a6866eb3dad660bd4ba2 /ipaserver
parentb47d6c09440799f41ca4aa91014a7829ada06114 (diff)
downloadfreeipa.git-97e3602f7be9f96803ff641025949ccc5b067eb3.tar.gz
freeipa.git-97e3602f7be9f96803ff641025949ccc5b067eb3.tar.xz
freeipa.git-97e3602f7be9f96803ff641025949ccc5b067eb3.zip
I18N of RPC
Uses the HTTP header to perform set the LANG environment variable in Python, used for the gettext translations Author: adam <ayoung@redhat.com>
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/rpcserver.py7
1 files changed, 6 insertions, 1 deletions
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 = """<html>
<head>
<title>404 Not Found</title>
@@ -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):