]>
src.bluestatic.org Git - bugdar.git/blob - includes/language.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 [#]gpl[#] 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 $lang->setlex('error_invalid_id', $lang->string('That is an invalid ID.'));
27 // ###################################################################
28 // updates the localization cache
29 function build_language_cache($languageid)
33 $bugsys->db
->query("DELETE FROM " . TABLE_PREFIX
. "localization WHERE languageid = $languageid");
35 $localizations = fetch_strings($languageid, true);
36 foreach ($localizations AS $key => $value)
38 $bugsys->db->query("INSERT INTO
" . TABLE_PREFIX . "localization (localkey
, localtext
, languageid
) VALUES ('" . $bugsys->escape($key) . "', '" . $bugsys->escape($value) . "', $languageid)");
42 // ###################################################################
43 // fetches phrases from the system
44 function fetch_strings($languageid, $forcexml = false)
48 $language =& $bugsys->datastore['language']["$languageid"];
52 if (!$language['languageid'])
57 if ($language['debug'] OR $forcexml)
59 if (!file_exists($language['filename']))
61 trigger_error('Cannot load XML strings file', E_USER_WARNING
);
65 $xmldata = file_get_contents($language['filename']);
66 if ($xmldata === false)
68 trigger_error('Error reading XML strings file', E_USER_WARNING
);
72 $xml = $bugsys->xml
->parse($xmldata);
73 foreach ($xml['localization']['string'] AS $string)
75 $locals[ $string['key']['value'] ] = $string['value']['value'];
80 $localizations = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "localization WHERE languageid = $languageid");
81 while ($local = $bugsys->db->fetch_array($localizations))
83 $locals["$local[localkey
]"] = $local['localtext'];
85 $bugsys->db->free_result($localizations);
91 // ###################################################################
92 // determines the user's language
93 function fetch_user_language()
97 if ($bugsys->userinfo['userid'])
99 $languageid = $bugsys->userinfo['languageid'];
100 $language = $bugsys->datastore['language']["$languageid"];
103 if (!$languageid AND is_array($bugsys->datastore
['language']))
105 foreach ($bugsys->datastore
['language'] AS $language)
107 if ($bugsys->options
['defaultlanguage'] == $language['languageid'])
109 $languageid = $language['languageid'];
110 $language = $bugsys->datastore
['language']["$languageid"];
116 $lang['id'] = $language['languageid'];
117 $lang['charset'] = $language['charset'];
118 $lang['direction'] = $language['direction'];
119 $lang['code'] = $language['languagecode'];
124 /*=====================================================================*\
125 || ###################################################################
128 || ###################################################################
129 \*=====================================================================*/