PHPackages                             ifresh/laravel-enum-translations - 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. ifresh/laravel-enum-translations

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

ifresh/laravel-enum-translations
================================

1.0.4(1mo ago)11.2k↓50%3MITPHPPHP ^8.1

Since Oct 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/iFreshDevelopment/laravel-enum-translations)[ Packagist](https://packagist.org/packages/ifresh/laravel-enum-translations)[ RSS](/packages/ifresh-laravel-enum-translations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (10)Versions (11)Used By (0)

Simple Enum translations for Laravel
====================================

[](#simple-enum-translations-for-laravel)

a Laravel package that simplifies the translation of enums in your applications, making it easy to associate enum values with translated labels for multiple languages. It enhances code readability and maintainability by handling enum translations seamlessly.

This makes it super easy to provide your front-end with a list of enum-keys with corresponding labels.

Features
--------

[](#features)

- Automatically load translated labels for your application Enums
- Provide a fallback based on the enum key to easily find missing translations
- Follows the configured locale of your application

Getting started
---------------

[](#getting-started)

1. Use [composer](https://getcomposer.org) to install the package `composer require ifresh/laravel-enum-translations`
2. Publish the configuration files `./artisan vendor:publish --tag=laravel-enum-translations`
3. Modify the `lang/en/enums.php` file OR copy this file to your application's locale folder.

Example
-------

[](#example)

Given the following enum:

```
namespace App\Enums;

enum Cards: string
{
    case Hearts = 'hearts';
    case Diamonds = 'diamonds';
    case Clubs = 'clubs';
    case Spades = 'spades';
}
```

You can add translated values by modifying the `lang/en/enums.php` file:

```
return [
    'cards' => [
        'hearts' => 'Hearts ❤️',
        'diamonds' => 'Diamonds 💎',
        'clubs' => 'Clubs ♣️',
        'spades' => 'Spades ♠️',
    ],
];
```

Now to use these translations in your application by using the `EnumTranslatorFacade`:

If you simply want to get the list of all the translations for a single Enum (for instance when filling a dropdown) you can use the `translate` method available on the Facade:

```
use App\Enums\Cards;
use IFresh\EnumTranslations\EnumTranslatorFacade as EnumTranslator;

$translations = EnumTranslator::translate(Cards::class);
/*
 * [
 *   'hearts' => 'Hearts ❤️',
 *   'diamonds' => 'Diamonds 💎',
 *   'clubs' => 'Clubs ♣️',
 *   'spades' => 'Spades ♠️',
 * ]
 */
```

It is also possible to get the translated value for a single enum value, to do this you can use the `translateValue` method instead:

```
EnumTranslator::translateValue(Cards::class, Cards::Hearts); // 'Hearts ❤️'
```

When you pass `null` as the selected enum value, an empty string is returned:

```
EnumTranslator::translateValue(Cards::class, null); // ''
```

Contributing
------------

[](#contributing)

All contributions are welcome! Please open a GitHub Issue or create a Pull-request

License
-------

[](#license)

The Laravel enum translations package is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance64

Regular maintenance activity

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~99 days

Recently: every ~182 days

Total

10

Last Release

53d ago

Major Versions

v0.4.1 → v1.0.02024-03-28

### Community

Maintainers

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

---

Top Contributors

[![stephanbouman](https://avatars.githubusercontent.com/u/67788644?v=4)](https://github.com/stephanbouman "stephanbouman (3 commits)")[![tkuijer](https://avatars.githubusercontent.com/u/1401811?v=4)](https://github.com/tkuijer "tkuijer (3 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/ifresh-laravel-enum-translations/health.svg)

```
[![Health](https://phpackages.com/badges/ifresh-laravel-enum-translations/health.svg)](https://phpackages.com/packages/ifresh-laravel-enum-translations)
```

###  Alternatives

[barryvdh/laravel-translation-manager

Manage Laravel Translations

1.7k3.6M17](/packages/barryvdh-laravel-translation-manager)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[illuminate/validation

The Illuminate Validation package.

18936.7M1.4k](/packages/illuminate-validation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[kkomelin/laravel-translatable-string-exporter

Translatable String Exporter for Laravel

3291.4M10](/packages/kkomelin-laravel-translatable-string-exporter)[laravel-lang/json-fallback

Adds support for fallback JSON string translation

162.2M4](/packages/laravel-lang-json-fallback)

PHPackages © 2026

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