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

Smarty native gettext

 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
vorapoap
Smarty Rookie


Joined: 22 Dec 2009
Posts: 32

PostPosted: Fri Dec 17, 2010 4:05 pm    Post subject: Smarty native gettext Reply with quote

I accomplish this {_ Translate Blah Blah...} by using a preFilter + postFilter. By doing so, .tpl.php generated by Smarty will be compatible with any po Editor.

Code:
   
public function _tpl_preFilter($tpl_source) {
      return preg_replace('/\{_ (.*?)\}/',
         '<!--GETTEXT echo _("$1"); /GETTEXT-->',
         $incg.$tpl_source);
}
public function _tpl_postFilter($tpl_source) {
      return preg_replace('/<!--GETTEXT (.*?) \/GETTEXT-->/',
         '<?'.'php $1 ?'.'>',
         $tpl_source);
}


With above code, I can do straight translation by using {_ ...} but can't use it as a argument to other procedure call. This is fine in Smarty2, but since in Smarty3, we can do {blahblah name={...}} so it will be nicer to have this feature in Smarty3
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 -> Feature Requests 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