* along with this program. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
\r
-// Translation (TODO)\r
-function _($text)\r
+ global $languages_list;\r
+ $languages_list = array ('auto' => 'Automatic',\r
+ 'en' => 'English',\r
+ 'fr' => 'Français');\r
+\r
+/* Translation */\r
+function t ($text)\r
{\r
- return ("$text");\r
+ $cfg = $GLOBALS['cfg'];\r
+ $languages_list = $GLOBALS['languages_list'];\r
+\r
+ /* Detect user's langage if we are in automatic mode. */\r
+ if (strcmp ($cfg['lang'], 'auto') == 0)\r
+ $l = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);\r
+ else\r
+ $l = $cfg['lang'];\r
+\r
+ /* Is the langage in the list ? */\r
+ $found = false;\r
+ foreach ($languages_list as $key => $v)\r
+ if (strcmp ($l, $key) == 0)\r
+ $found = true;\r
+\r
+ /* Get translation execpt for english. */\r
+ if ($found && strcmp ($l, "en"))\r
+ {\r
+ /* $tr is defined in this requirement. */\r
+ require (JIRAFEAU_ROOT . "lib/lang/$l.php");\r
+\r
+ foreach ($tr as $o => $t)\r
+ if (strcmp ($text, $o) == 0)\r
+ return "$t";\r
+ }\r
+ /* Return original text if no translation is found or already in english. */\r
+ return ($text);\r
}\r
\r
-?>
\ No newline at end of file
+?>\r