0

There is a lot of PO editors, you can find some of them here: What good alternatives to poEdit are there?

But which one can extract messages from twig files?

{% trans %}Hello %name%{% endtrans %}

There is some way to use poedit, but I'm looking for a better way.

Community
  • 1
  • 1
Mohammad Ali Akbari
  • 10,345
  • 11
  • 44
  • 62

2 Answers2

1

I think there is no PO editor that can parse Twig emplates. Poedit can do it with the help of Twig Gettext Extractor.

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

umpirsky
  • 9,902
  • 13
  • 71
  • 96
  • OK, can you define what is "better way" for you? What is wrong with current ways? – umpirsky Nov 07 '12 at 11:59
  • there are about 20 PO editors, you can find them in referred link in question. Which one can extract strings from twig files. independent from `Symfony framework` – Mohammad Ali Akbari Nov 07 '12 at 13:50
  • I think there is no PO editor that can do that. Poedit can do it with the help of Twig Gettext Extractor. – umpirsky Nov 07 '12 at 14:54
  • I wrote [a grunt task](https://github.com/gwa/grunt-gettext-parser) to extract gettext calls from twig templates to a php file that poedit can read. – Tim Mar 12 '17 at 15:53
0

I use the following two npm modules xgettext-template and gettext-volt. Works perfectly since Volt templates have nearly the same syntax as Twig templates.

EDIT 2021:

You could also purchase a Poedit Pro licence:

Work with Twig and Volt templates Twig is one of the most popular templating languages for web development, used by WordPress, Craft CMS, Symfony, Drupal, or Grav; Volt is used by Phalcon. Poedit Pro supports extraction of translation strings from Twig and Volt templates out of the box.

crash
  • 603
  • 4
  • 11