Skip to content
Advertisement

How to use Poedit with smarty templates?

I’m using PoEdit on smarty templates (phtml and tpl files) with the following Poedit configuration for PHP parser :

Extensions:

JavaScript

Parser command :

JavaScript

If i’m using gettext inside PHP tags <?php _('test'); ?> Poedit detect that translation as expected. But i’m using Smarty {_('test')} for displaying the translation, Poedit don’t detect it.

Is there a way to make Smarty detect { and } characters as PHP tags ?

Advertisement

Answer

Recently I got to work with Yii used with Smarty and gettext. but poedit not support the syntax of smarty.

https://github.com/Garefild/PoeditSmarty

And here comes the use of PoeditSmarty allowed Poedit recognize the syntax of Smarty.

JavaScript

Very simple to use, PoeditSmarty creates a “pot” file which Poedit know to read.

For example, I have a file “Header.tpl”

JavaScript

I’ll run the PoeditSmarty via cmd

JavaScript

The result of pot file

JavaScript

via Poedit

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement