]> git.wh0rd.org - tt-rss.git/blobdiff - localized_js.php
remove error_reporting() hacks; set default error reporting level in functions.php
[tt-rss.git] / localized_js.php
index b46ba83b3e25b53176446da205fd91072d9903f3..08eec1affda61182d9633c2ddcc4109fb2274585 100644 (file)
@@ -1,10 +1,20 @@
-<?php 
-require "functions.php";
-header("Content-Type: text/plain; charset=UTF-8");
+<?php
+       define('DISABLE_SESSIONS', true);
 
-function js_decl($s1, $s2) {
-       return "T_messages[\"$s1\"] = \"$s2\";\n";
-}
+       require "functions.php";
+       header("Content-Type: text/plain; charset=UTF-8");
+       
+       function T_js_decl($s1, $s2) {
+               if ($s1 && $s2) {
+                       $s1 = preg_replace("/\n/", "", $s1);
+                       $s2 = preg_replace("/\n/", "", $s2);
+
+                       $s1 = preg_replace("/\"/", "\\\"", $s1);
+                       $s2 = preg_replace("/\"/", "\\\"", $s2);
+
+                       return "T_messages[\"$s1\"] = \"$s2\";\n";
+               }
+       }
 ?>
 
 var T_messages = new Object();
@@ -19,8 +29,16 @@ function __(msg) {
 
 <?php
 
-print js_decl("display feeds", __("display feeds"));
-print js_decl("display tags", __("display tags"));
+       if (ENABLE_TRANSLATIONS) {
 
-?>
+               $l10n = _get_reader();
+
+               for ($i = 0; $i < $l10n->total; $i++) {
+                       $orig = $l10n->get_original_string($i);
+                       $translation = __($orig);
+       
+                       print T_js_decl($orig, $translation);
+               }
+       }
 
+?>