|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Fri Dec 17, 2010 4:05 pm Post subject: Smarty native gettext |
|
|
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 |
|
|
|
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
|