Update of /cvsroot/phpwebapp/web_app/l10n
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19477/l10n
Modified Files:
wbJSL10n.php class.L10n.php
Log Message:
- solved multiple lines problem
- fixed some problems with translating JS messages
Index: wbJSL10n.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/l10n/wbJSL10n.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** wbJSL10n.php 21 Jun 2005 08:39:51 -0000 1.1
--- wbJSL10n.php 22 Jun 2005 12:56:28 -0000 1.2
***************
*** 33,40 ****
$arr_msg = array();
! for ($i=0; $i < sizeof($webPage->js_i18n_messages); $i++)
{
! $msgid = $webPage->js_i18n_messages[$i];
! $msgstr = T_($msgid);
$arr_msg[] = "l10n.addMsg(\"$msgid\", \"$msgstr\");";
}
--- 33,46 ----
$arr_msg = array();
! while ( list($msgid, $msgstr) = each($webPage->js_i18n_messages) )
{
! //remove an extra slash and newline
! $msgid = str_replace("\\\n", "", $msgid);
!
! //replace newlines by '\n' (otherwise JS error will occur)
! $msgid = str_replace("\n", "\\n", $msgid);
! $msgstr = str_replace("\n", "\\n", $msgstr);
!
! //add the translation in the list of messages
$arr_msg[] = "l10n.addMsg(\"$msgid\", \"$msgstr\");";
}
Index: class.L10n.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/l10n/class.L10n.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** class.L10n.php 21 Jun 2005 08:39:51 -0000 1.3
--- class.L10n.php 22 Jun 2005 12:56:29 -0000 1.4
***************
*** 123,126 ****
--- 123,130 ----
$str2translate = $regs[0];
$original = $regs[1];
+
+ //replace '\n' by newline
+ $original = ereg_replace("\\\\n(\\\\ *\n)", "\n\\1", $original);
+
$translation = T_($original);
$text = str_replace($str2translate, $translation, $text);
***************
*** 305,322 ****
* the translation of a string, like this: $var = T_("...");
*/
! function T_($str)
{
if (USE_PHP_GETTEXT)
{
global $l10n;
if (isset($l10n->php_gettext))
! return $l10n->php_gettext->translate($str);
else
! return $str;
}
else //use GNU gettext
{
! return gettext($str);
}
}
?>
\ No newline at end of file
--- 309,331 ----
* the translation of a string, like this: $var = T_("...");
*/
! function T_($msgid)
{
+ //remove the slash at the end of the lines (used for multiple lines)
+ $msgid = ereg_replace("\\\\ *\n", "", $msgid);
+
if (USE_PHP_GETTEXT)
{
global $l10n;
if (isset($l10n->php_gettext))
! $msgstr = $l10n->php_gettext->translate($msgid);
else
! $msgstr = $msgid;
}
else //use GNU gettext
{
! $msgstr = gettext($msgid);
}
+
+ return $msgstr;
}
?>
\ No newline at end of file
|