]>
src.bluestatic.org Git - bugdar.git/blob - includes/language.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 // ###################################################################
14 // LEXICAL STRING CONSTANTS
16 $lang->setlex('error_invalid_id', $lang->string('That is an invalid ID.'));
18 // ###################################################################
19 // updates the localization cache
20 function build_language_cache($languageid)
24 $bugsys->db
->query("DELETE FROM localization WHERE languageid = $languageid");
26 $localizations = fetch_strings($languageid, true);
27 foreach ($localizations AS $key => $value)
29 $bugsys->db->query("INSERT INTO
localization (localkey
, localtext
, languageid
) VALUES ('" . $bugsys->escape($key) . "', '" . $bugsys->escape($value) . "', $languageid)");
33 // ###################################################################
34 // fetches phrases from the system
35 function fetch_strings($languageid, $forcexml = false)
39 $language =& $bugsys->datastore['language']["$languageid"];
43 if (!$language['languageid'])
48 if ($language['debug'] OR $forcexml)
50 if (!file_exists($language['filename']))
52 trigger_error('Cannot load XML strings file', E_USER_WARNING
);
56 $xmldata = file_get_contents($language['filename']);
57 if ($xmldata === false)
59 trigger_error('Error reading XML strings file', E_USER_WARNING
);
63 $xml = $bugsys->xml
->parse($xmldata);
64 foreach ($xml['localization']['string'] AS $string)
66 $locals[ $string['key']['value'] ] = $string['value']['value'];
71 $localizations = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "localization WHERE languageid = $languageid");
72 while ($local = $bugsys->db->fetch_array($localizations))
74 $locals["$local[localkey
]"] = $local['localtext'];
76 $bugsys->db->free_result($localizations);
82 // ###################################################################
83 // determines the user's language
84 function fetch_user_language()
88 if ($bugsys->userinfo['userid'])
90 $languageid = $bugsys->userinfo['languageid'];
91 $language = $bugsys->datastore['language']["$languageid"];
96 foreach ($bugsys->datastore
['language'] AS $language)
98 if ($language['default'])
100 $languageid = $language['languageid'];
101 $language = $bugsys->datastore
['language']["$languageid"];
107 $lang['id'] = $language['languageid'];
108 $lang['charset'] = $language['charset'];
109 $lang['direction'] = $language['direction'];
110 $lang['code'] = $language['languagecode'];
115 /*=====================================================================*\
116 || ###################################################################
119 || ###################################################################
120 \*=====================================================================*/