PHPackages                             coffreo/js-translation-extractor - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. coffreo/js-translation-extractor

ActiveLibrary[Localization &amp; i18n](/categories/localization)

coffreo/js-translation-extractor
================================

Extract translation from javascript source code

0.3.0(4y ago)134.2k↓57.1%5[1 issues](https://github.com/Coffreo/js-translation-extractor/issues)2MITPHPPHP ^5.6 || ^7.0 || ^8.0

Since Apr 24Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Coffreo/js-translation-extractor)[ Packagist](https://packagist.org/packages/coffreo/js-translation-extractor)[ RSS](/packages/coffreo-js-translation-extractor/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (3)Versions (6)Used By (2)

Coffreo/js-translation-extractor
================================

[](#coffreojs-translation-extractor)

By [Coffreo](https://coffreo.biz)

[![Build Status](https://camo.githubusercontent.com/7931ceb5acb6de050be47e7fd4dfe46e6074d0480d4ee5d283d669e10eacf340/68747470733a2f2f7472617669732d63692e6f72672f436f666672656f2f6a732d7472616e736c6174696f6e2d657874726163746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Coffreo/js-translation-extractor)[![codecov](https://camo.githubusercontent.com/4eea596113dcc63bce50ee9d70413008c7380598c3fea8c1713ef446b7810e22/68747470733a2f2f636f6465636f762e696f2f67682f436f666672656f2f6a732d7472616e736c6174696f6e2d657874726163746f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Coffreo/js-translation-extractor)

#### Javascript translations extractor for [`willdurand/js-translation-bundle`](https://github.com/willdurand/BazingaJsTranslationBundle)

[](#javascript-translations-extractor-for-willdurandjs-translation-bundle)

This package is a small project existing to store in one place wonderfuls regexps to properly export translations strings &amp; metas from javascript source files.
It can be used standalone, but it's main goal is to be used in :

- [`coffreo/jms-translation-js-extractor-bundle`](https://github.com/Coffreo/jms-translation-js-extractor-bundle)
- [`coffreo/php-translation-js-extractor-bundle`](https://github.com/Coffreo/php-translation-js-extractor-bundle)

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

[](#installation)

- You only need to install this package manually for standalone usage and to integrate in your own translation extractor system:

    ```
    composer require coffreo/js-translation-extractor

    ```
- Using with Symfony [JMSTranslationBundle](https://github.com/schmittjoh/JMSTranslationBundle)

    see [`coffreo/jms-translation-js-extractor-bundle`](https://github.com/Coffreo/jms-translation-js-extractor-bundle) installation guide.
- Using with Symfony [PHP Translation](https://php-translation.readthedocs.io/en/latest/)

    see [`coffreo/php-translation-js-extractor-bundle`](https://github.com/Coffreo/php-translation-js-extractor-bundle) installation guide.

Features
--------

[](#features)

- extracts following strings from javascript files like a pro

```
trans('MESSAGE', {param: 'foo'}, 'DOMAIN')
//    ^ 1st parameter is translation message
//                               ^ 3rd parameter is translation domain

transChoice('MESSAGE_WITH_PLURALS', 3, {param: 'foo'}, 'DOMAIN')
//          ^ 1st parameter is translation message
//                                                     ^ 4th parameter is translation domain

// others parameters aren't extracted because they are useless.
```

*Note that this is the syntax used by [`js-translation-bundle`](https://github.com/willdurand/BazingaJsTranslationBundle)*

- allow string delimiters to be `"` or `'`
- extracts multi-lines commands

Usage
-----

[](#usage)

```
use Coffreo\JsTranslationExtractor\Extractor\JsTranslationExtractor;
use Coffreo\JsTranslationExtractor\Model\TranslationCollection;

$extractor = new JsTranslationExtractor();
$translationCollection = new TranslationCollection();

$extractor->extract(first();
$first->getMessage();  // This is awesome
$first->getLine();     // 3
$first->getContext();  // ['domain' => 'foo']

$second = $translationCollection->get(1);
$second->getMessage();  // This is ugly
$second->getLine();     // 5
$second->getContext();  // []
```

Found a bug
-----------

[](#found-a-bug)

Please fill an issue with informations to reproduce bug.

If your translated strings are not extracted properly, please provide a sample failing string.

Development
-----------

[](#development)

- Clone repository
- Execute

```
make [install]   # to init composer after install
make test        # to run test
```

TODO
----

[](#todo)

- Find a way to add and extract desc/meaning values

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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

Every ~512 days

Total

3

Last Release

1605d ago

PHP version history (2 changes)0.1.0PHP ^5.6 || ^7.0

0.2.0PHP ^5.6 || ^7.0 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![emri99](https://avatars.githubusercontent.com/u/6652177?v=4)](https://github.com/emri99 "emri99 (14 commits)")[![pauli-heikkinen](https://avatars.githubusercontent.com/u/180627162?v=4)](https://github.com/pauli-heikkinen "pauli-heikkinen (1 commits)")

### Embed Badge

![Health badge](/badges/coffreo-js-translation-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/coffreo-js-translation-extractor/health.svg)](https://phpackages.com/packages/coffreo-js-translation-extractor)
```

###  Alternatives

[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[php-translation/extractor

Extract translations form the source code

1284.6M9](/packages/php-translation-extractor)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[api-platform/symfony

Symfony API Platform integration

384.5M129](/packages/api-platform-symfony)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)

PHPackages © 2026

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