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 \*=====================================================================*/
32 * This framework handles localization. Localization in new ISSO
33 * applications is done through this framework. Nearly all strings
34 * are passed to the string function, which looks up the string in
35 * a .strings.xml file during runtime. Before release, mkstrings
36 * creates the .strings.xml file for translators. Common strings
37 * can be accessed through the get lex function which calls a string
38 * based on unique identifier; this is useful for commonly used strings.
40 * @author Iris Studios, Inc.
41 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
49 * Framework registry object
58 var $localtable = array();
61 * The lex lookup table
64 var $lextable = array();
69 function __construct(&$registry)
71 $this->registry
=& $registry;
77 function Localize(&$registry)
79 $this->__construct($registry);
83 * Initializes the localization system with a table
85 * @param array Localization table
87 function init_with_table($table)
89 $this->localtable
= $table;
93 * Returns a localized string from the table
95 * @param string Text to localize
97 * @return string Localized string
101 if (defined('ISSO_LOCALIZE_DEBUG'))
103 return '[@"' . $key . '"]';
106 if (isset($this->localtable
["$key"]))
108 return $this->localtable
["$key"];
115 * Returns a value from the lex table for a specific code
117 * @param string Lex code
119 * @return string Localized string
121 function getlex($code)
123 if (defined('ISSO_LOCALIZE_DEBUG'))
125 return '&[@"' . $code . '"]';
128 if (isset($this->lextable
["$code"]))
130 return $this->lextable
["$code"];
133 trigger_error('Lex code `' . $code . '` did not appear in the lex table', E_USER_ERROR
);
137 * Sets a value in the lex table for easy access of strings
138 * that are commonly used
140 * @param string Lex code
141 * @param string Text equiv
143 function setlex($code, $value)
145 if (isset($this->lextable
["$code"]))
147 trigger_error('Cannot set lex `' . $code . '` : value already exists', E_USER_ERROR
);
150 $this->lextable
["$code"] = $value;
154 /*=====================================================================*\
155 || ###################################################################
158 || ###################################################################
159 \*=====================================================================*/