{"id":8710,"date":"2026-11-23T06:00:00","date_gmt":"2026-11-23T06:00:00","guid":{"rendered":"https:\/\/poeditor.com\/blog\/?p=8710"},"modified":"2026-11-13T13:51:04","modified_gmt":"2026-11-13T13:51:04","slug":"laravel-localization","status":"publish","type":"post","link":"https:\/\/poeditor.com\/blog\/laravel-localization\/","title":{"rendered":"Laravel localization: How to translate a Laravel app with JSON translation files"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"981\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-1024x981.jpg\" alt=\"\" class=\"wp-image-8732\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-1024x981.jpg 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-300x287.jpg 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-767x735.jpg 767w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-1536x1471.jpg 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization.jpg 1726w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel is a PHP framework that includes routing, the Eloquent ORM, Blade templates and validation out of the box. Its thorough documentation and easy-to-learn conventions make it a popular choice for building PHP web apps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your app is used in different countries, offering an interface in multiple languages makes it easier for users to navigate and understand. Internationalization (i18n) prepares the code so its text and formats can change per language, and localization (l10n) supplies the translations for each one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, we\u2019ll translate a Laravel TO-DO app into French with Laravel\u2019s JSON translation files and POEditor, including the framework\u2019s own validation messages, dates and numbers, while English stays the default language.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#The-TO-DO-app-before-translation\">The TO-DO app before translation<\/a><\/li>\n\n\n\n<li><a href=\"#Wrapping-strings-in-__()\">Wrapping strings in __()<\/a><\/li>\n\n\n\n<li><a href=\"#Generating-langen.json\">Generating lang\/en.json<\/a><\/li>\n\n\n\n<li><a href=\"#Translating-Laravel\u2019s-validation-messages\">Translating Laravel\u2019s validation messages<\/a><\/li>\n\n\n\n<li><a href=\"#Setting-the-locale-with-middleware\">Setting the locale with middleware<\/a><\/li>\n\n\n\n<li><a href=\"#Formatting-dates-and-numbers\">Formatting dates and numbers<\/a><\/li>\n\n\n\n<li><a href=\"#Translating-the-JSON-files-in-POEditor\">Translating the JSON files in POEditor<\/a><\/li>\n<\/ul>\n\n\n\n<h2 id=\"The-TO-DO-app-before-translation\" class=\"wp-block-heading\">The TO-DO app before translation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The TO-DO app is built with Laravel 13 and PHP 8.3, and it uses Blade views and a SQLite database. You register with a username and a password, create lists, add tasks, mark them as done and filter a list by open or completed tasks. Every label, button and flash message is written in English in the Blade views and the controllers, numbers go through PHP\u2019s <code>number_format()<\/code>, and dates are printed with Carbon\u2019s <code>format()<\/code> in US patterns such as <code>M j, Y<\/code>. Validation errors such as \u201cThe name field is required.\u201d come from the English language files inside the framework.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"645\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-1024x645.png\" alt=\"\" class=\"wp-image-8719\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-1024x645.png 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-300x189.png 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-767x483.png 767w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-1536x967.png 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/01_lists_page_en-2048x1290.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>The TO-DO app\u2019s lists page, in English only<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To run it, install the dependencies with <code>composer install<\/code>, copy <code>.env.example<\/code> to <code>.env<\/code>, and run <code>php artisan key:generate<\/code>, <code>php artisan migrate --force<\/code> and php artisan <code>db:seed --force<\/code>. The seeder creates a demo account with the password <code>demo1234<\/code> and three lists. Start the app with <code>php artisan serve<\/code> and open the address it prints.<\/p>\n\n\n\n<h2 id=\"Wrapping-strings-in-__()\" class=\"wp-block-heading\">Wrapping strings in __()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To translate a string in Laravel, pass it to the <code>__()<\/code> helper. In Blade, <code>{{ __('Your lists') }}<\/code> prints the translation for the current language, escaped like any other <code>{{ }}<\/code> output, and prints the text you passed in when there is no translation for it. The <code>@lang<\/code> directive does the same lookup but doesn\u2019t escape the result, so <code>{{ __() }}<\/code> is the safer choice wherever a translation includes something a user typed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the top of the lists page with its strings wrapped:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{{-- resources\/views\/lists\/index.blade.php --}}<br>@section('title', __('Your lists'))<br><br>@section('content')<br>&nbsp; &nbsp; &lt;div class=\"card shadow-sm mb-4\"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=\"card-body\"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form method=\"POST\" action=\"{{ route('lists.store') }}\" id=\"new-list-form\" class=\"row g-2 align-items-start\"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @csrf<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=\"col-12 col-sm\"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=\"new-list-name\" class=\"form-label\"&gt;{{ __('New list') }}&lt;\/label&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=\"text\" id=\"new-list-name\" name=\"name\" value=\"{{ old('name') }}\" placeholder=\"{{ __('Groceries') }}\"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @class(&#091;'form-control', 'is-invalid' =&gt; $errors-&gt;createList-&gt;has('name')])&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=\"col-12 col-sm-auto align-self-sm-end\"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type=\"submit\" class=\"btn btn-primary w-100\"&gt;{{ __('Create list') }}&lt;\/button&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/form&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<br>&nbsp; &nbsp; &lt;\/div&gt;<br><br>&nbsp; &nbsp; @if ($lists-&gt;isEmpty())<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;p class=\"text-body-secondary\"&gt;{{ __(\"You don't have any lists yet. Create your first one above.\") }}&lt;\/p&gt;<br>&nbsp; &nbsp; @else<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;p class=\"text-body-secondary\"&gt;{{ __('Lists: :count', &#091;'count' =&gt; Number::format($lists-&gt;count())]) }}&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A value that changes at runtime goes into the string as a placeholder that starts with a colon, such as <code>:count<\/code>, and you pass its value in an array as the second argument. Laravel fills it in after looking up the translation, so the translator can put <code>:count<\/code> wherever the sentence needs it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The flash messages are set in the controllers, where the original app put the user\u2019s input straight into English sentences, as in <code>\"List \\\"{$list-&gt;name}\\\" created.\" and 'Task \"'.$task-&gt;text.'\" marked as done.'<\/code>. A translator can\u2019t reorder or re-punctuate a sentence that is assembled in code, so each message becomes one string with a placeholder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ app\/Http\/Controllers\/TodoListController.php<\/em><br><strong>public<\/strong> <strong>function<\/strong> store(Request $request): RedirectResponse<br>{<br>&nbsp; &nbsp; $validated = $request-&gt;validateWithBag('createList', &#091;<br>&nbsp; &nbsp; &nbsp; &nbsp; 'name' =&gt; &#091;'required', 'string', 'max:100'],<br>&nbsp; &nbsp; ], &#091;], &#091;'name' =&gt; __('name')]);<br><br>&nbsp; &nbsp; $list = $request-&gt;user()-&gt;todoLists()-&gt;create($validated);<br><br>&nbsp; &nbsp; <strong>return<\/strong> redirect()-&gt;route('lists.show', $list)<br>&nbsp; &nbsp; &nbsp; &nbsp; -&gt;with('success', __('List \":name\" created.', &#091;'name' =&gt; $list-&gt;name]));<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The last array gives the name field a translatable name for its error messages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a JSON translation file the English text is the key, so every place that uses the same English text gets the same translation. The TO-DO app shows \u201cDone\u201d both as a filter tab and as the badge on a finished task, and both read \u201cTermin\u00e9\u201d in French. When two places need different translations, give them different English text.<\/p>\n\n\n\n<h2 id=\"Generating-langen.json\" class=\"wp-block-heading\">Generating lang\/en.json<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel supports two types of translation files in the <code>lang<\/code> directory: PHP files that return arrays of short keys, such as <code>lang\/fr\/messages.php<\/code>, accessed with <code>__('messages.welcome')<\/code>, and JSON files that use the English text as the key. The TO-DO app uses the JSON files, because POEditor imports and exports them in its Key-Value JSON format. POEditor\u2019s PHP Array format is export-only, and it writes a <code>$LANG<\/code> list of term, definition and context entries instead of the array a Laravel language file returns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">New Laravel projects don\u2019t have a lang directory, so create an empty one. <code>php artisan lang:publish<\/code> would create it too, but it also copies Laravel\u2019s English PHP language files into <code>lang\/en<\/code>, which you don\u2019t need here.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel has no command that collects the strings from your code, so the TO-DO app uses the <a href=\"https:\/\/github.com\/kkomelin\/laravel-translatable-string-exporter\" rel=\"nofollow\">Translatable String Exporter<\/a> package, which supports Laravel 13. Install it as a development dependency and run its export command for English:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>composer require kkomelin\/laravel-translatable-string-exporter --dev\nmkdir lang\nphp artisan translatable:export en<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The command searches the <code>app<\/code> and <code>resources<\/code> directories for <code>__()<\/code> and <code>@lang<\/code> calls and writes every string it finds to <code>lang\/en.json<\/code>, with the string as both the key and the value. It doesn\u2019t create the <code>lang<\/code> directory, which is why <code>mkdir<\/code> comes first. The strings it finds on the TO-DO app\u2019s lists page include these:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/<\/strong> <strong>lang\/en.json<\/strong><br>{<br>&nbsp; &nbsp; \"Your lists\": \"Your lists\",<br>&nbsp; &nbsp; \"New list\": \"New list\",<br>&nbsp; &nbsp; \"Groceries\": \"Groceries\",<br>&nbsp; &nbsp; \"Create list\": \"Create list\",<br>&nbsp; &nbsp; \"You don't have any lists yet. Create your first one above.\": \"You don't have any lists yet. Create your first one above.\",<br>&nbsp; &nbsp; \"Lists: :count\": \"Lists: :count\",<br>&nbsp; &nbsp; \"No tasks yet.\": \"No tasks yet.\",<br>&nbsp; &nbsp; \"Tasks left: :count\": \"Tasks left: :count\",<br>&nbsp; &nbsp; \"Created on :date\": \"Created on :date\"<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When you run the command again later, it keeps the values that are already in the file, adds new strings and removes the ones your code no longer uses.<\/p>\n\n\n\n<h2 id=\"Translating-Laravel\u2019s-validation-messages\" class=\"wp-block-heading\">Translating Laravel\u2019s validation messages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The registration form checks the username and password with rules such as <code>required<\/code>, <code>min:3<\/code> and <code>confirmed<\/code>. Laravel builds each error from a language line, such as <code>validation.required<\/code> (\u201cThe :attribute field is required.\u201d), and those lines come from the English validation file inside the framework. Without a French version of the validation file, error messages still appear in English on French pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel\u2019s translator looks in the JSON file before the PHP files for every key, <code>validation.required<\/code> included. So add the messages for the rules your forms use to <code>en.json<\/code>, under their language line names, and they go to POEditor with the rest of the strings. Copy the English text from <code>vendor\/laravel\/framework\/src\/Illuminate\/Translation\/lang\/en\/validation.php<\/code>. Rules that check a size, such as <code>min<\/code> and <code>max<\/code>, have one message per type of value, and a text field uses the <code>string<\/code> one:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/<\/strong> <strong>lang\/en.json<\/strong><br>&nbsp; &nbsp; \"validation.required\"<strong>:<\/strong> \"The :attribute field is required.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.string\"<strong>:<\/strong> \"The :attribute field must be a string.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.min.string\"<strong>:<\/strong> \"The :attribute field must be at least :min characters.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.max.string\"<strong>:<\/strong> \"The :attribute field must not be greater than :max characters.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.alpha_dash\"<strong>:<\/strong> \"The :attribute field must only contain letters, numbers, dashes, and underscores.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.unique\"<strong>:<\/strong> \"The :attribute has already been taken.\"<strong>,<\/strong><br>&nbsp; &nbsp; \"validation.confirmed\"<strong>:<\/strong> \"The :attribute field confirmation does not match.\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The key has to be the language line\u2019s name: an entry keyed by the English sentence, <code>\"The :attribute field is required.\"<\/code>, has no effect, because the validator asks the translator for <code>validation.required<\/code>, never for the sentence.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No <code>__()<\/code> call in the code uses these keys, so the next <code>translatable:export<\/code> en would delete them. The exporter keeps any key listed in <code>lang\/persistent-strings.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/<\/strong> <strong>lang\/persistent-strings.json<\/strong><br>&#091;<br>&nbsp; &nbsp; \"validation.required\",<br>&nbsp; &nbsp; \"validation.string\",<br>&nbsp; &nbsp; \"validation.min.string\",<br>&nbsp; &nbsp; \"validation.max.string\",<br>&nbsp; &nbsp; \"validation.alpha_dash\",<br>&nbsp; &nbsp; \"validation.unique\",<br>&nbsp; &nbsp; \"validation.confirmed\"<br>]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>:attribute<\/code> is the field\u2019s name, which Laravel takes from the input\u2019s <code>name<\/code>, so a French message would still say username. Pass translated names as the third argument of <code>validate()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ app\/Http\/Controllers\/Auth\/RegisterController.php<\/em><br>$rules = &#091;<br>&nbsp; &nbsp; 'username' =&gt; &#091;'required', 'string', 'min:3', 'max:30', 'alpha_dash:ascii', 'unique:users'],<br>&nbsp; &nbsp; 'password' =&gt; &#091;'required', 'string', 'min:8', 'confirmed'],<br>];<br><br>$attributes = &#091;<br>&nbsp; &nbsp; 'username' =&gt; __('username'),<br>&nbsp; &nbsp; 'password' =&gt; __('password'),<br>];<br><br>$validated = $request-&gt;validate($rules, &#091;], $attributes);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With \u201cnom d\u2019utilisateur\u201d as the French translation of <code>username<\/code>, an empty username on a French page gives \u201cLe champ nom d\u2019utilisateur est obligatoire.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel\u2019s error pages, such as the 404 and the 419 \u201cPage Expired\u201d page, call <code>__()<\/code> too, but their views are inside the framework. Run php artisan <code>vendor:publish --tag=laravel-errors<\/code> to copy them into <code>resources\/views\/errors<\/code>, where the exporter finds their strings.<\/p>\n\n\n\n<h2 id=\"Setting-the-locale-with-middleware\" class=\"wp-block-heading\">Setting the locale with middleware<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel stores the current language in the application locale, which starts with the value of <code>APP_LOCALE<\/code> in <code>.env<\/code> and can be changed with <code>App::setLocale()<\/code>. The TO-DO app sets it on every request in a middleware. In <code>config\/app.php<\/code>, define the supported languages and the names to display in the language switcher:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ config\/app.php<\/em><br>'locale' =&gt; env('APP_LOCALE', 'en'),<br><br>'fallback_locale' =&gt; env('APP_FALLBACK_LOCALE', 'en'),<br><br><em>\/\/ ...<\/em><br><br><em>\/\/ The languages the app is translated into, each with the name the<\/em><br><em>\/\/ language switcher shows for it, written in that language.<\/em><br>'available_locales' =&gt; &#091;<br>&nbsp; &nbsp; 'en' =&gt; 'English',<br>&nbsp; &nbsp; 'fr' =&gt; 'Fran\u00e7ais',<br>],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create the middleware with <code>php artisan make:middleware SetLocale<\/code>. It first checks the session for the language selected by the visitor using the switcher. Without one, <code>getPreferredLanguage()<\/code> compares the browser\u2019s <code>Accept-Language<\/code> header with the supported languages and returns the best match, or the first language in the list when nothing matches:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>&lt;?php<\/strong> <em>\/\/ app\/Http\/Middleware\/SetLocale.php<\/em><br><br><strong>namespace<\/strong> App\\Http\\Middleware;<br><br><strong>use<\/strong> Closure;<br><strong>use<\/strong> Illuminate\\Http\\Request;<br><strong>use<\/strong> Illuminate\\Support\\Facades\\App;<br><strong>use<\/strong> Illuminate\\Support\\Number;<br><strong>use<\/strong> Symfony\\Component\\HttpFoundation\\Response;<br><br><strong>class<\/strong> SetLocale<br>{<br>&nbsp; &nbsp; <strong>public<\/strong> <strong>function<\/strong> handle(Request $request, Closure $next): Response<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; $locales = array_keys(config('app.available_locales'));<br><br>&nbsp; &nbsp; &nbsp; &nbsp; <em>\/\/ The language picked with the switcher, or else the browser's first<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; <em>\/\/ supported language, or else the first one in the list (English).<\/em><br>&nbsp; &nbsp; &nbsp; &nbsp; $locale = $request-&gt;session()-&gt;get('locale');<br><br>&nbsp; &nbsp; &nbsp; &nbsp; <strong>if<\/strong> (! in_array($locale, $locales, <strong>true<\/strong>)) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $locale = $request-&gt;getPreferredLanguage($locales);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; App::setLocale($locale);<br>&nbsp; &nbsp; &nbsp; &nbsp; Number::useLocale($locale);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; <strong>return<\/strong> $next($request);<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Carbon\u2019s Laravel service provider listens for the event that <code>App::setLocale()<\/code> fires, so dates switch language with the rest of the app. Laravel\u2019s <code>Number<\/code> class keeps a locale of its own, which is why the middleware also calls <code>Number::useLocale()<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The middleware has to run after the session has started, since it reads the session. Add it to the <code>web<\/code> group right after StartSession, and import both classes at the top of <code>bootstrap\/app.php<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ bootstrap\/app.php<\/em>\n-&gt;withMiddleware(<strong>function<\/strong> (Middleware $middleware): void {\n&nbsp; &nbsp; <em>\/\/ ...<\/em>\n\n&nbsp; &nbsp; <em>\/\/ Right after the session starts, because the language is kept in the<\/em>\n&nbsp; &nbsp; <em>\/\/ session, and before the CSRF check and route model binding, so their<\/em>\n&nbsp; &nbsp; <em>\/\/ 419 and 404 pages are in the visitor's language too.<\/em>\n&nbsp; &nbsp; $middleware-&gt;insertAfterInGroup('web', StartSession::<strong>class<\/strong>, SetLocale::<strong>class<\/strong>);\n})<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$middleware-&gt;web(append: SetLocale::class)<\/code> would work for ordinary pages, but it puts the middleware at the end of the group, after the CSRF check and route model binding. An expired form or a link to a deleted list would then show its error page in English. An address that matches no route skips the web group altogether, so the TO-DO app also ends <code>routes\/web.php<\/code> with <code>Route::fallback(fn () =&gt; abort(404));<\/code>, which sends unknown URLs through it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The TO-DO app keeps the choice in the session rather than in the URL. A language in the URL, such as <code>\/fr\/lists\/1<\/code>, means a <code>{locale}<\/code> prefix on every route and in every link the app generates, and every page of the TO-DO app other than login and registration is behind a login, so there are no public pages that need a separate address per language. The switcher links to a route that saves the language and returns to the page the visitor came from, query string included, so a filtered list stays filtered. The route file needs use <code>Illuminate\\Http\\Request<\/code>; at the top:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ routes\/web.php<\/em><br><em>\/\/ The language switcher: keeps the choice in the session (SetLocale reads it)<\/em><br><em>\/\/ and goes back to the page the visitor was on. Other locales get a 404.<\/em><br>Route::get('\/language\/{locale}', <strong>function<\/strong> (Request $request, string $locale) {<br>&nbsp; &nbsp; $request-&gt;session()-&gt;put('locale', $locale);<br><br>&nbsp; &nbsp; <strong>return<\/strong> back();<br>})-&gt;whereIn('locale', array_keys(config('app.available_locales')))-&gt;name('language.switch');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>whereIn()<\/code> limits <code>{locale}<\/code> to the configured languages, so <code>\/language\/de<\/code> returns a 404. The switcher itself is a partial with one link per language:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{{-- resources\/views\/partials\/language-switcher.blade.php --}}\n&lt;div class=\"btn-group btn-group-sm\" role=\"group\" aria-label=\"{{ __('Language') }}\"&gt;\n&nbsp; &nbsp; @foreach (config('app.available_locales') as $locale =&gt; $name)\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=\"{{ route('language.switch', $locale) }}\" lang=\"{{ $locale }}\"\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @class(&#091;'btn', 'btn-secondary' =&gt; app()-&gt;isLocale($locale), 'btn-outline-secondary' =&gt; ! app()-&gt;isLocale($locale)])\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @if (app()-&gt;isLocale($locale)) aria-current=\"true\" @endif&gt;{{ $name }}&lt;\/a&gt;\n&nbsp; &nbsp; @endforeach\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Include it in the navbar of <code>resources\/views\/layouts\/app.blade.php<\/code> with <code>@include('partials.language-switcher')<\/code>. In the same layout and in the published <code>resources\/views\/errors\/minimal.blade.php<\/code>, replace <code>&lt;html lang=\"en\"&gt; with &lt;html lang=\"{{ str_replace('_', '-', app()-&gt;getLocale()) }}\"&gt;<\/code>, so browsers and screen readers know which language the page is in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Logging out calls <code>$request-&gt;session()-&gt;invalidate()<\/code>, which empties the session and the saved language with it. In <code>LoginController::destroy()<\/code>, read the locale before that call and put it back afterwards, so the login page that follows stays in the visitor\u2019s language:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/\/ app\/Http\/Controllers\/Auth\/LoginController.php<\/em>\n$locale = $request-&gt;session()-&gt;get('locale');\n\nAuth::logout();\n\n$request-&gt;session()-&gt;invalidate();\n$request-&gt;session()-&gt;regenerateToken();\n$request-&gt;session()-&gt;put('locale', $locale);<\/code><\/pre>\n\n\n\n<h2 id=\"Formatting-dates-and-numbers\" class=\"wp-block-heading\">Formatting dates and numbers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Carbon, the date library Laravel uses, has month names and date formats for each language. <code>format()<\/code> always writes English month names, while <code>isoFormat()<\/code> and <code>translatedFormat()<\/code> use the current locale. <code>isoFormat()<\/code> also supports Carbon\u2019s localized date formats, so the date order is handled automatically for each language without having to translate a format string. The <code>ll<\/code> format displays \u201cNov 9, 2026\u201d in English and \u201c9 nov. 2026\u201d in French. The list page uses both <code>LL<\/code> and <code>LT<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{{-- resources\/views\/lists\/show.blade.php --}}\n{{ __('Created on :date at :time', &#091;\n&nbsp; &nbsp; 'date' =&gt; $list-&gt;created_at-&gt;isoFormat('LL'),\n&nbsp; &nbsp; 'time' =&gt; $list-&gt;created_at-&gt;isoFormat('LT'),\n]) }}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In English this reads \u201cCreated on November 9, 2026 at 3:01 PM\u201d, and in French \u201cCr\u00e9\u00e9e le 9 novembre 2026 \u00e0 15:01\u201d. The date under each task uses L, which displays 11\/09\/2026 in English and 09\/11\/2026 in French.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel\u2019s <code>Number<\/code> class uses PHP\u2019s <code>intl<\/code> extension to format numbers. Make sure the extension is enabled, or <code>Number::format() <\/code>will throw an exception. The progress line under each list combines three numbers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{{-- resources\/views\/partials\/progress.blade.php --}}\n{{ __(':done of :total done (:percent)', &#091;\n&nbsp; &nbsp; 'done' =&gt; Number::format($list-&gt;done_tasks_count),\n&nbsp; &nbsp; 'total' =&gt; Number::format($list-&gt;tasks_count),\n&nbsp; &nbsp; 'percent' =&gt; Number::percentage($list-&gt;percentDone(), precision: 1),\n]) }}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Number::percentage()<\/code> takes the percentage itself, so 40 with one decimal is \u201c40.0%\u201d in English and \u201c40,0 %\u201d in French, where <code>Number::format()<\/code> also writes 1,234 as \u201c1 234\u201d. The French translation of the whole line, <code>Termin\u00e9es : :done sur :total (:percent)<\/code>, puts the numbers after a label.<\/p>\n\n\n\n<h2 id=\"Translating-the-JSON-files-in-POEditor\" class=\"wp-block-heading\">Translating the JSON files in POEditor<\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Importing en.json<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In POEditor, click the <strong>+<\/strong> button on the <strong>Dashboard<\/strong>, name the project <code>TO-DO app (Laravel)<\/code>, and add English and French as its languages.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"646\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-1024x646.png\" alt=\"\" class=\"wp-image-8720\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-1024x646.png 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-300x189.png 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-768x484.png 768w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-1536x968.png 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/02_project_languages-2048x1291.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>English and French added to the new project<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Open <strong>Import<\/strong> and choose <code>lang\/en.json<\/code>. On a project\u2019s first import, <strong>Also import translations to a language<\/strong> is already switched on, so leave it on and choose English from the list under it. POEditor detects the file format automatically, but you can also choose it manually: click <strong>set it now<\/strong> and choose <strong>Key-Value JSON (.json)<\/strong> under <strong>CHANGE FILE FORMAT<\/strong>. Then click <strong>Import to project<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"929\" height=\"1024\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-929x1024.png\" alt=\"\" class=\"wp-image-8721\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-929x1024.png 929w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-272x300.png 272w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-768x846.png 768w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-1394x1536.png 1394w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/03_import_json-1859x2048.png 1859w\" sizes=\"auto, (max-width: 929px) 100vw, 929px\" \/><figcaption class=\"wp-element-caption\"><em>Importing<\/em> <em>en.json<\/em> <em>as Key-Value JSON, with its values going into English<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Each key becomes a term, and its value becomes the English translation. The TO-DO app\u2019s <code>en.json<\/code> contains 81 terms, all with English translations. For most of them the term and the English text are the same sentence, but a <code>validation<\/code>.* term has its English sentence only in the English translation. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After this import the project\u2019s <strong>Default Reference Language<\/strong> is still unset, so translators wouldn\u2019t see that English text. Go back to the project page, click the gear icon to open the project settings, click <strong>Edit Details<\/strong>, choose English under <strong>DEFAULT REFERENCE LANGUAGE<\/strong> and click <strong>Save project details<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Translating into French<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open French and translate. Each row shows the English reference text, with the term in smaller type below it. Keep placeholders such as <code>:name <\/code>and <code>:attribute<\/code> exactly as they are, since Laravel replaces them with their values. You can move them within the sentence and adjust the surrounding punctuation to fit French, as in <code>Liste \u00ab :name \u00bb cr\u00e9\u00e9e<\/code>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want a starting point, use <strong>Automatic Translation<\/strong> or <strong>AI<\/strong> under <strong>Translation Options<\/strong> above the list. Both generate French translations that you can review and edit.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-1024x683.png\" alt=\"\" class=\"wp-image-8722\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-1024x683.png 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-300x200.png 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-768x512.png 768w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-1536x1024.png 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/04_french_translations-2048x1366.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>French translations, with the English reference text above each term<\/em><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Exporting fr.json<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Click <strong>Export<\/strong> on the French language page and choose <strong>Key-Value JSON (.json)<\/strong> as the <strong>FILE FORMAT<\/strong>. With <strong>EXPORT<\/strong> left at <strong>All<\/strong>, an untranslated term is written with an empty value, &#8220;&#8221;. Laravel prints the key in place of an empty translation, which for most strings is the English text, but for a validation message it\u2019s the key itself, so a French form would say <code>validation.required<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Until the French translations are complete, enable <strong>Advanced export options<\/strong> and set <strong>EXPORT<\/strong> to <strong>Translated<\/strong>. This excludes untranslated terms from the exported file. Laravel then shows English text for those missing translations. For regular strings it prints the key, which is the English text, and for validation.* entries it uses the framework\u2019s English message, since <code>APP_FALLBACK_LOCALE<\/code> is set to <code>en<\/code>. Click <strong>Export File<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"774\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-1024x774.png\" alt=\"\" class=\"wp-image-8723\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-1024x774.png 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-300x227.png 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-767x580.png 767w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-1536x1162.png 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/05_export_json-2048x1549.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>Exporting the French translations as Key-Value JSON<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The download is named <code>TO-DO_app_Laravel_French.json<\/code>. Save it as <code>lang\/fr.json<\/code>. It contains the same keys as <code>en.json<\/code>, in the same order, but with the French translations as their values. Here are a few of its entries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/<\/strong> <strong>lang\/fr.json<\/strong><br>{<br>&nbsp; &nbsp; \"Your lists\": \"Vos listes\",<br>&nbsp; &nbsp; \"New list\": \"Nouvelle liste\",<br>&nbsp; &nbsp; \"Groceries\": \"Courses\",<br>&nbsp; &nbsp; \"Create list\": \"Cr\u00e9er la liste\",<br>&nbsp; &nbsp; \"Lists: :count\": \"Listes : :count\",<br>&nbsp; &nbsp; \"validation.required\": \"Le champ :attribute est obligatoire.\"<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>php artisan serve<\/code> uses the new file on the next request, so reload the page and click <strong>Fran\u00e7ais<\/strong> in the navbar.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"644\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-1024x644.png\" alt=\"\" class=\"wp-image-8724\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-1024x644.png 1024w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-300x189.png 300w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-768x483.png 768w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-1536x967.png 1536w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/06_lists_page_fr-2048x1289.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>The lists page in French, with French number and date formats<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On a list page, the dates use the French formats, the filter tabs and status badges are translated, and a form that fails validation shows the French message with the translated field name. Here is the Groceries list after an empty task is submitted, first in English and then in French:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"1024\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-987x1024.png\" alt=\"\" class=\"wp-image-8725\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-987x1024.png 987w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-289x300.png 289w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-767x796.png 767w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-1481x1536.png 1481w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_en-1974x2048.png 1974w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\" \/><figcaption class=\"wp-element-caption\"><em>A list in English, with a validation message from en.json<\/em><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"1024\" src=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-987x1024.png\" alt=\"\" class=\"wp-image-8726\" srcset=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-987x1024.png 987w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-289x300.png 289w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-767x796.png 767w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-1481x1536.png 1481w, https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/07_list_page_fr-1974x2048.png 1974w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\" \/><figcaption class=\"wp-element-caption\"><em>A list in French, with a validation message from fr.json<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping up<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When you change the app\u2019s text, run <code>php artisan translatable:export en<\/code> again. It adds the new strings to <code>en.json<\/code>, removes the ones the code no longer uses and keeps the keys in <code>persistent-strings.json<\/code>. Then import <code>en.json<\/code> into POEditor as Key-Value JSON. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On later imports, <strong>Also import translations to a language<\/strong> is switched off by default. Turn it on and select English when importing, otherwise the new terms won\u2019t have English translations. Since the English text is used as the key, changing a sentence creates a new term that has no French translation yet. The old term appears on the <strong>Obsolete Terms<\/strong> page after the import, where you can select it and click <strong>Delete Selected<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Translate the new terms, export French again and replace <code>lang\/fr.json<\/code>. To automate this for every release, use the <a href=\"\/docs\/api\">POEditor API<\/a> or a <a href=\"\/kb\/localization-file-management-with-github-bitbucket-and-gitlab-integrations\">code hosting integration<\/a> to upload <code>en.json<\/code> and download the translated files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"\/register\/\">Create a free POEditor account<\/a> and import your own <code>lang\/en.json<\/code> to start translating your Laravel app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For other stacks in this series, see these guides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"\/blog\/python-gettext-localization\/\">Python gettext localization: How to translate a Python app<\/a><\/li>\n\n\n\n<li><a href=\"\/blog\/django-i18n\/\">Django i18n: How to translate and localize your app<\/a><\/li>\n\n\n\n<li><a href=\"\/blog\/cakephp-localization\/\">CakePHP localization: How to translate a CakePHP app with i18n<\/a><\/li>\n\n\n\n<li><a href=\"\/blog\/node-js-localization\/\">Node.js localization: How to translate an express app with i18n-node<\/a><\/li>\n\n\n\n<li><a href=\"\/blog\/asp-net-core-localization\/\">ASP.NET Core localization: How to translate a Razor Pages app with .resx files<\/a><\/li>\n\n\n\n<li><a href=\"\/blog\/rails-i18n\/\">Rails i18n: How to translate a Ruby on Rails app with YAML locale files<\/a><\/li>\n<\/ul>\n\n\n<div class=\"call-action my-4 d-flex justify-content-between align-items-md-center gap-4 flex-column flex-lg-row\"><div><h3 class=\"fs-4\">Ready to power up localization?<\/h3><span class=\"fs-6\">Subscribe to the POEditor platform today!<\/span><\/div><a class=\"btn btn-b-primary d-flex align-items-center justify-content-center px-4 py-3 flex-shrink-0\" \n\t\t\t\t\thref=\"https:\/\/poeditor.com\/pricing\/?utm_source=blog&#038;utm_medium=btn&#038;utm_campaign=cta_pricing\">See pricing<\/a><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Why does a French page still show some English text?<\/summary>\n<p class=\"wp-block-paragraph\">Laravel looks up JSON translations using exact keys, so <code>__('Log In')<\/code> and <code>__('Log in')<\/code> are treated as different strings. Changing the wording, punctuation or spacing in the code also creates a new key that <code>fr.json<\/code> doesn\u2019t contain yet. When the key is missing, Laravel prints the key itself, which is the English text. An empty value, &#8220;&#8221;, gives the same result, except for a validation.* key, where the page shows the key name, such as v<code>alidation.required<\/code>. Run <code>php artisan translatable:export en<\/code>, import <code>en.json<\/code> into POEditor, translate the new terms and export French again. To check <code>fr.json<\/code> from the command line, <code>php artisan translatable:inspect-translations fr --export-first<\/code> adds the strings missing from it, with their English text as the value, and lists every entry whose value is the same as its key. That list also includes words spelled the same in both languages, such as \u201cMenu\u201d.<br><\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How do I translate Laravel\u2019s other built-in messages?<\/summary>\n<p class=\"wp-block-paragraph\">You can translate them just like the validation messages. Laravel\u2019s translator checks the JSON file first for any key, so a message such as <code>auth.failed<\/code> or <code>passwords.reset<\/code> can go into en.json under that key, with its English text copied from the matching file in <code>vendor\/laravel\/framework\/src\/Illuminate\/Translation\/lang\/en\/<\/code>. Add the key to <code>lang\/persistent-strings.json<\/code> as well, so <code>translatable:export<\/code> doesn\u2019t remove it, and it goes to POEditor with your other strings.<br><\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Can I use Laravel\u2019s PHP language files with POEditor instead of JSON?<\/summary>\n<p class=\"wp-block-paragraph\">POEditor can\u2019t import PHP files, and its PHP Array export writes a <code>$LANG<\/code> list of term, definition and context entries, which Laravel can\u2019t load as a language file. Keep the strings you send to translators in the JSON files. If your app already uses short keys from PHP files, such as <code>__('messages.welcome')<\/code>, you can move those entries into <code>en.json<\/code> and fr.json with the same keys, because Laravel checks the JSON file for <code>messages.welcome<\/code> before it opens <code>lang\/fr\/messages.php<\/code>. Give each key its English text as the value in <code>en.json<\/code>; the exporter writes the key as the value for a string it hasn\u2019t seen before, and keeps a value you\u2019ve changed.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How do I translate the same English text in two different ways?<\/summary>\n<p class=\"wp-block-paragraph\">With JSON files the English text is the key, so <code>__('Open')<\/code> has one translation wherever it appears. When a word needs two translations, for example a button label and a status, make the two source texts different, or use a key that names the place, such as <code>__('filters.open')<\/code>, and set its English text in <code>en.json<\/code>. The exporter keeps the value you set, and with English as the <strong>Default Reference Language<\/strong>, translators see that text above the key in POEditor.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>How do I translate text that JavaScript shows, such as a confirm() dialog?<\/summary>\n<p class=\"wp-block-paragraph\">Use <code>@js<\/code> to pass the Blade translation to the script as a JavaScript string literal, with quotes and HTML characters properly escaped. The TO-DO app\u2019s task delete buttons use <code>onsubmit=\"return confirm(@js(__('Delete this task?')))\"<\/code>, and the exporter finds the <code>__()<\/code> call in the Blade file like any other. Laravel doesn\u2019t provide <code>__()<\/code> in the browser, so text that lives in your JavaScript files needs a JavaScript translation library that reads the same JSON files.<br><\/p>\n<\/details>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel is a PHP framework that includes routing, the Eloquent ORM, Blade templates and validation out of the box. Its thorough documentation and easy-to-learn conventions make it a popular choice for building PHP web apps. If your app is used in different countries, offering an interface in multiple languages makes it easier for users to [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-8710","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog<\/title>\n<meta name=\"description\" content=\"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/poeditor.com\/blog\/laravel-localization\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor\" \/>\n<meta property=\"og:url\" content=\"https:\/\/poeditor.com\/blog\/laravel-localization\/\" \/>\n<meta property=\"og:site_name\" content=\"POEditor Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/POEditor\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-23T06:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1726\" \/>\n\t<meta property=\"og:image:height\" content=\"1653\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"POEditor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@poeditor\" \/>\n<meta name=\"twitter:site\" content=\"@poeditor\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"POEditor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/\"},\"author\":{\"name\":\"POEditor\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#\\\/schema\\\/person\\\/db77eb2d09539eaac83dcd8f2af06b17\"},\"headline\":\"Laravel localization: How to translate a Laravel app with JSON translation files\",\"datePublished\":\"2026-11-23T06:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/\"},\"wordCount\":2981,\"publisher\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/laravel-localization-1024x981.jpg\",\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/\",\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/\",\"name\":\"Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/laravel-localization-1024x981.jpg\",\"datePublished\":\"2026-11-23T06:00:00+00:00\",\"description\":\"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#primaryimage\",\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/laravel-localization.jpg\",\"contentUrl\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/laravel-localization.jpg\",\"width\":1726,\"height\":1653,\"caption\":\"laravel localization with POEditor\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/laravel-localization\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel localization: How to translate a Laravel app with JSON translation files\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/\",\"name\":\"POEditor Blog\",\"description\":\"All about translation and localization management\",\"publisher\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#organization\",\"name\":\"POEditor\",\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/logo_head_512_transparent.png\",\"contentUrl\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/logo_head_512_transparent.png\",\"width\":512,\"height\":512,\"caption\":\"POEditor\"},\"image\":{\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/POEditor\",\"https:\\\/\\\/x.com\\\/poeditor\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/poeditor\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCXAk1u8N49VRMAqNneENCFA\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/#\\\/schema\\\/person\\\/db77eb2d09539eaac83dcd8f2af06b17\",\"name\":\"POEditor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g\",\"caption\":\"POEditor\"},\"url\":\"https:\\\/\\\/poeditor.com\\\/blog\\\/author\\\/poeditor\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog","description":"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/poeditor.com\/blog\/laravel-localization\/","og_locale":"en_US","og_type":"article","og_title":"Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog","og_description":"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor","og_url":"https:\/\/poeditor.com\/blog\/laravel-localization\/","og_site_name":"POEditor Blog","article_publisher":"https:\/\/www.facebook.com\/POEditor","article_published_time":"2026-11-23T06:00:00+00:00","og_image":[{"width":1726,"height":1653,"url":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization.jpg","type":"image\/jpeg"}],"author":"POEditor","twitter_card":"summary_large_image","twitter_creator":"@poeditor","twitter_site":"@poeditor","twitter_misc":{"Written by":"POEditor","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#article","isPartOf":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/"},"author":{"name":"POEditor","@id":"https:\/\/poeditor.com\/blog\/#\/schema\/person\/db77eb2d09539eaac83dcd8f2af06b17"},"headline":"Laravel localization: How to translate a Laravel app with JSON translation files","datePublished":"2026-11-23T06:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/"},"wordCount":2981,"publisher":{"@id":"https:\/\/poeditor.com\/blog\/#organization"},"image":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#primaryimage"},"thumbnailUrl":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-1024x981.jpg","articleSection":["Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/","url":"https:\/\/poeditor.com\/blog\/laravel-localization\/","name":"Laravel localization: How to translate a Laravel app with JSON translation files - POEditor Blog","isPartOf":{"@id":"https:\/\/poeditor.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#primaryimage"},"image":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#primaryimage"},"thumbnailUrl":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization-1024x981.jpg","datePublished":"2026-11-23T06:00:00+00:00","description":"Learn how to implement Laravel localization to support multiple languages in your application, and how to translating JSON files in POEditor","breadcrumb":{"@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/poeditor.com\/blog\/laravel-localization\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#primaryimage","url":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization.jpg","contentUrl":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2026\/11\/laravel-localization.jpg","width":1726,"height":1653,"caption":"laravel localization with POEditor"},{"@type":"BreadcrumbList","@id":"https:\/\/poeditor.com\/blog\/laravel-localization\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/poeditor.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Laravel localization: How to translate a Laravel app with JSON translation files"}]},{"@type":"WebSite","@id":"https:\/\/poeditor.com\/blog\/#website","url":"https:\/\/poeditor.com\/blog\/","name":"POEditor Blog","description":"All about translation and localization management","publisher":{"@id":"https:\/\/poeditor.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/poeditor.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/poeditor.com\/blog\/#organization","name":"POEditor","url":"https:\/\/poeditor.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/poeditor.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2019\/11\/logo_head_512_transparent.png","contentUrl":"https:\/\/poeditor.com\/blog\/wp-content\/uploads\/2019\/11\/logo_head_512_transparent.png","width":512,"height":512,"caption":"POEditor"},"image":{"@id":"https:\/\/poeditor.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/POEditor","https:\/\/x.com\/poeditor","https:\/\/www.linkedin.com\/company\/poeditor\/","https:\/\/www.youtube.com\/channel\/UCXAk1u8N49VRMAqNneENCFA"]},{"@type":"Person","@id":"https:\/\/poeditor.com\/blog\/#\/schema\/person\/db77eb2d09539eaac83dcd8f2af06b17","name":"POEditor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/95bca2c465fe6134f210cb2f2fbed4f71bf37833fb285624320e808c865695c1?s=96&d=mm&r=g","caption":"POEditor"},"url":"https:\/\/poeditor.com\/blog\/author\/poeditor\/"}]}},"_links":{"self":[{"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/posts\/8710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/comments?post=8710"}],"version-history":[{"count":7,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/posts\/8710\/revisions"}],"predecessor-version":[{"id":8738,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/posts\/8710\/revisions\/8738"}],"wp:attachment":[{"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/media?parent=8710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/categories?post=8710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poeditor.com\/blog\/wp-json\/wp\/v2\/tags?post=8710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}