On 09/20/2010 05:10 PM, Rob Crittenden wrote:
Adam Young wrote:
The previous I18N patch only works if a single language is set in the
headers. Typically, this header is a list, comma separated. THis version
parsese the list and selects the first language.


nack. You should make sure there isn't a weight on the language too.

>>> lang='en-us,en;q=0.5'
>>> lang.split(',')[0].split(';')[0]
'en-us'

>>> lang='en-us;q=1.0,en;q=0.5'
>>> lang.split(',')[0].split(';')[0]
'en-us'

rob
Nice catch.  Thanks.  Here's the updated
>From dc8d885e969a938c39792bc5b1c70368a887e48b Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Mon, 20 Sep 2010 16:44:50 -0400
Subject: [PATCH] language as a list
 Now parsing the list of languages set in the http header, and selecting the first.  Handles weighting as well.

---
 ipaserver/rpcserver.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index f17fe7d..557ba4e 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -35,6 +35,7 @@ from ipalib.compat import json
 from wsgiref.util import shift_path_info
 import base64
 import os
+import string
 _not_found_template = """<html>
 <head>
 <title>404 Not Found</title>
@@ -195,7 +196,8 @@ class WSGIExecutioner(Executioner):
         lang= os.environ['LANG']
         try:
             if ('HTTP_ACCEPT_LANGUAGE' in environ):
-                os.environ['LANG']=environ['HTTP_ACCEPT_LANGUAGE']
+                os.environ['LANG']=string.split(
+                    environ['HTTP_ACCEPT_LANGUAGE'],",")[0].split(';')[0]
             if (
                 environ.get('CONTENT_TYPE', '').startswith(self.content_type)
                 and environ['REQUEST_METHOD'] == 'POST'
-- 
1.7.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to