]>
src.bluestatic.org Git - isso.git/blob - localize.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]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 \*=====================================================================*/
29 $OBJECT = 'Localization System';
36 * This framework handles localization. Localization in new ISSO
37 * applications is done through this framework. Nearly all strings
38 * are passed to the string function, which looks up the string in
39 * a .strings.xml file during runtime. Before release, a C tool
40 * creates the .strings.xml file for translators. Common strings
41 * can be accessed through the get lex function which calls a string
42 * based on unique identifier; this is useful for commonly used strings.
44 * @author Iris Studios, Inc.
45 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
53 * Framework registry object
62 var $localtable = array();
65 * The lex lookup table
68 var $lextable = array();
73 function Localize(&$registry)
75 $this->registry
=& $registry;
79 * Initializes the localization system with a table
81 * @param array Localization table
83 function init_with_table($table)
85 $this->localtable
= $table;
89 * Returns a localized string from the table
91 * @param string Text to localize
93 * @return string Localized string
97 if (defined('ISSO_LOCALIZE_DEBUG'))
99 return '[@"' . $key . '"]';
102 if ($this->localtable
["$key"])
104 return $this->localtable["$key"];
111 * Returns a value from the lex table for a specific code
113 * @param string Lex code
115 * @return string Localized string
117 function getlex($code)
119 if (defined('ISSO_LOCALIZE_DEBUG'))
121 return '&[@"' . $code . '"]';
124 if (isset($this->lextable
["$code"]))
126 return $this->lextable["$code"];
129 trigger_error('Lex code `' . $code . '` did not appear in the lex table', E_USER_ERROR
);
133 * Sets a value in the lex table for easy access of strings
134 * that are commonly used
136 * @param string Lex code
137 * @param string Text equiv
139 function setlex($code, $value)
141 if (isset($this->lextable
["$code"]))
143 trigger_error('Cannot set lex `' . $code . '` : value already exists', E_USER_ERROR);
146 $this->lextable["$code"] = $value;
150 /*=====================================================================*\
151 || ###################################################################
154 || ###################################################################
155 \*=====================================================================*/