2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 // ###################################################################
23 // for those who don't have gettext
25 if (!function_exists('gettext'))
27 function gettext($str) { return $str; }
28 function _($str) { return $str; }
29 function bindtextdomain() {}
30 function textdomain() {}
31 function bind_textdomain_codeset() {}
33 BSApp
::debug('NOTICE: gettext not installed');
36 // ###################################################################
37 // LEXICAL STRING CONSTANTS
39 define('L_INVALID_ID', T('That is an invalid ID.'));
41 // ###################################################################
42 // determines the user's language
43 function fetch_user_language()
47 if (bugdar
::$userinfo['userid'])
49 $languageid = bugdar
::$userinfo['languageid'];
50 $language = bugdar
::$datastore['language']["$languageid"];
53 if (!$languageid AND is_array(bugdar
::$datastore['language']))
55 foreach (bugdar
::$datastore['language'] AS $language)
57 if (bugdar
::$options['defaultlanguage'] == $language['languageid'])
59 $languageid = $language['languageid'];
60 $language = bugdar
::$datastore['language']["$languageid"];
66 $lang['id'] = $language['languageid'];
67 $lang['charset'] = $language['charset'];
68 $lang['direction'] = $language['direction'];
69 $lang['langcode'] = $language['langcode'];
75 * Translation function. This will take in a native (English) string and return either
76 * a translated version or, if it cannot find one, the native string back. If the devgettext
77 * setting is enabled, this will use MOReader to load a .mo file, otherwise it will fall back onto
78 * making a call to _(), the built-in Gettext implementation.
80 * @param string Native string
82 * @return string Translated string
89 if (!bugdar
::$options['devgettext'])
96 require_once './includes/class_mo.php';
97 $info = fetch_user_language();
98 if ($info['langcode'] == null
)
100 BSApp
::debug("cannot translate '$str'");
103 $mo = new MOReader("locale/$info[langcode]/LC_MESSAGES/messages.mo");
109 /*=====================================================================*\
110 || ###################################################################
113 || ###################################################################
114 \*=====================================================================*/