For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2006 > smarty and GNU gettext









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author smarty and GNU gettext
D_C

2006-05-30, 8:06 am

hi list -

there is a great GNU library for dealing with localisation, that has a
php function gettext()
http://www.php.net/manual/en/function.gettext.php

many high-end PHP projects use this (wordpress, drupal).

I was wondering if there is a way to use this with smarty?

basically gettext is a php function, so if this is used in the middle
of a smarty template, it will make templates really ugly. I think!
Unless there is a clean way to inline php funcs inside smarty...

also, since a php funciton is being called in the middle of a
template, i imagine this stops smarty from being able to pre-compie/
cache the template itself?

So, any suggested approaches?

Can a modifier function work directly on a string? eg if i created a
localize() modifier that called gettext, then:

had a template like this:

{ "message list" | localize }

rather than puttig the english "message list" in a separate tag to be
passed to smarty:

{$messageListTag|localize}

this would require all the tags to be read in ahead of time, and
another level of indirection + probably reading lots of irrelevant
tags per page.

thanks for any help as always!

/dc
--
________________________________________
_______
David "DC" Collier

dc@pikkle.com
skype: callto://d3ntaku
http://www.pikkle.com
+81 (0)80 6521 9559

http://charajam.com$B!!!Z!z%-%c%i"v%8%c%`!z![(B
$B?M5$%-%c%i$H(BJ-POP$B:G?7%R%C%H6J$r<+J,$GAH$_9g$o$;$F(B
$BBT< u(BFlash$B$dCe(BFlash$B$r:n$C$A$c$*$
&!*(B
________________________________________
_______
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com