Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

[Solved]Creation on a custom function for {_("")}

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
zakwil
Smarty n00b


Joined: 30 Jul 2014
Posts: 4
Location: France

PostPosted: Wed Jul 30, 2014 7:24 am    Post subject: [Solved]Creation on a custom function for {_("")} Reply with quote

Hello,

I want to display multilingual text with smarty3, I tried to use {_("text")}, which displays 'text', but I want to add custom php code to handle the i18n.

Can someone could tell me where should I put my php code?

Solution : In the cache dir the I found : <?php echo _("textned");?>
I just need to handle the php function _()
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 30, 2014 8:51 pm    Post subject: Reply with quote

The '_' function is an alias for the PHP gettext function. It can't be redeclared.

A possible solution would be to implement a modifier.
See http://www.smarty.net/docs/en/plugins.modifiers.tpl

Which could be called like this:
Code:
{"text"|t}
Back to top
View user's profile Send private message
zakwil
Smarty n00b


Joined: 30 Jul 2014
Posts: 4
Location: France

PostPosted: Thu Jul 31, 2014 6:14 am    Post subject: Reply with quote

Yes, a modifer call simply "t" is another good solution.

I can use the _() function because I don't add the php gettext extension ; that was my first choice, but I get a bug with the bindtextdomain...

Thanks for your answser by the way.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP