From f23cdcbe7a13123a85e0198b02380318091c7c4e Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Thu, 20 Jun 2013 17:52:41 +0000 Subject: [PATCH] parse URL for language parameter lang= e.g.: http://spclient-dev.indexdata.com/?lang=en http://spclient-dev.indexdata.com/?lang=da http://spclient-dev.indexdata.com/?lang=de --- experiments/spclient/mkws.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/experiments/spclient/mkws.js b/experiments/spclient/mkws.js index 6403442..9b339fa 100644 --- a/experiments/spclient/mkws.js +++ b/experiments/spclient/mkws.js @@ -569,7 +569,7 @@ function mkws_service_proxy_auth(auth_url) { /* locale */ function M(word) { - var lang = mkws_config.lang; + var lang = jQuery.parseQuerystring().lang || mkws_config.lang; if (!lang || !mkws_locale_lang[lang]) return word; @@ -577,5 +577,17 @@ function M(word) { return mkws_locale_lang[lang][word] ? mkws_locale_lang[lang][word] : word; } +jQuery.extend({ + parseQuerystring: function() { + var nvpair = {}; + var qs = window.location.search.replace('?', ''); + var pairs = qs.split('&'); + $.each(pairs, function(i, v){ + var pair = v.split('='); + nvpair[pair[0]] = pair[1]; + }); + return nvpair; +} }); + /* magic */ $(document).ready(function() { mkws_html_all(mkws_config) }); -- 1.7.10.4