PHPackages                             gettext/twig-scanner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. gettext/twig-scanner

ActiveLibrary[Templating &amp; Views](/categories/templating)

gettext/twig-scanner
====================

Twig scanner for gettext

v0.1.0(3y ago)423.5k—3.4%2[5 issues](https://github.com/php-gettext/Twig-Scanner/issues)GPL-3.0-or-laterPHPPHP ^7.2 || ^8.0

Since Jul 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/php-gettext/Twig-Scanner)[ Packagist](https://packagist.org/packages/gettext/twig-scanner)[ Docs](https://github.com/php-gettext/twig-scanner)[ RSS](/packages/gettext-twig-scanner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Twig Scanner
============

[](#twig-scanner)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ab5416e7aa5149c7459bdd82b032c401378fd90285c724df0e0831bb8b88ac8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676574746578742f747769672d7363616e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gettext/twig-scanner)[![Software License](https://camo.githubusercontent.com/cad8c16a3d580a69d8923c98d8de25d21cb00fa54fa60a856a8e1ca657f79db4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c76332d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/02ab084c124b08c461c1bdbb2204b24466cbeac32d2b1dee0649e08202266995/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676574746578742f747769672d7363616e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gettext/twig-scanner)

Created by Raphaël Droz  (GPL-3 License)

Twig code scanner to use with [gettext/gettext](https://github.com/php-gettext/Gettext)

Warning
-------

[](#warning)

In order to be usable, upstream ParsedFunction class at php-gettext/Gettext must be slightly modified to ease inheritance.

Installation
------------

[](#installation)

```
composer require gettext/twig-scanner

```

About dependencies
------------------

[](#about-dependencies)

We do not require a **specific** version of Twig.

ToDo: Support symfony/twig-bridge `trans` filter.

Usage example
-------------

[](#usage-example)

```
use Gettext\Scanner\TwigScanner;
use Gettext\Generator\PoGenerator;
use Gettext\Translations;

//Create a new scanner, adding a translation for each domain we want to get:
$twigScanner = new TwigScanner(
    Translations::create('domain1'),
    Translations::create('domain2'),
    Translations::create('domain3')
);

//Set a default domain, so any translations with no domain specified, will be added to that domain
$twigScanner->setDefaultDomain('domain1');

//Extract all comments starting with 'notes:'
$twigScanner->extractCommentsStartingWith('notes:');

//Scan files
foreach (glob('*.twig') as $file) {
    $twigScanner->scanFile($file);
}

//Save the translations in .po files
$generator = new PoGenerator();

foreach ($twigScanner->getTranslations() as $domain => $translations) {
    $generator->generateFile($translations, "locales/{$domain}.po");
}
```

---

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

The GPL-3 License (GPL-3). Please see [LICENSE](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1400d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e99df56b617f4af8cf0556a51a0ca20c7420104920c57d7e9eab093f92bb744f?d=identicon)[oscarotero](/maintainers/oscarotero)

---

Top Contributors

[![oscarotero](https://avatars.githubusercontent.com/u/377873?v=4)](https://github.com/oscarotero "oscarotero (11 commits)")[![tvdijen](https://avatars.githubusercontent.com/u/841045?v=4)](https://github.com/tvdijen "tvdijen (5 commits)")[![tehbeard](https://avatars.githubusercontent.com/u/734177?v=4)](https://github.com/tehbeard "tehbeard (3 commits)")

---

Tags

i18ntwigtranslationgettextscanner

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/gettext-twig-scanner/health.svg)

```
[![Health](https://phpackages.com/badges/gettext-twig-scanner/health.svg)](https://phpackages.com/packages/gettext-twig-scanner)
```

###  Alternatives

[gettext/gettext

PHP gettext manager

70130.2M102](/packages/gettext-gettext)[gettext/php-scanner

PHP scanner for gettext

15471.2k12](/packages/gettext-php-scanner)[jblond/twig-trans

Twig 3 translation extension

13169.9k2](/packages/jblond-twig-trans)[om/potrans

Command line tool for translate Gettext with Google Translator API or DeepL API

10515.0k4](/packages/om-potrans)[fisharebest/localization

A lightweight localization database and translation tools, with data from the CLDR, IANA, ISO, etc.

3191.1k2](/packages/fisharebest-localization)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
