Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gwa/grunt-gettext-parser

Extract gettext translation calls from Twig templates to a single PHP file for parsing. Support for i18n extension, Drupal 8 templates, and Wordpress Timber
https://github.com/gwa/grunt-gettext-parser

drupal-8 grunt grunt-plugins i18n timber twig wordpress

Last synced: about 1 month ago
JSON representation

Extract gettext translation calls from Twig templates to a single PHP file for parsing. Support for i18n extension, Drupal 8 templates, and Wordpress Timber

Awesome Lists containing this project

README

        

# grunt-gettext-parser

[![Build Status](https://travis-ci.org/gwa/grunt-gettext-parser.svg?branch=master)](https://travis-ci.org/gwa/grunt-gettext-parser)

> Extract gettext calls from templates to a single PHP file that can then be used to create a `.po` file for translations.

A grunt task that parses `gettext` calls from [twig](http://twig.sensiolabs.org/) ([i18n Extension](http://twig-extensions.readthedocs.io/en/latest/i18n.html), [Timber](http://upstatement.com/timber/) for Wordpress, or Drupal 8) files and creates a "dummy" PHP file with gettext calls.

The dummy file can then be parsed [using grunt-pot](https://www.npmjs.com/package/grunt-pot) to create a `.pot` or `.po` file.

### i18n

Running the task in `i18n` mode on the following:

```markup

{{ trans "my text" }}


{% trans %}
other text with a {{ variable }}
{% endtrans %}

```

results in:

```php

{{ __('my text', 'mydomain') }}
{{ __('other text', 'otherdomain') }}
```

results in:

```php

{{ 'my text'|t }}
```

also results in:

```php