r19179 - htdocs/trunk/search - Let search use cookie to get language, patch by Tao Wang

Geert Janssens gjanssens at code.gnucash.org
Mon May 17 09:28:28 EDT 2010


Author: gjanssens
Date: 2010-05-17 09:28:28 -0400 (Mon, 17 May 2010)
New Revision: 19179
Trac: http://svn.gnucash.org/trac/changeset/19179

Modified:
   htdocs/trunk/search/namazu-cgi.sh
Log:
Let search use cookie to get language, patch by Tao Wang

Modified: htdocs/trunk/search/namazu-cgi.sh
===================================================================
--- htdocs/trunk/search/namazu-cgi.sh	2010-05-17 13:25:09 UTC (rev 19178)
+++ htdocs/trunk/search/namazu-cgi.sh	2010-05-17 13:28:28 UTC (rev 19179)
@@ -3,15 +3,17 @@
 # Namazu CGI wrapper. Deal with LANG
 #
 
-# compute the langinfo from the PATH_INFO
-langinfo=`echo $PATH_INFO | grep '^/\w*' | sed -e 's#^/\(\w*\).*$#\1#'`
+# compute the langinfo from the $QUERY_STRING
+langinfo=`echo "$QUERY_STRING" | grep -oE '(^|[?&])lang=([a-zA-Z_]+)' | cut -f 2 -d "="`
+if [ -z "$langinfo" ]; then
+  # if cannot get langinfo from $QUERY_STRING, then get it from COOKIE
+  langinfo=`echo "$HTTP_COOKIE" | grep -oE '(^|[?&])lang_cookie=([a-zA-Z_]+)' | cut -f 2 -d "="`
+fi
 
 if [ -n "$langinfo" ] ; then
   LANG="$langinfo"
-  SCRIPT_NAME="$SCRIPT_NAME/$langinfo"
   export LANG
+  echo "Set-Cookie: lang_cookie=$langinfo"
 fi
-#SCRIPT_NAME="$SCRIPT_NAME/"
-export SCRIPT_NAME
 
 exec /var/www/cgi-bin/namazu.cgi



More information about the gnucash-changes mailing list