Function to translate widget
-
Hi,
I’m trying to automatically translate my widget into different languages, so I use the following code :/** * Return translation text * * @param $token * * @return mixed */ $LANG="fr"; function __($token) { global $LANG; $translations = include('./lang/' . $LANG . '.php'); if (empty($LANG) || empty('translations') || !array_key_exists($token, $translations)) { return $token; } else { return $translations[$token]; } } } /** * Display translation text * * @param $token * @param null $lang */ function _e($token, $lang = null) { echo __($token, $lang); }But with this code I get the error : Fatal error: Cannot redeclare __() (previously declared …
I don’t know if this function is used in a hook cause the name is very strange.
Have you a solution ?
Thanks, for your help.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Function to translate widget’ is closed to new replies.