summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-06-15 17:49:23 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-06-15 17:49:23 +0200
commit09602acc5f754c3e814b4b7de9d9d4d283ed45ff (patch)
tree5c364497d2769f171e9e90b4d99afbe496965528 /lib
parent81e4638f5a7b80d8c8339b1e32644fd234935f89 (diff)
Add two wrappers (_t() and _i())
- _t() is a wrapper for Minz_Translate::t() - Improve coding style of Translate.php - _i() is a wrapper for FreshRSS::icon() - queries.phtml shows how they work - It is a lot easier to read files with these functions :)
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Translate.php34
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php
index e14f783f7..df48350e9 100644
--- a/lib/Minz/Translate.php
+++ b/lib/Minz/Translate.php
@@ -18,28 +18,28 @@ class Minz_Translate {
* $translates est le tableau de correspondance
* $key => $traduction
*/
- private static $translates = array ();
+ private static $translates = array();
/**
* Inclus le fichier de langue qui va bien
* l'enregistre dans $translates
*/
- public static function init () {
- $l = Minz_Configuration::language ();
- self::$language = Minz_Session::param ('language', $l);
+ public static function init() {
+ $l = Minz_Configuration::language();
+ self::$language = Minz_Session::param('language', $l);
$l_path = APP_PATH . '/i18n/' . self::$language . '.php';
- if (file_exists ($l_path)) {
- self::$translates = include ($l_path);
+ if (file_exists($l_path)) {
+ self::$translates = include($l_path);
}
}
/**
* Alias de init
*/
- public static function reset () {
- self::init ();
+ public static function reset() {
+ self::init();
}
/**
@@ -48,24 +48,32 @@ class Minz_Translate {
* @return la valeur correspondante à la clé
* > si non présente dans le tableau, on retourne la clé elle-même
*/
- public static function t ($key) {
+ public static function t($key) {
$translate = $key;
- if (isset (self::$translates[$key])) {
+ if (isset(self::$translates[$key])) {
$translate = self::$translates[$key];
}
- $args = func_get_args ();
+ $args = func_get_args();
unset($args[0]);
- return vsprintf ($translate, $args);
+ return vsprintf($translate, $args);
}
/**
* Retourne la langue utilisée actuellement
* @return la langue
*/
- public static function language () {
+ public static function language() {
return self::$language;
}
}
+
+function _t($key) {
+ $args = func_get_args();
+ unset($args[0]);
+ array_unshift($args, $key);
+
+ return call_user_func_array("Minz_Translate::t", $args);
+}