Using smarty default variable modifier with gettext
-
21-08-2019 - |
Question
I'm currently using smarty with zend framework, and I have set up smarty to use gettext in the following manner:
{gettext text="resource-identifier"}
This works properly, but I got a problem when trying to use this with the smarty default variable handler. I want to do this:
{$somevar|default:gettext text="resource-identifier"}
But this only prints 'gettext'. Any suggestions to how I can do this. Is it even possible?
Solution
For smarty, chaining a result of a function isn't possible like that. You'll need to see if gettext can assign its result to a variable (an assign=varname param), or write your own (and at that point just write a new modifier that is like default_gettext:'resource-id')
in the assumed assign, it'd look like:
{gettext text="resource-id" assign="myvar"}
{$somevar|default:$myvar}
In the new modifier it'd look like:
{$somevar|default_gettext:"resource-id"}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow