5

I'm trying to get Smarty and gettext to work together in a project of mine. Currently smarty uses .tpl files for its template system.
I use PoEdit for creating catalog files and I've added '*.tpl' to the file extensions under PHP but when I try to scan for gettext strings I get the following errors and it is not able to find my strings:

xgettext: warning: file ../libs/smarty/debug.tpl' extensiontpl' is unknown; will try C
xgettext: warning: file ../template/login.tpl' extensiontpl' is unknown; will try C
xgettext: warning: file ../template/index.tpl' extensiontpl' is unknown; will try C

Well how can I get it to work?

2hamed
  • 8,719
  • 13
  • 69
  • 112

2 Answers2

5

(What you have mentioned should work). Make sure it's saving correctly.

Edit > Preferences > Parsers

Select PHP

Enter in the allowed extensions...

.php;.tpl

enter image description here

Note: You also might need to update your parser command to include:

xgettext --language=PHP --force-po -o %o %C %K %F

Layke
  • 51,422
  • 11
  • 85
  • 111
  • This is not possible since POEDIT version 2. There is no option to edit Parsers. – mikep Sep 05 '18 at 12:45
  • @mikep It is, by adding a custom extractor (the "+" button). – Václav Slavík Sep 06 '18 at 08:08
  • @VáclavSlavík thank you I found it now! But in version Poedit-1.8.13 there is one advantage that I can see extractors setup (xgettext command etc.) for existing languages to get inspired when creating new custom extractor. Eg. for VueJS templates (\*.vue files) I had to use the same options such as for Python (\*.py) but in version 2 I can not see and copy it. Newbie does not know where to start when creating new custom extractor in version 2. – mikep Sep 06 '18 at 09:18
4

After a day of trying to install smarty parser with no success I have edited the Perl in

Edit > Preferences > Parsers

So to the list of extensions I added *.tpl

*.pl;*.tpl

It parses now all {_("text")} inside smarty tpl

Milan
  • 51
  • 3
  • 1
    Actually Perl parser didn't work for my html files entirely (had some problems with parsing attributes inside html tags). I found Python parser more accurate - It can parse – trojan Jun 08 '16 at 13:39