2017 © Pedro Peláez
 

application twig-gettext-extractor

(Updated for Twig 2.2) The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

image

roydejong/twig-gettext-extractor

(Updated for Twig 2.2) The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

  • Friday, July 14, 2017
  • by roydejong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 50 % Grown

The README.md

Twig Gettext Extractor Build Status

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates., (*1)

This fork

Hello. Here's some things this fork offers:, (*2)

  • This fork has been designed for compatibility with version 2 of twig. It's a bit of a hack, but it works.
  • Removed symfony dependencies which might make it a bit easier to install.
  • You can add "dummy filters" via a --filter parameter to prevent the extractor from breaking when it encounters user-defined filters that would cause template parsing to break (HINT: add this before the --files part of the extractor command).
  • If extraction fails for whatever reason, a log file will be dumped to the directory in which the gettext extractor library lives.

This fork is available on Packagist as a composer package for your convenience:, (*3)

composer require roydejong/twig-gettext-extractor

Or, to install globally (to your home directory) - recommended:, (*4)

composer global require roydejong/twig-gettext-extractor

Original documentation

Installation

Manual

Local

Download the twig-gettext-extractor.phar file and store it somewhere on your computer., (*5)

Global

You can run these commands to easily access twig-gettext-extractor from anywhere on your system:, (*6)

$ sudo wget https://github.com/umpirsky/Twig-Gettext-Extractor/releases/download/1.2.0/twig-gettext-extractor.phar -O /usr/local/bin/twig-gettext-extractor
$ sudo chmod a+x /usr/local/bin/twig-gettext-extractor

Then, just run twig-gettext-extractor., (*7)

Composer

Local

$ composer require umpirsky/twig-gettext-extractor

Global

$ composer global require umpirsky/twig-gettext-extractor

Make sure you have ~/.composer/vendor/bin in your PATH and you're good to go:, (*8)

$ export PATH="$PATH:$HOME/.composer/vendor/bin"

Don't forget to add this line in your .bashrc file if you want to keep this change after reboot., (*9)

Setup

By default, Poedit does not have the ability to parse Twig templates. This can be resolved by adding an additional parser (Edit > Preferences > Parsers) with the following options:, (*10)

  • Language: Twig
  • List of extensions: *.twig
  • Invocation:
    • Parser command: <project>/vendor/bin/twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F (replace <project> with absolute path to your project)
    • An item in keyword list: -k%k
    • An item in input file list: %f
    • Source code charset: --from-code=%c

, (*11)

Now you can update your catalog and Poedit will synchronize it with your twig templates., (*12)

Custom extensions

Twig-Gettext-Extractor registers some default twig extensions. However, if you are using custom extensions, you need to register them first before you can extract the data. In order to achieve that, copy the binfile into some custom place. A common practice would be: cp vendor/bin/twig-gettext-extractor bin/twig-gettext-extractor, (*13)

Now you may add your custom extensions here:, (*14)

$twig->addFunction(new \Twig_SimpleFunction('myCustomExtension', true));
$twig->addFunction(new \Twig_SimpleFunction('myCustomExtension2', true));

Custom filters (in this fork)

If you're using custom, user-defined twig filters, the extractor will break when it encounters them., (*15)

You can modify the parser command in Poedit if you want to register custom filters., (*16)

Doing so will create a dummy filter that will return the input as output without modifying it., (*17)

For example, if you have a currency filter, modify your parser command as follows:, (*18)

twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --filters currency --files %F

The --filters command must be added after the gettext parameters but before the --files declaration to work correctly. You can add multiple filters by delimiting them with a space., (*19)

The Versions

14/07 2017

dev-master

9999999-dev

(Updated for Twig 2.2) The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/07 2017

v2.1

2.1.0.0

(Updated for Twig 2.2) The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/04 2017

v2.0

2.0.0.0

(Updated for Twig 2.2) The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/07 2016

v1.2.1

1.2.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

20/12 2015

dev-feature/box

dev-feature/box

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

  Sources   Download

MIT

The Requires

 

The Development Requires

25/10 2015

1.2.0

1.2.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

25/10 2015

dev-feature/update-dependencies

dev-feature/update-dependencies

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

25/02 2015

1.1.5

1.1.5.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

25/02 2015

1.1.4

1.1.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

14/02 2013

1.1.3

1.1.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

26/01 2013

1.1.2

1.1.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

08/11 2012

1.1.1

1.1.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Саша Стаменковић

31/08 2012

1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

by Саша Стаменковић

29/08 2012

1.0.0

1.0.0.0

A script to extract translations from twig templates.

  Sources   Download

MIT

The Requires

 

by Саша Стаменковић