Skip to content

Optional analytics, session recording and advertising stay off unless you accept. You can reject them and use Transglot. Change your choice anytime in Cookie preferences. Cookie Policy

Back to the blog
Developer platform

The Best Tools to Translate a Laravel Application in 2026

How Laravel stores translations, four ways to translate a Laravel app, and what to check so :name placeholders and pipe plurals survive.

by transglot team
published November 23, 2026
8 min read

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:

jsonjson
{
"Welcome back": "Bon retour",
"Hello, :name!": "Bonjour, :name !",
"You have :count new messages.": "Vous avez :count nouveaux messages."
}

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:

phpphp
<?php
return [
'welcome' => 'Bon retour',
'greeting' => 'Bonjour, :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 :Name and :NAME, which capitalize the inserted value. A translator or a model that changes :name to :nom breaks the string silently, because Laravel prints the unknown placeholder as text.
  • Plurals are written with pipes in one string and read with trans_choice():
phpphp
'messages' => '{0} No messages|{1} One message|[2,*] :count messages',

JSON or PHP files: which to use

JSON filesPHP files
KeyThe source sentenceA short name such as messages.welcome
Files per languageOneOne per group
Nested groupsNoYes
CommentsNoYes
FitsApps that write English in the code and translate laterApps 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

ApproachHow it worksFits
Edit the files by handCopy lang/en to lang/fr and translateOne or two languages, rare changes
A translation packageA Composer package adds an editor or a command inside the appDevelopers who translate themselves
A script and a model APIAn Artisan command sends changed strings to a modelMany languages, no reviewers
A localization platformA service reads the files, translates, and gives reviewers an editorMany 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:

bashbash
npx transglot@latest init

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:

bashbash
npx transglot@latest init --targets fr,de,es

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:

jsonjson
{
"url": "https://api.transglot.ai",
"sources": [
{ "path": "lang/{locale}.json", "format": "laravel_json", "locales": ["en"] },
{ "path": "lang/{locale}/messages.php", "format": "laravel_php", "locales": ["en"] }
],
"pull": [
{ "path": "lang/{locale}.json", "format": "laravel_json" },
{ "path": "lang/{locale}/messages.php", "format": "laravel_php" }
]
}

sources lists what is uploaded. pull lists where each language is written. Commit the file.

3. Push and pull

bashbash
transglot push --wait
transglot 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:

yamlyaml
name: transglot
on:
push:
branches: [main]
jobs:
localize:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: transglot/transglot-action@v1
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
url: https://api.transglot.ai

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 its custom and attributes groups.
  • Placeholders such as :name, :Name and :NAME are 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:

  1. Install Laravel Lang for the framework's messages in each language.
  2. Keep only your customized messages and attribute names in your own files.
  3. 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:

phpphp
'files' => ':count plik|:count pliki|:count plików',

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:

phpphp
<?php
test('every language has every key of the English file', function () {
$source = json_decode(file_get_contents(lang_path('en.json')), true);
foreach (glob(lang_path('*.json')) as $file) {
$translated = json_decode(file_get_contents($file), true);
$missing = array_diff_key($source, $translated);
expect($missing)->toBeEmpty(basename($file).' is missing keys');
}
});
test('placeholders survive translation', function () {
$source = json_decode(file_get_contents(lang_path('en.json')), true);
foreach (glob(lang_path('*.json')) as $file) {
$translated = json_decode(file_get_contents($file), true);
foreach ($source as $key => $english) {
preg_match_all('/:[A-Za-z_]+/', $english, $expected);
foreach ($expected[0] as $placeholder) {
expect(strtolower($translated[$key] ?? ''))
->toContain(strtolower($placeholder));
}
}
}
});

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

  1. Push a file that contains :name, :Name and :count. Confirm all three return unchanged.
  2. Push a pipe plural with three ranges. Confirm the pipes and ranges are intact.
  3. Change one English sentence and push again. Confirm only that string is translated.
  4. 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.

Sources

colophon

Who wrote this, and what to read next

wrote this

transglot team

The byline on this post has no profile yet. Author profiles are managed alongside the posts themselves.

Engineering
Developer platform
keep reading

Check Laravel JSON translations before they reach production

Check Laravel JSON translations for missing keys and changed placeholders, then validate reviewed locale files before release with an executable PHP example.

November 9, 2026
8 min read
keep reading

Localization as code: automate translations in CI/CD

Connect localization to CI/CD with scoped tokens, explicit waiting, reviewed translation snapshots and a recovery path for failed or partial runs.

February 24, 2026
7 min read
works with what you already run

41 connectors, already built.

the pipeline this post describes

Try it on your own strings. Free, no card.

Free plan: 100,000 words to start (25,000 at sign-up, 75,000 after a phone check), then 10,000 a month, 15 locales including your source, 3 seats.