Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv15690/lib
Modified Files:
Template.php
Log Message:
Language independent templates.
Support for get-textification of strings within templates.
$_("string")
[ -> htmlspecialchars(gettext("string")) ]
<tag attrib=_("string") [...]>
[ ->
<tag attrib="<?php echo htmlspecialchars(gettext("string")); ?>"
[...] >
]
<?plugin{-form,-link,} PluginName arg=_("string") [...]?>
[ ->
<?plugin PluginName arg="<?php echo gettext("string"); ?>"
[...] ?>
]
Index: Template.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/Template.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Template.php 2001/11/21 19:46:50 1.3
--- Template.php 2001/11/29 02:59:21 1.4
***************
*** 23,27 ****
foreach (array_unique($m[0]) as $plugin_pi) {
$orig[] = '/' . preg_quote($plugin_pi, '/') . '/s';
! $repl[] = $pluginLoader->expandPI($plugin_pi, $dbi, $request);
}
--- 23,33 ----
foreach (array_unique($m[0]) as $plugin_pi) {
$orig[] = '/' . preg_quote($plugin_pi, '/') . '/s';
! // Plugin args like 'description=_("Get backlinks")' get
! // gettexted.
! // FIXME: move this to WikiPlugin.php.
! $translated_pi = preg_replace('/(\s\w+=)_\("((?:[^"\\\\]|\\.)*)"\)/xse',
! '"\1\"" . gettext("\2") . "\""',
! $plugin_pi);
! $repl[] = $pluginLoader->expandPI($translated_pi, $dbi, $request);
}
***************
*** 36,40 ****
--- 42,60 ----
$repl[] = '$this->_getReplacement("\1", "\2")';
+ // Convert $_("String") to < ?php echo htmlspecialchars(gettext("String")); ? >
+ $orig[] = '/\$_\(("(?:[^"\\\\]|\\.)*")\)/xs';
+ $repl[] = "<?php echo htmlspecialchars(gettext(\\1)); ?>";
+
+ // Convert tag attributes like foo=_("String") to foo="String" (with gettext mapping).
+ $orig[] = '/( < \w [^>]* \w=)_\("((?:[^"\\\\]|\\.)*)"\)/xse';
+ $repl[] = '"\1\"" . htmlspecialchars(gettext("\2")) . "\""';
+
return preg_replace($orig, $repl, $template);
+
+ $ret = preg_replace($orig, $repl, $template);
+ echo QElement('pre', $ret);
+ return $ret;
+
+
}
***************
*** 174,179 ****
function WikiTemplate($template, $page_revision = false) {
global $templates;
!
! $this->TemplateFile(FindLocalizedFile($templates[$template]));
$this->_template_name = $template;
--- 194,200 ----
function WikiTemplate($template, $page_revision = false) {
global $templates;
!
! $this->TemplateFile(FindFile($templates[$template]));
!
$this->_template_name = $template;
|