]> git.wh0rd.org Git - tt-rss.git/commitdiff
translations support for mobile version
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 16 Dec 2008 07:13:09 +0000 (08:13 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 16 Dec 2008 07:13:09 +0000 (08:13 +0100)
functions.php
mobile/login_form.php
mobile/mobile.js [new file with mode: 0644]
mobile/tt-rss.php

index bb858671914d0cfa0d0c65e775920e59c9cab072..38b11c665cd88cdda3acee6eb501f8d452e38c1a 100644 (file)
                                $lang = $_COOKIE["ttrss_lang"];
                        }
 
+                       /* In login action of mobile version */
+                       if ($_POST["language"] && defined('MOBILE_VERSION')) {
+                               $lang = $_POST["language"];
+                               $_COOKIE["ttrss_lang"] = $lang;
+                       }
+
                        if ($lang) {
                                if (defined('LC_MESSAGES')) {
                                        _setlocale(LC_MESSAGES, $lang);
                                } else {
                                        die("can't setlocale(): please set ENABLE_TRANSLATIONS to false in config.php");
                                }
-                               _bindtextdomain("messages", "locale");
+
+                               if (defined('MOBILE_VERSION')) {
+                                       _bindtextdomain("messages", "../locale");
+                               } else {
+                                       _bindtextdomain("messages", "locale");
+                               }
+
                                _textdomain("messages");
                                _bind_textdomain_codeset("messages", "UTF-8");
                        }
index 567d1aa97451bd83b5141e38f0c03d8c5e5d3ddd..dd5b4acdc5b09a8370528444bf0cfb19dac129bd 100644 (file)
@@ -3,14 +3,50 @@
        <title>Tiny Tiny RSS : Login</title>
        <link rel="stylesheet" type="text/css" href="mobile.css">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+       <script type="text/javascript" charset="utf-8" src="mobile.js"></script>
 </head>
 
+<script type="text/javascript">
+function init() {
+
+       if (arguments.callee.done) return;
+       arguments.callee.done = true;           
+
+       var login = document.forms["loginForm"].login;
+       var click = document.forms["loginForm"].click;
+
+       login.focus();
+       click.disabled = false;
+
+}
+function languageChange(elem) {
+       try {
+               document.forms['loginForm']['click'].disabled = true;
+       
+               var lang = elem[elem.selectedIndex].value;
+               setCookie("ttrss_lang", lang, <?php print SESSION_COOKIE_LIFETIME ?>);
+               window.location.reload();
+       } catch (e) {
+               exception_error("languageChange", e);
+       }
+}
+
+</script>
+
+<script type="text/javascript">
+if (document.addEventListener) {
+       document.addEventListener("DOMContentLoaded", init, null);
+}
+window.onload = init;
+</script>
+
+
 <body>
 
        <div id="content">
        <div id="heading">Tiny Tiny RSS</div>
 
-       <form action="tt-rss.php" method="POST">
+       <form action="tt-rss.php" method="POST" name="loginForm">
        <input type="hidden" name="rt" value="<?php echo $_GET['rt'] ?>">
        <input type="hidden" name="login_action" value="do_login">
 
                <tr><td align='right'><?php echo __("Login:") ?></td><td><input name="login"></td>
                <tr><td align='right'><?php echo __("Password:") ?></td><td><input type="password" name="password"></tr>
 
+               <tr><td align="right"><?php echo __("Language:") ?></td>
+               <td>
+                       <?php
+                               print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
+                                       "style='width : 100%' onchange='languageChange(this)'");
+
+                       ?>
+               </td></tr>
                <tr><td colspan='2'>
-                       <input type="submit" class="button" value="Login">
+               <input type="submit" class="button" value="<?php echo __('Log in') ?>" name="click">
                </td></tr>
                </table>
        </form>
diff --git a/mobile/mobile.js b/mobile/mobile.js
new file mode 100644 (file)
index 0000000..64d5814
--- /dev/null
@@ -0,0 +1,48 @@
+function debug(msg) {
+       // no-op
+}
+
+function setCookie(name, value, lifetime, path, domain, secure) {
+       
+       var d = false;
+       
+       if (lifetime) {
+               d = new Date();
+               d.setTime(d.getTime() + (lifetime * 1000));
+       }
+
+       debug("setCookie: " + name + " => " + value + ": " + d);
+       
+       int_setCookie(name, value, d, path, domain, secure);
+
+}
+
+function int_setCookie(name, value, expires, path, domain, secure) {
+       document.cookie= name + "=" + escape(value) +
+               ((expires) ? "; expires=" + expires.toGMTString() : "") +
+               ((path) ? "; path=" + path : "") +
+               ((domain) ? "; domain=" + domain : "") +
+               ((secure) ? "; secure" : "");
+}
+
+function exception_error(location, e, silent) {
+       var msg;
+
+       if (e.fileName) {
+               var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1);
+       
+               msg = "Exception: " + e.name + ", " + e.message + 
+                       "\nFunction: " + location + "()" +
+                       "\nLocation: " + base_fname + ":" + e.lineNumber;
+
+       } else if (e.description) {
+               msg = "Exception: " + e.description + "\nFunction: " + location + "()";
+       } else {
+               msg = "Exception: " + e + "\nFunction: " + location + "()";
+       }
+
+       if (!silent) {
+               alert(msg);
+       }
+}
+
index a23bc8b6a943bd1abe3f2f0ec1d113fec138f8e2..9521e66dcdb671fdaf9d2c087788f65e5728fdb9 100644 (file)
@@ -1,6 +1,8 @@
 <?php
        error_reporting(E_ERROR | E_WARNING | E_PARSE);
 
+       define('MOBILE_VERSION', true);
+
        require_once "../config.php";
        require_once "functions.php";
        require_once "../functions.php";