PHPackages                             brunoscode/laravel-translation-handler - 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. brunoscode/laravel-translation-handler

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

brunoscode/laravel-translation-handler
======================================

This is my package laravel-translation-handler

v2.0.2(2mo ago)01.6k↓50%1MITPHPPHP ^8.2CI passing

Since Feb 10Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/BrunosCode/LaravelTranslationHandler)[ Packagist](https://packagist.org/packages/brunoscode/laravel-translation-handler)[ Docs](https://github.com/brunoscode/laravel-translation-handler)[ GitHub Sponsors](https://github.com/BrunosCode)[ RSS](/packages/brunoscode-laravel-translation-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (26)Versions (17)Used By (1)

Laravel Translation Handler
===========================

[](#laravel-translation-handler)

Laravel Translation Handler is a package to manage translations in Laravel applications. It supports importing, exporting, and managing translations across different formats such as PHP files, CSV files, JSON files, and databases.

[![Latest Version on Packagist](https://camo.githubusercontent.com/f28ab551abe925136007b58e37530318d17132ec81729b8987e6a5e3c8e43bc9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272756e6f73636f64652f6c61726176656c2d7472616e736c6174696f6e2d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brunoscode/laravel-translation-handler)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bc0aed774d6d5fde8be874bd957e4eb08ee43a00ce849c04a22cf82af756df34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6272756e6f73636f64652f6c61726176656c2d7472616e736c6174696f6e2d68616e646c65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/brunoscode/laravel-translation-handler/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ce8c9bca8be7b476abe730fb9f861059c16ae366f7235d250310159b83507de5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6272756e6f73636f64652f6c61726176656c2d7472616e736c6174696f6e2d68616e646c65722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/brunoscode/laravel-translation-handler/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/85f50c53393dadf38f04fc26fc7610a0ead6cc94ef252a35d3bbcbc1f58ab561/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272756e6f73636f64652f6c61726176656c2d7472616e736c6174696f6e2d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brunoscode/laravel-translation-handler)

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

[](#installation)

You can install the package via composer:

```
composer require brunoscode/laravel-translation-handler
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="BrunosCode\TranslationHandler\TranslationHandlerServiceProvider"
```

This will create a `translation-handler.php` file in your `config` directory.

### Configuration Options

[](#configuration-options)

- `keyDelimiter`: The delimiter used in translation keys (default: `.`).
- `fileNames`: An array of translation file names (default: `['translation-handler']`).
- `locales`: An array of supported locales (default: `['en']`).
- `defaultImportFrom`: The default format to import translations from (default: `TranslationOptions::PHP`).
- `defaultImportTo`: The default format to import translations to (default: `TranslationOptions::PHP`).
- `defaultExportFrom`: The default format to export translations from (default: `TranslationOptions::PHP`).
- `defaultExportTo`: The default format to export translations to (default: `TranslationOptions::PHP`).
- `phpHandlerClass`: The handler class for PHP files (default: `BrunosCode\TranslationHandler\PhpFileHandler::class`).
- `csvHandlerClass`: The handler class for CSV files (default: `BrunosCode\TranslationHandler\CsvFileHandler::class`).
- `jsonHandlerClass`: The handler class for JSON files (default: `BrunosCode\TranslationHandler\JsonFileHandler::class`).
- `dbHandlerClass`: The handler class for database (default: `BrunosCode\TranslationHandler\DatabaseHandler::class`).
- `phpFormat`: Whether to format PHP translations (default: `false`).
- `phpPath`: The path to PHP translation files (default: `lang_path()`).
- `csvDelimiter`: The delimiter used in CSV files (default: `;`).
- `csvFileName`: The name of the CSV file (default: `translations`).
- `csvPath`: The path to CSV files (default: `storage_path('lang')`).
- `jsonPath`: The path to JSON files (default: `lang_path()`).
- `jsonFileName`: The name of the JSON file (default: `''`).
- `jsonNested`: Whether JSON output should be nested like PHP files (default: `false`).
- `jsonFormat`: Whether JSON output should be formatted (default: `true`).

Commands
--------

[](#commands)

The package provides several Artisan commands to manage translations:

### `translation-handler`

[](#translation-handler)

Move translations from one format to another.

#### Usage

[](#usage)

```
php artisan translation-handler {from?} {to?} {--force} {--fresh} {--file-names=*} {--locales=*} {--from-path} {--to-path} {--guided}
```

#### Parameters

[](#parameters)

- `from` (string|null): The format to move translations from. If not provided, you will be prompted to enter it.
- `to` (string|null): The format to move translations to. If not provided, you will be prompted to enter it.

#### Options

[](#options)

- `--force` (bool): Whether to force the move, overwriting existing translations. Default is `false`.
- `--fresh` (bool): Whether to delete old translations. Default is `false`.
- `--file-names` (array): An array of translation file names. Default is `fileNames` option.
- `--locales` (array): An array of supported locales. Default is `locales` option.
- `--from-path` (string|null): The path to the source translations. Default is the default path for the choose format.
- `--to-path` (string|null): The path to the destination translations. Default is the default path for the choose format.
- `--guided` (bool): Whether to enable guided mode. Default is `false`.

### `translation-handler:import`

[](#translation-handlerimport)

Import translations from one format to another.

#### Usage

[](#usage-1)

```
php artisan translation-handler:import {--force} {--from} {--from-path} {--to} {--to-path} {--file-names=*} {--locales=*} {--guided}
```

#### Options

[](#options-1)

- `--force` (bool): Whether to force the import, overwriting existing translations. Default is `false`.
- `--fresh` (bool): Whether to delete old translations. Default is `false`.
- `--from` (string|null): The format to import translations from. Default is `defaultImportFrom` option.
- `--from-path` (string|null): The path to the source translations. Default is the default path for the choose format.
- `--to` (string|null): The format to import translations to. Default is `defaultImportTo` option.
- `--to-path` (string|null): The path to the destination translations. Default is the default path for the choose format.
- `--file-names` (array): An array of translation file names. Default is `fileNames` option.
- `--locales` (array): An array of supported locales. Default is `locales` option.
- `--guided` (bool): Whether to enable guided mode. Default is `false`.

### `translation-handler:export`

[](#translation-handlerexport)

Export translations from one format to another.

#### Usage

[](#usage-2)

```
php artisan translation-handler:export {--force} {--from} {--from-path} {--file-names=*} {--locales=*} {--to} {--to-path} {--guided}
```

#### Options

[](#options-2)

- `--force` (bool): Whether to force the export, overwriting existing translations. Default is `false`.
- `--fresh` (bool): Whether to delete old translations. Default is `false`.
- `--from` (string|null): The format to export translations from. Default is `defaultExportFrom` option.
- `--from-path` (string|null): The path to the source translations. Default is the default path for the choose format.
- `--to` (string|null): The format to export translations to. Default is `defaultExportTo` option.
- `--to-path` (string|null): The path to the destination translations. Default is the default path for the choose format.
- `--file-names` (array): An array of translation file names. Default is `fileNames` option.
- `--locales` (array): An array of supported locales. Default is `locales` option.
- `--guided` (bool): Whether to enable guided mode. Default is `false`.

### `translation-handler:get`

[](#translation-handlerget)

Get a specific translation.

#### Usage

[](#usage-3)

```
php artisan translation-handler:get {from?} {key?} {locale?} {--from-path=}
```

#### Parameters

[](#parameters-1)

- `from` (string|null): The format to get translations from. If not provided, you will be prompted to enter it.
- `key` (string|null): The translation key. If not provided, you will be prompted to enter it.
- `locale` (string|null): The translation locale. If not provided, you will be prompted to enter it.

#### Options

[](#options-3)

- `--from-path` (string|null): The path to the source translations. Default is the default path for the choose format

### `translation-handler:set`

[](#translation-handlerset)

Set a specific translation.

#### Usage

[](#usage-4)

```
php artisan translation-handler:set {to?} {key?} {locale?} {value?} {--to-path=} {--force}
```

#### Parameters

[](#parameters-2)

- `to` (string|null): The format to set translations to. If not provided, you will be prompted to enter it.
- `key` (string|null): The translation key. If not provided, you will be prompted to enter it.
- `locale` (string|null): The translation locale. If not provided, you will be prompted to enter it.
- `value` (string|null): The translation value. If not provided, you will be prompted to enter it.

#### Options

[](#options-4)

- `--to-path` (string|null): The path to the destination translations. Default is the default path for the choose format.
- `--force` (bool): Whether to force the set, overwriting existing translations. Default is `false`.

Facade
------

[](#facade)

### Import Translations

[](#import-translations)

To import translations from one format to another:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Import translations from PHP files to JSON files
TranslationHandler::import(TranslationOptions::PHP, TranslationOptions::JSON);

// Import translations from CSV files to database
TranslationHandler::import(TranslationOptions::CSV, TranslationOptions::DB);
```

#### Parameters

[](#parameters-3)

- `from` (string|null): The format to import translations from. Default is `defaultImportFrom` option.
- `to` (string|null): The format to import translations to. Default is `defaultImportTo` option.
- `force` (bool): Whether to force the import, overwriting existing translations. Default is `false`.
- `fromPath` (string|null): The path to the source translations. Default is the default path for the choose format.
- `toPath` (string|null): The path to the destination translations. Default is the default path for the choose format.

### Export Translations

[](#export-translations)

To export translations from one format to another:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Export translations from JSON files to PHP files
TranslationHandler::export(TranslationOptions::JSON, TranslationOptions::PHP);

// Export translations from database to CSV files
TranslationHandler::export(TranslationOptions::DB, TranslationOptions::CSV);
```

#### Parameters

[](#parameters-4)

- `from` (string|null): The format to export translations from. Default is `defaultExportFrom` option.
- `to` (string|null): The format to export translations to. Default is `defaultExportTo` option.
- `force` (bool): Whether to force the export, overwriting existing translations. Default is `false`.
- `fromPath` (string|null): The path to the source translations. Default is the default path for the choose format.
- `toPath` (string|null): The path to the destination translations. Default is the default path for the choose format.

### Get Translations

[](#get-translations)

To get translations from a specific format:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Get translations from PHP files
$translations = TranslationHandler::get(TranslationOptions::PHP);

// Get translations from JSON files
$translations = TranslationHandler::get(TranslationOptions::JSON);
```

#### Parameters

[](#parameters-5)

- `from` (string): The format to get translations from.
- `path` (string|null): The path to the source translations. Default is the default path for the choose format.

### Set Translations

[](#set-translations)

To set translations to a specific format:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Collections\TranslationCollection;
use BrunosCode\TranslationHandler\Data\Translation;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Create a new translation
$translation = new Translation('key', 'en', 'value');

// Add the translation to a collection
$collection = new TranslationCollection([$translation]);

// Set translations to JSON files
TranslationHandler::set($collection, TranslationOptions::JSON);

// Set translations to database
TranslationHandler::set($collection, TranslationOptions::DB);
```

#### Parameters

[](#parameters-6)

- `translations` (TranslationCollection): The collection of translations to set.
- `to` (string): The format to set translations to.
- `path` (string|null): The path to the destination translations. Default is the default path for the choose format.
- `force` (bool): Whether to force the set, overwriting existing translations. Default is `false`.

### Delete Translations

[](#delete-translations)

To delete translations from a specific format:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Delete translations from PHP files
TranslationHandler::delete(TranslationOptions::PHP);

// Delete translations from CSV files
TranslationHandler::delete(TranslationOptions::CSV);
```

#### Parameters

[](#parameters-7)

- `from` (string): The format to delete translations from.
- `path` (string|null): The path to the source translations. Default is the default path for the choose format.

### Advanced Usage

[](#advanced-usage)

#### Setting Options

[](#setting-options)

You can set specific options for the `TranslationHandler`:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;
use BrunosCode\TranslationHandler\Data\TranslationOptions;

// Set a specific option
TranslationHandler::setOption('keyDelimiter', '_');

// Set multiple options
$options = new TranslationOptions(array_merge(
    config('translation-handler'),
    ['keyDelimiter' => '_',]
));
TranslationHandler::setOptions($options);
```

#### Parameters

[](#parameters-8)

- `name` (string): The name of the option to set.
- `value` (mixed): The value of the option to set.

#### Resetting Options

[](#resetting-options)

To reset options to their default values:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;

// Reset all options to default
TranslationHandler::resetOptions();
```

#### Getting Default Options

[](#getting-default-options)

To get the default options:

```
use BrunosCode\TranslationHandler\Facades\TranslationHandler;

// Get default options
$defaultOptions = TranslationHandler::getDefaultOptions();
```

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

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss what you would like to change.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance81

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.8% 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 ~40 days

Recently: every ~63 days

Total

11

Last Release

60d ago

Major Versions

v0.1.7 → v1.02026-03-18

v1.0 → v2.02026-03-18

PHP version history (2 changes)v0.1PHP ^8.1

v1.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![BrunosCode](https://avatars.githubusercontent.com/u/78606186?v=4)](https://github.com/BrunosCode "BrunosCode (67 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravelBrunosCodelaravel-translation-handler

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/brunoscode-laravel-translation-handler/health.svg)

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

###  Alternatives

[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

590244.8k1](/packages/askdkc-breezejp)[bezhansalleh/filament-language-switch

Zero config Language Switch(Changer/Localizer) plugin for filamentphp admin

3431.0M16](/packages/bezhansalleh-filament-language-switch)[statikbe/laravel-filament-chained-translation-manager

A translation manager tool for Laravel Filament, that makes use of the Laravel Chained Translator.

92108.7k](/packages/statikbe-laravel-filament-chained-translation-manager)[outerweb/filament-translatable-fields

Filament integration for spatie/laravel-translatable

3582.9k8](/packages/outerweb-filament-translatable-fields)[elegantly/laravel-translator

All on one translations management for Laravel

6216.9k](/packages/elegantly-laravel-translator)[smousss/laravel-globalize

Make Laravel projects translatable in a matter of seconds!

2266.3k](/packages/smousss-laravel-globalize)

PHPackages © 2026

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