PHPackages                             beliven-it/laravel-i18n - 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. beliven-it/laravel-i18n

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

beliven-it/laravel-i18n
=======================

A small package for scan / import / export translations

1.1.0(2mo ago)053↓50%[2 PRs](https://github.com/beliven-it/laravel-i18n/pulls)MITPHPPHP ^8.2CI passing

Since Mar 3Pushed 1mo agoCompare

[ Source](https://github.com/beliven-it/laravel-i18n)[ Packagist](https://packagist.org/packages/beliven-it/laravel-i18n)[ Docs](https://github.com/beliven-it/laravel-i18n)[ GitHub Sponsors](https://github.com/Beliven)[ RSS](/packages/beliven-it-laravel-i18n/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (13)Versions (5)Used By (0)

Laravel I18n
============

[](#laravel-i18n)

[![](./repo/banner.png)](./repo/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c63c3202eca407a367c43cc89919b48ec7df169cb37e42f6062c29a53bfa1765/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656c6976656e2d69742f6c61726176656c2d6931386e2e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://packagist.org/packages/beliven-it/laravel-i18n)[![GitHub Tests Action Status](https://camo.githubusercontent.com/047ae40d2341469ad66899941af008c6ada02f705c5ec33f0f94828c03465a92/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656c6976656e2d69742f6c61726176656c2d6931386e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://github.com/beliven-it/laravel-i18n/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5e8664617d8ac1e9f4bac05f213ba72763d71556481ce7fcb6e83091a6bc0ce8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656c6976656e2d69742f6c61726176656c2d6931386e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://github.com/beliven-it/laravel-i18n/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/9da45118f90804c1151bd20d670469ce51ac8a283fe2200ff09a36dcaab1123d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62656c6976656e2d69742f6c61726176656c2d6931386e2e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://packagist.org/packages/beliven-it/laravel-i18n)

A powerful Laravel package for managing translations with ease. Scan your codebase for translation keys, export them to Excel for translators, and import them back seamlessly. Supports both PHP array files and JSON translations.

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

[](#installation)

You can install the package via composer:

```
composer require beliven-it/laravel-i18n
```

Features
--------

[](#features)

- 🔍 **Scan** - Automatically scan your codebase for translation keys (`__()`, `trans()`, `@lang()`)
- 📤 **Export** - Export all translations to Excel format for easy editing by translators
- 📥 **Import** - Import translations back from Excel with merge or overwrite modes
- 🌐 **Dual Format Support** - Handles both PHP array files and JSON translations
- 🎯 **Smart Detection** - Automatically distinguishes between structured (PHP) and simple (JSON) translations
- 📊 **Excel Integration** - Uses PhpSpreadsheet for reliable Excel file handling

How It Works
------------

[](#how-it-works)

The package intelligently handles two types of translations:

### PHP Array Files (Structured Translations)

[](#php-array-files-structured-translations)

Keys with dots are stored in PHP array files with nested structure:

```
__('messages.welcome')        // → lang/en/messages.php
__('clinic/detail.title')     // → lang/en/clinic/detail.php
```

### JSON Files (Simple String Translations)

[](#json-files-simple-string-translations)

Keys without dots are stored in JSON files:

```
__('Welcome')                 // → lang/en.json
__('My Translation')          // → lang/en.json
```

Usage
-----

[](#usage)

### Scanning for Translation Keys

[](#scanning-for-translation-keys)

Scan your application code to find all translation keys:

```
# Scan and add missing keys to all locales
php artisan i18n:manage scan

# Scan for a specific locale only
php artisan i18n:manage scan --locale=en
```

The scanner will:

- Find all `__()`, `trans()`, and `@lang()` calls in your code
- Create appropriate translation files (PHP or JSON)
- Add missing keys to existing files
- Show a summary of created files and added keys

**Example output:**

```
Scanning for translation keys...
  ✓ Created en/messages.php -> welcome
  + Added en/clinic.php -> detail.title

Scan complete!
┌────────────────────────┬───────┐
│ Metric                 │ Count │
├────────────────────────┼───────┤
│ Total keys found       │ 45    │
│ Files created          │ 2     │
│ Keys added             │ 12    │
│ Keys already existing  │ 33    │
└────────────────────────┴───────┘

```

### Exporting Translations

[](#exporting-translations)

Export all translations to an Excel file for translators:

```
# Export to default location (storage/app/translations.xlsx)
php artisan i18n:manage export

# Export to custom location
php artisan i18n:manage export --output=/path/to/translations.xlsx
```

The Excel file will contain:

- **Locale** - The language code (en, it, fr, etc.)
- **Path** - The file path (lang/en/messages.php or lang/en.json)
- **Key** - The translation key
- **Value** - The translation value

### Importing Translations

[](#importing-translations)

Import translations back from Excel:

```
# Import with merge mode (default - keeps existing translations)
php artisan i18n:manage import --input=/path/to/translations.xlsx

# Import with overwrite mode (replaces entire files)
php artisan i18n:manage import --input=/path/to/translations.xlsx --overwrite
```

**Example output:**

```
Importing translations from: /path/to/translations.xlsx (mode: merge)

Import complete!
┌────────────────┬───────┐
│ Metric         │ Count │
├────────────────┼───────┤
│ Files created  │ 1     │
│ Keys added     │ 15    │
│ Keys updated   │ 8     │
└────────────────┴───────┘

```

### Programmatic Usage

[](#programmatic-usage)

You can also use the services directly in your code:

#### Scanning

[](#scanning)

```
use Beliven\I18n\Services\TranslationScanner;
use Beliven\I18n\Services\TranslationFileManager;

$scanner = app(TranslationScanner::class);
$fileManager = app(TranslationFileManager::class);

// Scan for translation keys
$foundKeys = $scanner->scan(['app', 'resources']);

// Parse a key to determine its type
$parsed = $scanner->parseKey('messages.welcome');
// Returns: ['type' => 'php', 'file' => 'messages', 'key' => 'welcome']

$parsed = $scanner->parseKey('Welcome');
// Returns: ['type' => 'json', 'file' => null, 'key' => 'Welcome']
```

#### Managing Translation Files

[](#managing-translation-files)

```
use Beliven\I18n\Services\TranslationFileManager;

$manager = app(TranslationFileManager::class);

// PHP files
$manager->addKey('en', 'messages', 'welcome', 'Welcome!');
$translations = $manager->loadFile('en', 'messages');

// JSON files
$manager->addJsonKey('en', 'Welcome', 'Welcome!');
$jsonTranslations = $manager->loadJsonFile('en');
```

#### Exporting

[](#exporting)

```
use Beliven\I18n\Services\TranslationExporter;

$exporter = app(TranslationExporter::class);
$result = $exporter->export('/path/to/output.xlsx');

// Returns:
// [
//     'locales' => 3,
//     'rows' => 150,
//     'file' => '/path/to/output.xlsx'
// ]
```

#### Importing

[](#importing)

```
use Beliven\I18n\Services\TranslationImporter;

$importer = app(TranslationImporter::class);

// Merge mode
$stats = $importer->import('/path/to/input.xlsx', false);

// Overwrite mode
$stats = $importer->import('/path/to/input.xlsx', true);

// Returns:
// [
//     'files_created' => 2,
//     'keys_added' => 25,
//     'keys_updated' => 10
// ]
```

Workflow Example
----------------

[](#workflow-example)

Here's a typical workflow for managing translations:

1. **Develop** - Write your code using translation functions:

    ```
    echo __('Welcome');                    // Simple string
    echo __('messages.greeting', ['name' => $user->name]);  // Structured
    ```
2. **Scan** - Find all translation keys in your codebase:

    ```
    php artisan i18n:manage scan
    ```
3. **Export** - Export to Excel for your translators:

    ```
    php artisan i18n:manage export --output=translations.xlsx
    ```
4. **Translate** - Send the Excel file to translators
5. **Import** - Import the translated file back:

    ```
    php artisan i18n:manage import --input=translated.xlsx
    ```
6. **Done** - Your application now has all translations!

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/beliven-it/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](https://github.com/beliven-it/.github/blob/main/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Fabrizio Gortani](https://github.com/beliven-it)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance89

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

69d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/471123868194e393f10e7d42f6a430f3cc2f9574128ee5fa10e7d4bad8342f43?d=identicon)[beliven](/maintainers/beliven)

---

Top Contributors

[![beliven-fabrizio-gortani](https://avatars.githubusercontent.com/u/99825015?v=4)](https://github.com/beliven-fabrizio-gortani "beliven-fabrizio-gortani (16 commits)")

---

Tags

exporti18nimportlaravelscanlaravellaravel-i18nBeliven

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/beliven-it-laravel-i18n/health.svg)

```
[![Health](https://phpackages.com/badges/beliven-it-laravel-i18n/health.svg)](https://phpackages.com/packages/beliven-it-laravel-i18n)
```

###  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)[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)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[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)[cosnavel/laravel-query-localization

Query String Localization Package for Laravel

508.2k](/packages/cosnavel-laravel-query-localization)

PHPackages © 2026

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