• Stars
    star
    114
  • Rank 297,270 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

symfony upgrade fixer β€’ twig gettext extractor β€’ wisdom β€’ centipede β€’ permissions handler β€’ extraload β€’ gravatar β€’ locurro β€’ country list β€’ transliterator

Twig Gettext Extractor Build Status

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

Installation

Manual

Local

Download the twig-gettext-extractor.phar file and store it somewhere on your computer.

Global

You can run these commands to easily access twig-gettext-extractor from anywhere on your system:

$ 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.

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:

$ 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.

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:

  • 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

Now you can update your catalog and Poedit will synchronize it with your twig templates.

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

Now you may add your custom extensions here:

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

Command Line Arguments

You can also specify custom extensions and filters via command line, by adding the --functions and --filters arguments, e.g.:

--functions formRow,formElement --filters localizedCurrency

You can specify an unlimited amount of comma-separated function and filter names.

Similarly, you can specify the location of the gettext executable you want to use with --exec

--exec /usr/local/bin/xgettext

More Repositories

1

country-list

🌐 List of all countries with names and ISO 3166-1 codes in all languages and data formats.
HTML
5,060
star
2

language-list

List of all languages with names and ISO 639-1 codes in all languages and all data formats.
HTML
493
star
3

locale-list

List of all locales with names and codes in all languages and all data formats.
HTML
295
star
4

currency-list

πŸ’° List of all currencies with names and ISO 4217 codes in all languages and all data formats.
HTML
290
star
5

Symfony-Upgrade-Fixer

Analyzes your Symfony project and tries to make it compatible with the new version of Symfony framework.
PHP
274
star
6

tld-list

List of all top-level domains in all data formats.
HTML
156
star
7

centipede

πŸŽ‡ The Simplest automated testing tool on Earth.
PHP
141
star
8

wisdom

Domain availability checker.
PHP
121
star
9

PermissionsHandler

πŸ”’ Composer script handling directories permissions by making them writable both by the web server and the command line user.
PHP
66
star
10

Transliterator

Transliterator is a PHP library for text transliteration.
PHP
60
star
11

twig-php-function

Call (almost) any PHP function from your Twig templates.
PHP
60
star
12

centipede-crawler

Crawls all unique links.
PHP
42
star
13

umpirsky.com

Source code for umpirsky.com
CSS
40
star
14

Extraload

Powerful ETL library.
PHP
34
star
15

locurro

πŸ’Ά Local currency converter.
PHP
32
star
16

list-generator

Export data to various formats.
PHP
20
star
17

Gravatar

Lightweight Gravatar library.
PHP
16
star
18

silex-on-steroids

Silex demo application.
PHP
13
star
19

Freelander

Simple landing page that just works.
CSS
9
star
20

zymfony-validator

Zend validator adapter for Symfony
PHP
8
star
21

symfony-cli-calculator

Simple demo CLI calculator based on Symfony Console Component
PHP
8
star
22

I18nRoutingServiceProvider

Silex i18n routing service provider.
PHP
7
star
23

eclipse-templates

Eclipse code templates
6
star
24

Oregon

Statistics library for open source organizations.
PHP
5
star
25

chess-notifier

Get Chess.com browser notifications on your desktop. Never lose on time again!
JavaScript
5
star
26

Sylex

Sylex is a tiny layer on top of Silex framework.
PHP
5
star
27

country-list.umpirsky.com

Country list website
JavaScript
4
star
28

Simplex

The PHP micro-framework based on Silex
PHP
4
star
29

UmpirskyI18nRoutingBundle

Internationalized routing with minimal performance cost.
PHP
3
star
30

Titlerator

Convert subtitles to utf-8 encoding.
PHP
2
star
31

rhytmbox-tunein-import

Script to import your radio stations from TuneIn into Rhythmbox.
Python
2
star
32

EPS

Malo punimo EPS
PHP
1
star
33

hello-github

Just playing with git
1
star
34

top-github-repositories

Orders GitHub repositories by given parameter.
PHP
1
star
35

nautilus-scripts

Nautilus scripts
Python
1
star
36

stajesti.rs

Projekat koji daje odgovor na večito pitanje.
CSS
1
star
37

top-php-frameworks

Top ranking PHP frameworks.
PHP
1
star
38

Simplex-Demo

Simple website made in Simplex
JavaScript
1
star
39

phpsummercamp-phpspec

PHPSpec uses specifications to describe object behaviour as an input language rather than user stories. We always focus on a single object while mocking other dependencies. This is incredibly easy with the Prophecy mocking framework, which is created to fulfill PHPSpec needs. In this workshop we will introduce you to the basics of PHPSpec and show you how to describe your objects the right way.
1
star