20 if (file_exists(BASE.
"wcmf/lib/util/class.InifileParser.php"))
21 require_once(BASE.
"wcmf/lib/util/class.InifileParser.php");
59 function get ($message, $parameters=null, $domain=
'',
$lang=
'')
61 if (!file_exists(BASE.
"wcmf/lib/util/class.InifileParser.php"))
64 global $MESSAGE_LANGUAGE;
65 global $MESSAGE_LOCALE_DIR;
70 if ($MESSAGE_LANGUAGE !=
'')
71 $lang = $MESSAGE_LANGUAGE;
73 $lang = $_SERVER[
'HTTP_ACCEPT_LANGUAGE'];
80 $lang = preg_replace(
"/(\w+)_(\w+)/e",
"'\\1_'.strtoupper('\\2')",
$lang);
82 if (strpos(
$lang,
'_') ===
false)
86 if (($useGetText = $parser->getValue(
'usegettext',
'cms')) ===
false)
92 if (function_exists(bindtextdomain) && function_exists(textdomain) && function_exists(gettext))
95 putenv(
"LANGUAGE=".
$lang);
96 putenv(
"LANG=".
$lang);
97 putenv(
"LC_ALL=".
$lang);
98 setlocale(LC_ALL,
$lang);
99 bindtextdomain($domain, $MESSAGE_LOCALE_DIR);
101 $localizedMessage = gettext($message);
104 $localizedMessage = $message;
109 $messageFile = $MESSAGE_LOCALE_DIR.$lang.
"/LC_MESSAGES/messages_".
$lang.
".php";
110 if (file_exists($messageFile))
112 require($messageFile);
113 if (${
"messages_$lang"}[$message] !=
"")
114 $localizedMessage = ${
"messages_$lang"}[$message];
116 $localizedMessage = $message;
119 $localizedMessage = $message;
123 preg_match_all(
"/%([0-9]+)%/", $localizedMessage, $matches);
124 $matches = $matches[1];
125 for ($i=0; $i<
sizeof($matches);$i++)
126 $matches[$i] =
'/\%'.$matches[$i].
'\%/';
128 if (
sizeof($matches) > 0 && is_array($parameters))
129 $localizedMessage = preg_replace($matches, $parameters, $localizedMessage);
131 return $localizedMessage;
143 if (!file_exists(BASE.
"wcmf/lib/util/class.InifileParser.php"))
146 global $MESSAGE_LANGUAGE;
147 global $MESSAGE_LOCALE_DIR;
152 if ($MESSAGE_LANGUAGE !=
'')
153 $lang = $MESSAGE_LANGUAGE;
154 else if (
$lang ==
'')
155 $lang = $_SERVER[
'HTTP_ACCEPT_LANGUAGE'];
160 $lang = preg_replace(
"/(\w+)_(\w+)/e",
"'\\1_'.strtoupper('\\2')",
$lang);
162 if (strpos(
$lang,
'_') ===
false)
167 $messageFile = $MESSAGE_LOCALE_DIR.$lang.
"/LC_MESSAGES/messages_".
$lang.
".php";
168 if (file_exists($messageFile))
170 require($messageFile);
171 return ${
"messages_$lang"};
Use the Message class to output messages. You need not instantiate a Message object because the metho...