PHPackages                             jorisvanw/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. jorisvanw/laravel-larex

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

jorisvanw/laravel-larex
=======================

Translate your Laravel application from a single CSV file!

v4.0.1(3y ago)07MITPHPPHP ^8.0

Since Jul 4Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (28)Used By (0)

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

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

[](#laravel-larex)

[![Version](https://camo.githubusercontent.com/aa363a8ba6bdb52607f16c1ef327c3d9d0a6567f69c4a67b5789842ef4e235e9/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f6c61726176656c2d6c617265782f762f737461626c65)](https://packagist.org/packages/lukasss93/laravel-larex)[![Downloads](https://camo.githubusercontent.com/f6a27a13829a800da159d763918e40c592faaa2999a6259632103d9812987eee/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f6c61726176656c2d6c617265782f646f776e6c6f616473)](https://packagist.org/packages/lukasss93/laravel-larex)[![PHP](https://camo.githubusercontent.com/b37aea6382b5bce46a2482879b665b1c6c52c28f27681ee02e98431b5eb22baa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d254532253839254135253230382e302d626c7565)](https://camo.githubusercontent.com/b37aea6382b5bce46a2482879b665b1c6c52c28f27681ee02e98431b5eb22baa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d254532253839254135253230382e302d626c7565)[![Laravel](https://camo.githubusercontent.com/4701ee8a8c9f381958f7ec25182d7360a4d2bac76899c4d208835a2dd59b1c5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d254532253839254135253230382e302d6f72616e6765)](https://camo.githubusercontent.com/4701ee8a8c9f381958f7ec25182d7360a4d2bac76899c4d208835a2dd59b1c5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d254532253839254135253230382e302d6f72616e6765)[![License](https://camo.githubusercontent.com/090f29fe095050c51516c2fffa276f5be6ec4f8998ecb6202343a6b5f76acd07/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f6c61726176656c2d6c617265782f6c6963656e7365)](https://packagist.org/packages/lukasss93/laravel-larex)[![Build](https://camo.githubusercontent.com/867275dcab4f257de53fbdc3b664bc3bf521047c655074c70f85219f55994ad7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4c756b6173737339332f6c61726176656c2d6c617265782f72756e2d7465737473)](https://camo.githubusercontent.com/867275dcab4f257de53fbdc3b664bc3bf521047c655074c70f85219f55994ad7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4c756b6173737339332f6c61726176656c2d6c617265782f72756e2d7465737473)[![Coverage](https://camo.githubusercontent.com/088330d731786f65d661d1342d1111247e36b8f6510a84bfacd8c5ecc193c12f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6c756b6173737339332f6c61726176656c2d6c617265783f746f6b656e3d58634c55326363465137)](https://codecov.io/gh/Lukasss93/laravel-larex)

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

You can import translation entries from resources/lang files 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 resources/lang files.
    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/resources/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.

### 📝 Example

[](#-example)

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

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

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