Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Translation plugin

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
jeliasson
Smarty n00b


Joined: 10 Jan 2013
Posts: 3

PostPosted: Thu Jan 10, 2013 8:32 pm    Post subject: Translation plugin Reply with quote

Hi,

I've created a translation module in PHP which I want to call using Smarty.
However, I'm not passing the translation variable(s) to the view and I want to call it like {ABOUT_EMAIL|translate} with the option to pass an argument, e.g. {ABOUT_ME|translate language='en'}.
Would this be possible, or must I threat it was a function, e.g. {translate('ABOUT_ME', 'en')} ?

Thank you
Back to top
View user's profile Send private message
jeliasson
Smarty n00b


Joined: 10 Jan 2013
Posts: 3

PostPosted: Thu Jan 10, 2013 8:43 pm    Post subject: Reply with quote

Nevermind, I will go for a function and use {translate name=ABOUT_ME language=en}
Back to top
View user's profile Send private message
jeliasson
Smarty n00b


Joined: 10 Jan 2013
Posts: 3

PostPosted: Thu Jan 10, 2013 8:44 pm    Post subject: Reply with quote

One question however,
Is it possible to get ABOUT_ME from {translate ABOUT_ME}?
If yes, how?

Also, if is it then possible to pass more arguments? e.g. {translate ABOUT_ME language=en}?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Jan 10, 2013 11:16 pm    Post subject: Reply with quote

Consider a custom modifier which could be use like {'foo'|translate} {'foo'|translate:'en'}

See http://www.smarty.net/docs/en/language.modifiers.tpl and http://www.smarty.net/docs/en/plugins.modifiers.tpl

You may also consider block function plugins which would allow a syntax like

{translate language='en'}foo{/translate}

See http://www.smarty.net/docs/en/plugins.block.functions.tpl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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