debug('NOTICE: gettext not installed'); } // ################################################################### // LEXICAL STRING CONSTANTS define('L_INVALID_ID', T('That is an invalid ID.')); // ################################################################### // determines the user's language function fetch_user_language() { global $bugsys; if (bugdar::$userinfo['userid']) { $languageid = bugdar::$userinfo['languageid']; $language = bugdar::$datastore['language']["$languageid"]; } if (!$languageid AND is_array(bugdar::$datastore['language'])) { foreach (bugdar::$datastore['language'] AS $language) { if (bugdar::$options['defaultlanguage'] == $language['languageid']) { $languageid = $language['languageid']; $language = bugdar::$datastore['language']["$languageid"]; break; } } } $lang['id'] = $language['languageid']; $lang['charset'] = $language['charset']; $lang['direction'] = $language['direction']; $lang['langcode'] = $language['langcode']; return $lang; } /** * Translation function. This will take in a native (English) string and return either * a translated version or, if it cannot find one, the native string back. If the devgettext * setting is enabled, this will use MOReader to load a .mo file, otherwise it will fall back onto * making a call to _(), the built-in Gettext implementation. * * @param string Native string * * @return string Translated string */ function T($str) { global $bugsys; static $mo; if (!bugdar::$options['devgettext']) { return _($str); } if ($mo === null) { require_once './includes/class_mo.php'; $info = fetch_user_language(); if ($info['langcode'] == null) { $bugsys->debug("cannot translate '$str'"); return $str; } $mo = new MOReader("locale/$info[langcode]/LC_MESSAGES/messages.mo"); } return $mo->T($str); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>