PHPackages                             soundasleep/translation-discovery - 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. soundasleep/translation-discovery

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

soundasleep/translation-discovery
=================================

0135PHP

Since Mar 3Pushed 11y ago1 watchersCompare

[ Source](https://github.com/soundasleep/translation-discovery)[ Packagist](https://packagist.org/packages/soundasleep/translation-discovery)[ RSS](/packages/soundasleep-translation-discovery/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

translation-discovery
=====================

[](#translation-discovery)

*translation-discovery* is a Composer-enabled PHP script to locate translations across multiple PHP components from JSON files, which can then be combined together into single translations for project runtime.

Based on [asset-discovery](https://github.com/soundasleep/asset-discovery).

Configuring
-----------

[](#configuring)

First include `translation-discovery` as a requirement in your project `composer.json`, and run `composer update` to install it into your project:

```
{
  "require": {
    "soundasleep/translation-discovery": "dev-master"
  }
}
```

Now create a `translation-discovery.json` in your project, to define the types of assets to discover, and where to place source files:

```
{
  "src": ["vendor/*/*", "core"],
  "locales": {
    "fr": "generated/locales/fr.json",
    "de": "generated/locales/de.json"
  },
  "generate_php": true
}
```

*translation-discovery* will look in all the `src` folders for files called `locales.json`to find matching assets. Wildcards are supported. For example, in your `vendor/my/package/locales.json`:

```
{
  "fr": "locales/fr.json",
  "de": ["locales/de/*.json"]
}
```

Building
--------

[](#building)

Run the generate script, either with your build script or manually, with a given root directory:

```
php -f vendor/soundasleep/translation-discovery/generate.php .

```

*translation-discovery* will then load all identified locale JSON files, combine all of the locale strings into one large JSON file, and then write this out to each locale destination JSON.

If `generate_php` is set to `true`, a `.php` file will also be generated which returns the locale strings in a format suitable for PHP `require()`.

These files can then be passed along to the next step in a build chain.

Discovering translation strings
-------------------------------

[](#discovering-translation-strings)

Particularly if you are using the [openclerk/i18n](https://github.com/openclerk/i18n) project, you can use the find script to locale potentially matching translation strings and output them into a template file in JSON.

Update `translation-discovery.json` in your project, to define the source locations:

```
{
  "templates": ["vendor/openclerk", "core", "site"],
  "template": "site/locale/template.json"
}
```

Run the find script, either with your build script or manually, with a given root directory:

```
php -f vendor/soundasleep/translation-discovery/find.php .

```

This script will find all instances of the following translation strings, and output them to the `template` JSON folder:

1. `t("string")`
2. `ht("string")`
3. `plural("string", 1)` and `plural("string", "strings", 1)`
4. `"string" /* i18n */`
5. And the single-quote versions of these patterns

Example projects
----------------

[](#example-projects)

1. [Openclerk](https://github.com/soundasleep/openclerk)

TODOs
-----

[](#todos)

1. More documentation, especially default `translation-discovery.json` parameters
2. Create `grunt` task `grunt-php-translation-discovery` to wrap the manual PHP command
3. Release 0.1 version

See also
--------

[](#see-also)

1. [asset-discovery](https://github.com/soundasleep/asset-discovery)
2. [component-discovery](https://github.com/soundasleep/component-discovery)
3. [openclerk/i18n](https://github.com/openclerk/i18n)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ebbec5ccc867054461adebb7c5b6312f8256f989ef96b124892e6e89724afdb?d=identicon)[soundasleep](/maintainers/soundasleep)

---

Top Contributors

[![soundasleep](https://avatars.githubusercontent.com/u/3889656?v=4)](https://github.com/soundasleep "soundasleep (16 commits)")

### Embed Badge

![Health badge](/badges/soundasleep-translation-discovery/health.svg)

```
[![Health](https://phpackages.com/badges/soundasleep-translation-discovery/health.svg)](https://phpackages.com/packages/soundasleep-translation-discovery)
```

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)

PHPackages © 2026

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