- foreach ($tr as $o => $t)\r
- if (strcmp ($text, $o) == 0)\r
- return "$t";\r
+ /* Decode JSON. */\r
+ $trans = json_decode ($trans_j, true);\r
+ if ($trans === NULL)\r
+ return $text;\r
+\r
+ /* Try to find translation. */\r
+ if (!array_key_exists ($text, $trans))\r
+ return $text;\r
+\r
+ return $trans[$text];\r
+}\r
+\r
+function json_lang_generator ()\r
+{\r
+ $cfg = $GLOBALS['cfg'];\r
+ $languages_list = $GLOBALS['languages_list'];\r
+\r
+ /* Detect user's langage if we are in automatic mode. */\r
+ if (strcmp ($cfg['lang'], 'auto') == 0)\r
+ {\r
+ if (isset ($_SERVER['HTTP_ACCEPT_LANGUAGE']))\r
+ $l = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);\r
+ else\r
+ $l = "en";\r