Documentation reviewed 23 November 2026.
Quick answer
The right tool to translate a Laravel application depends on who does the translating. If developers translate, a package that edits the files in lang/ is enough. If the app needs many languages or changes often, use a localization tool that reads Laravel's JSON and PHP files directly, translates the strings that changed, and writes the files back without touching :name placeholders. Whichever you choose, test it on validation.php and on a pluralized string first, since those are where Laravel files break.
How Laravel stores translations
Laravel reads two kinds of file from the lang directory. On a fresh Laravel 11 or 12 app the directory does not exist until you run php artisan lang:publish.
JSON files, one per language. The key is the source sentence:
You call them with the sentence itself: __('Welcome back').
PHP files, in a folder per language. Each returns an array, and the key is a short name:
You call them with the file name and the key: __('messages.welcome').
Two details matter to any translation tool:
- Placeholders start with a colon:
Hello, :name!. Laravel also accepts:Nameand:NAME, which capitalize the inserted value. A translator or a model that changes:nameto:nombreaks the string silently, because Laravel prints the unknown placeholder as text. - Plurals are written with pipes in one string and read with
trans_choice():
JSON or PHP files: which to use
| JSON files | PHP files | |
|---|---|---|
| Key | The source sentence | A short name such as messages.welcome |
| Files per language | One | One per group |
| Nested groups | No | Yes |
| Comments | No | Yes |
| Fits | Apps that write English in the code and translate later | Apps that want grouped keys and stable names |
Many apps use both: PHP files for the framework's own messages and JSON for the application's text. For automatic translation, JSON is the safer format. It has one fixed shape, so a tool can read and write it without interpreting PHP.
Four ways to translate a Laravel app
| Approach | How it works | Fits |
|---|---|---|
| Edit the files by hand | Copy lang/en to lang/fr and translate | One or two languages, rare changes |
| A translation package | A Composer package adds an editor or a command inside the app | Developers who translate themselves |
| A script and a model API | An Artisan command sends changed strings to a model | Many languages, no reviewers |
| A localization platform | A service reads the files, translates, and gives reviewers an editor | Many languages, non-developer reviewers |
Laravel's own messages in other languages come from the community Laravel Lang packages, which cover validation, authentication and pagination text. Your application's own strings still need one of the four approaches.
Platforms that work with Laravel's translation files include Lokalise, Crowdin, Localazy and Transglot. Check that the one you pick supports both the JSON and the PHP format if you use both, and see how each one prices the work: the Lokalise, Crowdin and Localazy comparisons price one workload on each.
Translating a Laravel app with Transglot, step by step
1. Connect the repository
From the project root:
init finds the files in lang/, works out the source language, signs you in through the browser, asks which languages you want, and runs the first translation. It needs Node.js 22 or later on the machine, not in the app. If the repository only has English, name the targets:
2. Read the configuration it wrote
init writes a transglot.json file. For an app with one JSON file per language and one PHP group, it looks like this:
sources lists what is uploaded. pull lists where each language is written. Commit the file.
3. Push and pull
push sends only the strings that changed since the last run and waits for the translation. pull writes each language back into lang/. An unchanged file translates nothing and costs nothing.
4. Run it on every merge
Create .github/workflows/transglot.yml:
Create a deploy token with the push and pull abilities in the project, and add it as a repository secret named TRANSGLOT_TOKEN. On each push to main the action uploads new strings, waits, pulls the translated files and commits them back. The GitHub Action guide covers the other commit modes.
What it handles, and what it does not
- Laravel JSON is read and written as is. Every value must be a string.
- Laravel PHP is supported for flat arrays of single-quoted strings. Files with nested arrays, comments or double-quoted strings are refused at import. That includes Laravel's bundled
validation.php, which nests itscustomandattributesgroups. - Placeholders such as
:name,:Nameand:NAMEare written back exactly, and a translation that drops one is flagged by the quality checks. - Pipe plurals are stored and returned as one string. They are not expanded into the plural forms each language needs.
- PHP files go through the command line tool or the API. The browser upload takes JSON.
The command line tool and the action start on the Starter plan, $19 a month for 300,000 translated words. See pricing.
Handling validation.php and pipe plurals
For validation.php, the practical split is:
- Install Laravel Lang for the framework's messages in each language.
- Keep only your customized messages and attribute names in your own files.
- Put those in the JSON file, or in a flat PHP file of their own, so a tool can read them.
For pipe plurals, remember that explicit ranges only cover the cases you wrote. {1} One file|[2,*] :count files works in French and German. It is wrong in Polish, Russian and Arabic, which need more than two forms, and a range cannot express their rules: Polish uses one form for 2 to 4 and for 22 to 24, and another for 5 to 21.
Laravel handles this when you leave the ranges out. Without ranges, trans_choice() picks the form by the plural rules of the language, in order. A Polish translation then has three parts:
So write the English source without ranges where you can (':count file|:count files'), and have a native speaker confirm the number and order of forms in languages with more than two. A translation tool returns the string it was given, so a two-part English string comes back as a two-part Polish string unless someone adds the third.
A test that catches a missing translation
Automatic translation fails quietly when a key is missing in one language. Add a test that compares every language file with the English one:
Run it in the same pipeline as the translation step. How to check Laravel JSON translations goes further into these checks.
What to test before you commit to a tool
- Push a file that contains
:name,:Nameand:count. Confirm all three return unchanged. - Push a pipe plural with three ranges. Confirm the pipes and ranges are intact.
- Change one English sentence and push again. Confirm only that string is translated.
- Pull into a clean branch and run your test suite. A missing key should fail a test, not reach production.
Frequently asked questions
Should I use JSON or PHP translation files in Laravel?
JSON suits apps that key strings by the source sentence and want one file per language. PHP files suit grouped keys such as messages.welcome. Many apps use both. For automatic translation, JSON is the safer format because it has one fixed shape.
Can AI translate Laravel language files?
Yes. The risks are the same as with any locale file: translated keys, changed placeholders and broken plural strings. Use a tool or a script that checks placeholders after translation.
What about Laravel's validation messages?
The framework's own messages are already translated by the community Laravel Lang packages for most languages. Translate only the messages you customized.
How do I keep translations current after each release?
Run the push and pull commands in continuous integration, so a changed English string is translated on the same merge. Transglot has a GitHub Action for this, and transglot push --wait exits with a failure code when a string is refused. Localization as code describes the workflow.
How much does it cost to translate a Laravel app?
An app with 2,000 strings of 8 words each is 16,000 words. Into 10 languages that is 160,000 translated words, inside the Starter plan's monthly 300,000. After the first run, only changed strings count.
How this guide was checked
- Laravel behaviour (file layout, placeholders,
trans_choice()and plural selection) follows the Laravel documentation linked under Sources. - The commands, configuration and format limits are taken from the product documentation on the review date. The limits are listed in full, including the files that are refused.
- The Pest tests are examples to adapt. They check JSON files only.
- The other platforms named were not tested for this guide. Check each one's format support against your own files before choosing.