From 7c33dbd479df8b95c0ec05dcacad0666d9550194 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Dec 2008 08:13:09 +0100 Subject: [PATCH] translations support for mobile version --- functions.php | 14 ++++++++++++- mobile/login_form.php | 48 +++++++++++++++++++++++++++++++++++++++++-- mobile/mobile.js | 48 +++++++++++++++++++++++++++++++++++++++++++ mobile/tt-rss.php | 2 ++ 4 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 mobile/mobile.js diff --git a/functions.php b/functions.php index bb8586719..38b11c665 100644 --- a/functions.php +++ b/functions.php @@ -53,6 +53,12 @@ $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); @@ -61,7 +67,13 @@ } 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"); } diff --git a/mobile/login_form.php b/mobile/login_form.php index 567d1aa97..dd5b4acdc 100644 --- a/mobile/login_form.php +++ b/mobile/login_form.php @@ -3,14 +3,50 @@ Tiny Tiny RSS : Login + + + + + +
Tiny Tiny RSS
-
+ @@ -23,8 +59,16 @@ + + + + - +
diff --git a/mobile/mobile.js b/mobile/mobile.js new file mode 100644 index 000000000..64d581410 --- /dev/null +++ b/mobile/mobile.js @@ -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); + } +} + diff --git a/mobile/tt-rss.php b/mobile/tt-rss.php index a23bc8b6a..9521e66dc 100644 --- a/mobile/tt-rss.php +++ b/mobile/tt-rss.php @@ -1,6 +1,8 @@