From 03fc8a1bce033cc8334f588f3c95baffa1291b54 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 24 May 2015 16:30:40 -0400 Subject: Avoid creating multiple instances of Translator --- app/functions.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'app/functions.php') diff --git a/app/functions.php b/app/functions.php index 439375be..e4b38cdd 100644 --- a/app/functions.php +++ b/app/functions.php @@ -9,8 +9,7 @@ use Core\Translator; */ function t() { - $t = new Translator; - return call_user_func_array(array($t, 'translate'), func_get_args()); + return call_user_func_array(array(Translator::getInstance(), 'translate'), func_get_args()); } /** @@ -20,19 +19,7 @@ function t() */ function e() { - $t = new Translator; - return call_user_func_array(array($t, 'translateNoEscaping'), func_get_args()); -} - -/** - * Translate a currency - * - * @return string - */ -function c($value) -{ - $t = new Translator; - return $t->currency($value); + return call_user_func_array(array(Translator::getInstance(), 'translateNoEscaping'), func_get_args()); } /** @@ -42,8 +29,7 @@ function c($value) */ function n($value) { - $t = new Translator; - return $t->number($value); + return Translator::getInstance()->number($value); } /** @@ -53,8 +39,7 @@ function n($value) */ function dt($format, $timestamp) { - $t = new Translator; - return $t->datetime($format, $timestamp); + return Translator::getInstance()->datetime($format, $timestamp); } /** @@ -67,5 +52,3 @@ function p($value, $t1, $t2) { return $value > 1 ? $t2 : $t1; } - - -- cgit v1.2.3