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

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

waterloomatt/translation
========================

Handle dynamic translations based on current controller/action.

1.0.5(10y ago)027MITPHP

Since Jan 16Pushed 6y agoCompare

[ Source](https://github.com/waterloomatt/laravel-dynamic-translations)[ Packagist](https://packagist.org/packages/waterloomatt/translation)[ RSS](/packages/waterloomatt-translation/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (6)Used By (0)

laravel-dynamic-translations
============================

[](#laravel-dynamic-translations)

Allows your application to use dynamic translations with ease

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

[](#installation)

### Composer

[](#composer)

Run the following to include this via Composer

```
composer require waterloomatt/translation

```

### Laravel 5 Configuration

[](#laravel-5-configuration)

Register the service provider with your application by adding the following line to config/app.php

```
'providers' => [
  Waterloomatt\Translation\Providers\TranslationServiceProvider::class
```

That's it! You're good to go.

Usage
-----

[](#usage)

In your views, use Laravel's translation helper as you normally would. Nothing needs to change here.

```
{{ trans('messages.pageTitle') }}

```

Now, the fun bit! In this example, you can override the 'pageTitle' translation by specifying which controller or action (or both) a translation should apply to.

In your messages.php translation file, override the `pageTitle` translation by specifying a controller or action (or both).

```
return [
  'pageTitle'                                   => 'My Application!'  // Applies to all pages
  'controller:search_key:pageTitle'             => 'Search',          // Applies to /search/{any_action}
  'action:index_key:pageTitle'                  => 'All Index Pages!',// Applies to /{any_controller}/index
  'controller:user_action:update_key:pageTitle' => 'Update User',     // Applies to user/update
];
```

As you can see, you can control which translation will be used by specifying the *controller* or *action* or both. The most specific translation that matches the current route will be used.

- Each component separates its name from its value by a *colon* `controller:user`, `controller:payment`
- Each component separates itself from other components by an *underscore* `controller:user_action:update`, `controller:payment_action:decline_key:pageTitle`
- The third component is *key* which simply defines the translation key.
- Both controller and action are optional

### Important! Translations are searched by most specific to least specific.

[](#important-translations-are-searched-by-most-specific-to-least-specific)

1. controller:name\_action:name\_key:name
2. action:name\_key:name
3. controller:name\_key:name
4. name

In the following examples, assume your current route is

- Example 1

```
return [
  'controller:search_key:pageTitle'               => 'Search',
  'controller:search_action:index_key:pageTitle'  => 'Search',    // this one!
];
```

- Example 2

```
return [
  'action:index_key:pageTitle'                    => 'Search',
  'pageTitle'                                     => 'Search',    // this one!
];
```

- Example 3

```
return [
  'controller:search_action:result_key:pageTitle' => 'Search',
  'controller:search_action:index_key:pageTitle'  => 'Search',    // this one!
];
```

- Example 4

```
return [
  'controller:search_key:pageTitle'               => 'Search',
  'action:index_key:pageTitle'                    => 'Search',    // this one!
];
```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~5 days

Total

5

Last Release

3843d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1981303?v=4)[Matt Skelton](/maintainers/waterloomatt)[@waterloomatt](https://github.com/waterloomatt)

---

Top Contributors

[![waterloomatt](https://avatars.githubusercontent.com/u/1981303?v=4)](https://github.com/waterloomatt "waterloomatt (14 commits)")

### Embed Badge

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

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

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[renatomarinho/laravel-multi-language

Laravel Multi Language

235.1k](/packages/renatomarinho-laravel-multi-language)

PHPackages © 2026

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