]> git.wh0rd.org - tt-rss.git/blob - localized_js.php
localized_js didn't use sessions
[tt-rss.git] / localized_js.php
1 <?php
2 set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
3 get_include_path());
4
5 require_once "sessions.php";
6 require_once "functions.php";
7 header("Content-Type: text/plain; charset=UTF-8");
8
9 function T_js_decl($s1, $s2) {
10 if ($s1 && $s2) {
11 $s1 = preg_replace("/\n/", "", $s1);
12 $s2 = preg_replace("/\n/", "", $s2);
13
14 $s1 = preg_replace("/\"/", "\\\"", $s1);
15 $s2 = preg_replace("/\"/", "\\\"", $s2);
16
17 return "T_messages[\"$s1\"] = \"$s2\";\n";
18 }
19 }
20 ?>
21
22 var T_messages = new Object();
23
24 function __(msg) {
25 if (T_messages[msg]) {
26 return T_messages[msg];
27 } else {
28 return msg;
29 }
30 }
31
32 function ngettext(msg1, msg2, n) {
33 return (parseInt(n) > 1) ? msg2 : msg1;
34 }
35
36 <?php
37 $l10n = _get_reader();
38
39 for ($i = 0; $i < $l10n->total; $i++) {
40 $orig = $l10n->get_original_string($i);
41 $translation = __($orig);
42
43 print T_js_decl($orig, $translation);
44 }
45 ?>