From 1f89b1714f66b2a7b29f45c30ac90c3b640f8e57 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Fri, 11 May 2012 10:10:17 +0000 Subject: new _e() and _t() i18n helper functions --- langs.inc.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'langs.inc.php') diff --git a/langs.inc.php b/langs.inc.php index 49f326f9d..ad1f34862 100644 --- a/langs.inc.php +++ b/langs.inc.php @@ -138,6 +138,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. * -- cgit v1.2.1