From 718018160bb63e7c1834c63c242d46707db38d22 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 21 Nov 2005 09:32:01 +0000 Subject: [PATCH] Have phrase string parsing working; there was a problem with slashes before --- template.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/template.php b/template.php index 3af69c2..2eeeeaf 100644 --- a/template.php +++ b/template.php @@ -394,7 +394,7 @@ class Template $location_end = -1; // Process the empty phrase objects -- do this now so we don't have to worry about it when we're parsing later - $template = preg_replace('#\{@\\\"(.*?)\\\"\}#i', '" . ' . $this->langcall . '(\'$1\') . "', $template); + $template = preg_replace('#\{@\\\"(.*?)\\\"\}#ie', '$this->_phrase_string(\'$1\')', $template); while (1) { @@ -444,7 +444,7 @@ class Template $phrase_name = preg_replace('#(.*?)#i', '$2', $phrase_bunch); // Wrap the parsed data into the build function - $function_wrap = '" . ' . $this->langconst . '("' . $phrase_name . '", "' . implode('", "', $arglist) . '") . "'; + $function_wrap = '" . ' . $this->langconst . '("' . /*str_replace(array('\"', "'"), array('"', "\'"),*/ $phrase_name/*)*/ . '", "' . implode('", "', $arglist) . '") . "'; // Replace the fully-parsed string back into the template $template = substr_replace($template, $function_wrap, $location_start, $location_end + strlen($tag_end) - $location_start); @@ -455,6 +455,18 @@ class Template return $template; } + /** + * Turns a localized phrase tag into a function call + * + * @param string Phrase text + * + * @return string Function call for phrase text + */ + function _phrase_string($text) + { + return '" . ' . $this->langcall . '(\'' . str_replace(array('\\\"', "'"), array('"', "\'"), $text) . '\') . "'; + } + /** * Parser for in-line template conditionals * -- 2.22.5