[dev] gettext + Horde_Templates

Nuno Loureiro nuno at co.sapo.pt
Wed May 14 12:08:22 PDT 2003


I just did a quick patch (completly untested).
I do not have the time to test it now. Will do it tommorrow if nobody
tries it first.



Index: Template.php
===================================================================
RCS file: /repository/horde/lib/Template.php,v
retrieving revision 1.17
diff -u -u -r1.17 Template.php
--- Template.php        23 Jan 2003 18:34:12 -0000      1.17
+++ Template.php        14 May 2003 19:05:33 -0000
@@ -217,6 +217,9 @@
             $contents = $this->parseCloop($key, $array, $contents);
         }

+        // Parse GetText.
+        $contents = $this->parseGetText($contents);
+
         // Reset template data unless we're supposed to keep it
         // around.
         if ($this->_resetVars) {
@@ -227,6 +230,24 @@
         return $contents;
     }

+
+    /**
+     * Parse gettext tags.
+     *
+     * @param string $contents   The unparsed content of the file.
+     *
+     * @return string            The parsed contents of the gettext
blocks.
+     */
+    function parseGetText($contents)
+    {
+        // Get the tags & loop.
+        $t = $this->getTags('trans', 'i18n');
+        while ($gtext = $this->getStatement($t, $contents)) {
+            $contents = str_replace($t['b'] . $gtext . $t['e'],
_("$gtext"), $contents);
+        }
+        return $contents;
+    }
+
     /**
      * Parse a given if statement.
      *







On Wed, 2003-05-14 at 00:32, Jan Schneider wrote:
> Zitat von Marko Djukic <marko at oblo.com>:
> 
> > the one problem with Horde_Templates is having text in templates that can
> > be
> > picked up for inclusion in .po and eventual translation.
> >
> > jan, you were saying that you want to stick with the native php gettext
> > support
> > which relies only on _() tags if i understood right. one thing that
> > doesn't
> > seem to make sense to me is how it could support something which is
> > XML-like
> > (and nothing to do with php) as is the case with Horde_Templates?
> >
> > does it seems a case of mixing apples and oranges?
> 
> Just to let the list know: We found a way to handle translateable strings in
> XML files and will probably use this for the templates.
> 
> Jan.
> 
> --
> http://www.horde.org - The Horde Project
> http://www.ammma.de - discover your knowledge
> http://www.tip4all.de - Deine private Tippgemeinschaft
-- 
Nuno Loureiro <nuno at co.sapo.pt>
PTM.com - http://www.sapo.pt/
PGP fingerprint = 8A32 5174 E80C 2D40 9075 405E C107 6592 054A 4D05



More information about the dev mailing list