From 4e22a3b5f3797f11b415c61393cbf42594a4c16d Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Wed, 20 Jun 2012 19:41:33 +0000 Subject: more readable func _d() --- langs.inc.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'langs.inc.php') diff --git a/langs.inc.php b/langs.inc.php index d4bbabb87..bc6ecc07b 100644 --- a/langs.inc.php +++ b/langs.inc.php @@ -148,22 +148,33 @@ S; * @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, $post = ' ') { return _d($s, $opt) . $post; } +/** + * @param string $s + * @param array $opt + * + * @return 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 _d($s = null, $opt = null) { + if ($s == '') + return null; + if (!is_null($opt)) $_t = $opt; else { global $_t; } - return trim(str_replace('{ok}', '', ($s == '' ? '---' : (array_key_exists($s, $_t) ? $_t[$s] : $s)))); + $ret = array_key_exists($s, $_t) ? $_t[$s] : $s; + + return trim(str_replace('{ok}', '', $ret)); } /** -- cgit v1.2.1