]>
src.bluestatic.org Git - bugdar.git/blob - includes/language.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)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 // LEXICAL STRING CONSTANTS
25 define('L_INVALID_ID', T('That is an invalid ID.'));
27 // ###################################################################
28 // determines the user's language
29 function fetch_user_language()
32 if (Bugdar
::$user['userid']) {
33 $languageid = Bugdar
::$user['languageid'];
34 $language = Bugdar
::$datastore['language']["$languageid"];
37 if (!$language && is_array(Bugdar::$datastore['language'])) {
38 foreach (Bugdar::$datastore['language'] AS $language) {
39 if (Bugdar::$options['defaultlanguage'] == $language['languageid']) {
40 $languageid = $language['languageid'];
41 $language = Bugdar::$datastore['language']["$languageid"];
48 'id' => $language['languageid'],
49 'charset' => $language['charset'],
50 'direction' => $language['direction'],
51 'langcode' => $language['langcode'],
56 * Translation function. This will take in a native (English) string and return either
57 * a translated version or, if it cannot find one, the native string back.
59 * @param string Native string
61 * @return string Translated string
70 require_once './includes/class_mo.php';
71 $info = fetch_user_language();
72 if ($info['langcode'] == null)
74 $bugsys->debug("cannot translate '$str'");
77 $mo = new MOReader("locale
/$info[langcode
]/LC_MESSAGES
/messages
.mo
");