Update of /cvsroot/phpwebapp/web_app/parser
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8209/parser
Modified Files:
class.Render.php
Log Message:
added translation (i18n/l10n) support
Index: class.Render.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/parser/class.Render.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** class.Render.php 9 Jun 2005 13:12:53 -0000 1.21
--- class.Render.php 13 Jun 2005 06:55:20 -0000 1.22
***************
*** 56,59 ****
--- 56,63 ----
$str = WebApp::replaceVars($str);
+ //translate all T_("xyz") strings
+ global $l10n;
+ if (ereg('T_\\("[^"]*"\\)', $str)) $str = $l10n->translate($str);
+
//extra replacements
$str = $this->other_replaces($str);
***************
*** 262,265 ****
--- 266,278 ----
}
+ //use another translation file, if such a file exists
+ global $l10n;
+ $l10n->pushState();
+ $dir = dirname($file_tpl->filename);
+ $filename = basename($file_tpl->filename);
+ $id = ereg_replace('\\..*$', '', $filename);
+ $l10n->set_translation_file($dir, $id);
+
+ //create a new variable scope
global $tplVars;
$tplVars->pushScope();
***************
*** 275,278 ****
--- 288,292 ----
$tplVars->popScope();
+ $l10n->popState();
if (DEBUG_INCLUDES) $this->output("</div>\n");
***************
*** 280,284 ****
/**
! * Renders the given $main_tpl by rendering its head and its body.
*/
function render_MainTpl($main_tpl)
--- 294,298 ----
/**
! * Renders the given $main_tpl.
*/
function render_MainTpl($main_tpl)
***************
*** 286,294 ****
//the body element was not closed in order to append easily other things
$main_tpl->body->contents .= '</body>';
- /*
- global $webPage;
- print $webPage->template_list();
- exit;
- */
$this->render_FileTpl($main_tpl);
}
--- 300,303 ----
***************
*** 309,312 ****
--- 318,327 ----
}
+ //use another translation file, if such a file exists
+ global $l10n;
+ $l10n->pushState();
+ $l10n->set_translation_file($wobj_tpl->class->path, $wobj_tpl->id);
+
+ //create a new variable scope
global $tplVars;
$tplVars->pushScope();
***************
*** 336,339 ****
--- 351,355 ----
$tplVars->popScope();
+ $l10n->popState();
if (DEBUG_WEBOBJECTS) $this->output("</div>\n");
|