How to make gettext and poedit recognize custom file types?
Asked Answered
A

2

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?

Acoustics answered 29/1, 2013 at 10:30 Comment(0)
U
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

Umeh answered 20/12, 2013 at 15:53 Comment(3)
This is not possible since POEDIT version 2. There is no option to edit Parsers.Gravid
@Gravid It is, by adding a custom extractor (the "+" button).Pyrazole
@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.Gravid
W
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

Wideeyed answered 3/4, 2014 at 9:24 Comment(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 <input type="text" placeholder="{pgettext('frontend','Your text to translate')}">Pneumatometer

© 2022 - 2024 — McMap. All rights reserved.