aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-05-11 10:10:17 +0000
committerRomain d'Alverny <rda@mageia.org>2012-05-11 10:10:17 +0000
commit1f89b1714f66b2a7b29f45c30ac90c3b640f8e57 (patch)
tree1875607fae95e810b24d31e77335428ec2b1737c
parent954f21aee04b66af7a450e6d6370394708dff945 (diff)
downloadwww-1f89b1714f66b2a7b29f45c30ac90c3b640f8e57.tar
www-1f89b1714f66b2a7b29f45c30ac90c3b640f8e57.tar.gz
www-1f89b1714f66b2a7b29f45c30ac90c3b640f8e57.tar.bz2
www-1f89b1714f66b2a7b29f45c30ac90c3b640f8e57.tar.xz
www-1f89b1714f66b2a7b29f45c30ac90c3b640f8e57.zip
new _e() and _t() i18n helper functions
-rw-r--r--langs.inc.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/langs.inc.php b/langs.inc.php
index 49f326f9d..ad1f34862 100644
--- a/langs.inc.php
+++ b/langs.inc.php
@@ -139,6 +139,30 @@ S;
}
/**
+ * Shorthand functions to echo localized strings.
+ *
+ * @param string $s string to localize
+ * @param boolean $ret return value?
+ *
+ * @return null|string
+ *
+ * FIXME Yes, it's terribly wrong/evil to rely on an unknown global $_t.
+ * Solution? rethink the whole i18n thing in an integrated one.
+*/
+function _t($s = null, $opt = null) {
+ if (!is_null($opt))
+ $_t = $opt;
+ else {
+ global $_t;
+ }
+ return ($s == '' ? '-EMPTY-STRING-' : (array_key_exists($s, $_t) ? $_t[$s] : $s));
+}
+
+function _e($s = null) {
+ echo _t($s);
+}
+
+/**
* Class regrouping basic methods for i18n strings in their current forms.
*
*/