PHPackages                             lukasss93/laravel-larex - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. lukasss93/laravel-larex

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

lukasss93/laravel-larex
=======================

Translate your Laravel application from a single CSV file!

v4.7.0(1mo ago)9790.3k↓11.1%9[2 issues](https://github.com/Lukasss93/laravel-larex/issues)[1 PRs](https://github.com/Lukasss93/laravel-larex/pulls)1MITPHPPHP ^8.0CI passing

Since Jul 4Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/Lukasss93/laravel-larex)[ Packagist](https://packagist.org/packages/lukasss93/laravel-larex)[ GitHub Sponsors](https://github.com/Lukasss93)[ RSS](/packages/lukasss93-laravel-larex/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (36)Used By (1)

 [![](https://camo.githubusercontent.com/82b72fd3ddba62ec16fc7ab7e9d819d2557be67c70b47d184bbd8dff306fa186/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304c617265782e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6c756b6173737339332532466c61726176656c2d6c617265782b2d2d646576267061747465726e3d67726170685061706572267374796c653d7374796c655f31266465736372697074696f6e3d5472616e736c6174652b796f75722b4c61726176656c2b6170706c69636174696f6e2b776974682b612b73696e676c652b4353562b66696c652532312b266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313235707826696d616765733d7461626c65)](https://camo.githubusercontent.com/82b72fd3ddba62ec16fc7ab7e9d819d2557be67c70b47d184bbd8dff306fa186/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304c617265782e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6c756b6173737339332532466c61726176656c2d6c617265782b2d2d646576267061747465726e3d67726170685061706572267374796c653d7374796c655f31266465736372697074696f6e3d5472616e736c6174652b796f75722b4c61726176656c2b6170706c69636174696f6e2b776974682b612b73696e676c652b4353562b66696c652532312b266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313235707826696d616765733d7461626c65)

Laravel Larex
=============

[](#laravel-larex)

[![Version](https://camo.githubusercontent.com/499783376e1490c11d7d786f267c1c8c9bcfaf823f9387c018d483a3c6e70b33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c756b6173737339332f6c61726176656c2d6c617265783f6c6162656c3d636f6d706f736572266c6f676f3d636f6d706f736572)](https://packagist.org/packages/lukasss93/laravel-larex)[![Downloads](https://camo.githubusercontent.com/29c4178b69b4caf1e239041dbeaf8c01f80d18c62ee3e15a2055ceb4ecdbd0fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c756b6173737339332f6c61726176656c2d6c61726578)](https://packagist.org/packages/lukasss93/laravel-larex)[![License](https://camo.githubusercontent.com/5ccbb1e6fd6eb6e15ff71dc915132ca60b686a08f1eedf726990a6abe3dc7174/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c756b6173737339332f6c61726176656c2d6c61726578)](https://camo.githubusercontent.com/5ccbb1e6fd6eb6e15ff71dc915132ca60b686a08f1eedf726990a6abe3dc7174/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c756b6173737339332f6c61726176656c2d6c61726578)[![PHP](https://camo.githubusercontent.com/f327a34c2110a9c5207b24f7d60d40e55d98b0148afb9bc0c3059f174de2b291/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6c756b6173737339332f6c61726176656c2d6c617265782f7068703f6c6f676f3d706870)](https://camo.githubusercontent.com/f327a34c2110a9c5207b24f7d60d40e55d98b0148afb9bc0c3059f174de2b291/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6c756b6173737339332f6c61726176656c2d6c617265782f7068703f6c6f676f3d706870)[![Laravel](https://camo.githubusercontent.com/276db787329a11da5cc06896e6fb183bc1a5e5090aab3d04ca3f7374230744cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6c756b6173737339332f6c61726176656c2d6c617265782f696c6c756d696e6174652f737570706f72743f6c6162656c3d6c61726176656c266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/276db787329a11da5cc06896e6fb183bc1a5e5090aab3d04ca3f7374230744cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6c756b6173737339332f6c61726176656c2d6c617265782f696c6c756d696e6174652f737570706f72743f6c6162656c3d6c61726176656c266c6f676f3d6c61726176656c)

[![Tests](https://camo.githubusercontent.com/7ce0d359eb3db6e17ee4e722416c6ba2f3b21a68f6cecc286494dd3ec00d1108/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c756b6173737339332f6c61726176656c2d6c617265782f72756e2d74657374732e796d6c3f6c6162656c3d546573742532305375697465266c6f676f3d676974687562)](https://camo.githubusercontent.com/7ce0d359eb3db6e17ee4e722416c6ba2f3b21a68f6cecc286494dd3ec00d1108/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c756b6173737339332f6c61726176656c2d6c617265782f72756e2d74657374732e796d6c3f6c6162656c3d546573742532305375697465266c6f676f3d676974687562)[![Maintainability](https://camo.githubusercontent.com/e40216d9826bcab46026f9eb153f62571273e518420d1b71cc90d188361f9b2c/68747470733a2f2f716c74792e73682f67682f4c756b6173737339332f70726f6a656374732f6c61726176656c2d6c617265782f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/Lukasss93/projects/laravel-larex)[![Code Coverage](https://camo.githubusercontent.com/97ad905f7079d55fddf998c038294756ff4b28aa9c0b7f3f611d87ef0012e411/68747470733a2f2f716c74792e73682f67682f4c756b6173737339332f70726f6a656374732f6c61726176656c2d6c617265782f636f7665726167652e737667)](https://qlty.sh/gh/Lukasss93/projects/laravel-larex)

> Laravel Larex lets you translate your whole Laravel application with a single CSV file.

You can import translation entries from lang folder into a structured CSV, edit the translations and export them back to Laravel PHP files.

Laravel Larex also supports functionalities to sort entries and find strings that aren't localized yet.

*See **[Plugins](#-plugins)** section for other features.*

🚀 Installation
--------------

[](#-installation)

You can install the package using composer

```
composer require lukasss93/laravel-larex --dev
```

Then add the service provider to `config/app.php`.
This step *can be skipped* if package auto-discovery is enabled.

```
'providers' => [
    Lukasss93\Larex\LarexServiceProvider::class
];
```

⚙ Publishing the config file
----------------------------

[](#-publishing-the-config-file)

Publishing the config file is optional:

```
php artisan vendor:publish --provider="Lukasss93\Larex\LarexServiceProvider" --tag="larex-config"
```

👓 Usage
-------

[](#-usage)

1. First, you must create the initial CSV file with `php artisan larex:init`.
    Or you can use `php artisan larex:import` to import entries from lang folder.
    The csv file has the following columns:

    - group (basically the file name)
    - key (the array key)
    - en (the language code)
    - other language codes...
2. Open the *project-root/lang/localization.csv* file and edit it as you see fit.
3. Finally, you can use `php artisan larex:export` to translate your entries from the csv file to the laravel php files.

### ✨ Tips

[](#-tips)

- You can import existing laravel php files with `php artisan larex:import`.
- You can use `php artisan larex:init --base` to init the CSV file with default Laravel entries.
- The **key** column inside the CSV file supports the **dot notation** for nested arrays.
- You can watch your CSV file with `php artisan larex:export --watch`
- You can use `php artisan larex:sort` to sort the CSV file by group and key.
- Be careful when using the `php artisan larex:export` command! It will overwrite all files named with the group names inside the CSV.
- Be careful when using the **dot notation**! Only the **last** entry will override the value.
- You can use `php artisan larex:insert` to add new items via CLI too!
- You can use `php artisan larex:import --include=en,it` to import only *"en"* and *"it"* items.
- You can use `php artisan larex:import --exclude=it` to import all items except *"it"* item.
- You can use `php artisan larex:export --include=en,it` to export only *"en"* and *"it"* columns.
- You can use `php artisan larex:export --exclude=it` to export all columns except *"it"* column.
- You can use `php artisan larex:localize` to find unlocalized strings (use the `--import` option to add strings in your CSV).
- You can use `php artisan larex:find` to search existing groups or keys in your CSV file.
- You can use `php artisan larex:remove` to remove existing strings in your CSV file.
- You can use `php artisan larex:lang:add` to add a new language column to your CSV file.
- You can use `php artisan larex:lang:remove` to remove a language column from your CSV file.
- You can use `php artisan larex:lang:order` to reorder language columns in your CSV file.

### 📝 Example

[](#-example)

1. Run `php artisan larex:init` command
2. Edit the *project-root/lang/localization.csv* file

groupkeyenitapphelloHelloCiaoapplist.developersDevelopersSviluppatoriapplist.teachersTeachersInsegnanti3. Run `php artisan larex:export` command
4. You'll get the following files:

    ```
    //project-root/lang/en/app.php
