Laravel Localization · · 8 min read

Internationalizing a Legacy Laravel App: A Staged Plan That Doesn't Stall

The typical attempt to internationalize an existing Laravel app goes like this. Someone estimates two weeks. A developer starts extracting strings from Blade templates. Three weeks later they're 60% through the views, haven't touched controllers or emails, the branch has forty conflicts, and a more urgent feature arrives. The branch is abandoned. Six months later someone estimates two weeks.

The failure isn't the extraction work — that part is tedious but tractable. It's sequencing: doing all the extraction before any of the value, in one long-lived branch, with no way to ship increments.

Here's a plan that avoids that.

Stage 0: Decide the taxonomy first

An hour here saves weeks later, because renaming keys across a codebase after the fact is miserable.

Use short semantic keys, not English strings. With string keys, fixing a typo in the English text orphans every translation of it — silently. Covered in JSON vs PHP lang files, and it's the single decision most likely to cause regret.

Group by feature, not by page. Pages get redesigned and merged; features are stabler:

lang/en/
    auth.php
    billing.php
    cart.php
    orders.php
    settings.php
    validation.php

Namespace by context inside the group. This is what makes translation correct, not just present:

// lang/en/orders.php
return [
    'headings' => ['index' => 'Your orders', 'show' => 'Order :number'],
    'actions' => ['cancel' => 'Cancel order', 'reorder' => 'Order again'],
    'status' => ['pending' => 'Pending', 'shipped' => 'Shipped'],
    'empty' => 'You have no orders yet.',
];

orders.actions.cancel and orders.status.cancelled are different words in many languages. One ambiguous key shared between a button and a status is a translation bug you can't fix without splitting the key — so split it now.

Write down the rules. Three lines in CONTRIBUTING.md: short keys, grouped by feature, namespaced by context. Without it, the second developer invents a different convention and you have two.

Stage 1: Make the app locale-aware while still monolingual

Do the plumbing before the extraction, with English as the only language. It's a small, reviewable, mergeable change:

  • Locale middleware in the web group (so Livewire updates get it too)
  • App::setLocale(), Carbon::setLocale() and Number::useLocale() — three separate systems
  • available_locales and rtl_locales in config
  • A locale column on users, and HasLocalePreference on the model
  • lang and dir on <html>, with hyphens in lang
  • php artisan lang:publish for the framework's own files

This merges in a day and changes no behaviour. It's also the foundation everything else needs, and doing it first means the extraction branches stay short.

Stage 2: Find the strings, don't extract them yet

Before touching code, get an inventory. You need to know whether this is 400 strings or 4,000, because the two are different projects.

Scan for candidates. Our Blade scanner handles individual templates if you want to see what detection looks like; for the whole repo you want something that walks directories and produces a count per area.

The output you want is a table: area, string count, and a rough tier. Something like:

| Area | Strings | Tier | |---|---|---| | Checkout flow | 120 | 1 — revenue path | | Auth + onboarding | 95 | 1 | | Account settings | 210 | 2 | | Transactional emails | 140 | 2 | | Admin panel | 890 | 3 — internal only | | Marketing pages | 180 | 2 |

That admin panel row is the one that saves the project. 890 strings used only by your own staff, who read English, do not need to be in the first phase — and possibly not ever. Teams that extract alphabetically hit the admin panel early and burn a third of their budget on it.

Don't skip the non-obvious surfaces while counting: placeholder/title/alt attributes, exception messages, validation, enum labels, mail subjects, PDF templates, notification text, Mailable markdown, and Laravel's own published vendor views.

Stage 3: Extract by user journey, ship each one

This is the part that changes the outcome. One journey per pull request, merged and deployed.

Take checkout. Extract its 120 strings, add lang/en/checkout.php, merge, deploy. Nothing user-visible changed — you've replaced literals with __() calls resolving to the same English text. It's safe, reviewable in an afternoon, and it's done.

Then auth. Then settings. Each PR is small, conflicts are rare because they touch different files, and progress is real rather than a percentage on a branch.

The mechanical work per journey:

{{-- Before --}}
<h1>Your orders</h1>
<button title="Cancel this order">Cancel order</button>
<input placeholder="Search orders">

{{-- After --}}
<h1>{{ __('orders.headings.index') }}</h1>
<button title="{{ __('orders.actions.cancel_hint') }}">{{ __('orders.actions.cancel') }}</button>
<input placeholder="{{ __('orders.search_placeholder') }}">

Then a ratchet test so the journey can't regress — a scoped version of the hardcoded-string check from the testing post, pointed at the directories you've finished. Scoped narrowly it's genuinely useful; pointed at the whole app it produces noise nobody acts on.

Order journeys by value: revenue path first, then acquisition, then retention, then internal. If the project is cancelled after three journeys, you want those three to have been checkout, signup and onboarding.

Stage 4: Add the second language

Only now, with English fully extracted for the journeys you care about, add a real target language.

Do it for one journey first, end to end. Translate checkout into Spanish, ship it, and look at it in a browser. You will find things no amount of extraction review surfaces:

  • Buttons that don't fit — German and Finnish expand substantially
  • Plural lines with too few forms, silently rendering the singular
  • Dates still in English because something calls format() instead of isoFormat()
  • An email whose subject is English because it was resolved in a constructor
  • Currency with the symbol on the wrong side
  • A validation message with an English field name inside a translated sentence, because attributes is empty

Every one of those is a class of bug that would otherwise appear thirty times across the app. Finding them on 120 strings instead of 4,000 is the entire argument for this sequencing.

Then apply the fixes as patterns, and roll the remaining journeys out with the patterns already in place.

Stage 5: Make it maintainable

The project isn't done when the strings are translated. It's done when it can't quietly rot — and the default is that it does, because Laravel falls back to your default locale silently when a key is missing.

Three things:

Key parity in CI. Fail the build when a locale is missing keys another has. Highest-value localization test there is; the implementation is in the testing post.

A rule for new code. Every PR adding user-facing text adds the key in all locales, or at minimum in the source locale with the gap tracked. Without this, drift restarts the day you finish.

A path for non-developers. If fixing a Spanish typo requires a developer, a deploy and a Thursday, typos don't get fixed. This is the organisational half, and it's usually what determines whether the app is still well-localized in a year.

Realistic estimates

For a mid-sized app — say 1,500 user-facing strings, 4 target languages:

  • Stage 0–1 (taxonomy, plumbing): 1–2 days
  • Stage 2 (inventory): half a day
  • Stage 3 (extraction): the bulk. Roughly 150–250 strings per developer-day including review, so 6–10 days for 1,500 — less if you defer the admin panel
  • Stage 4 (first language): 2–3 days including the pattern fixes it surfaces
  • Additional languages: 1 day each once patterns exist, plus review time
  • Stage 5 (CI, process): 1 day

Call it three to four weeks of focused work, spread across mergeable increments rather than one branch. The two-week estimate that keeps failing isn't wrong about the extraction — it's wrong about everything around it.

The mistakes that kill these projects

  • One long-lived branch. Merge per journey.
  • Extracting alphabetically or by directory instead of by user value, so the admin panel eats the budget.
  • Deferring the plumbing until after extraction, so nothing is testable in a real locale.
  • Adding four languages at once before finding the systemic bugs on one.
  • Using English strings as keys, so copy edits orphan translations.
  • Ambiguous shared keys that can't be translated correctly in either context.
  • No CI check, so the app drifts back out of sync within a quarter.
  • No non-developer path, so quality decays because fixes are too expensive.

Summary

Sequence it: taxonomy → plumbing → inventory → extract by journey, shipping each → one language end-to-end → maintainability. Merge continuously, order by user value, and defer internal-only surfaces.

The last two stages are where file-based translations fight you: gaps are silent, and every fix is a deploy. LangSyncer imports your lang files once extraction is underway, shows coverage per language so drift is visible, fills gaps with AI for review, and lets copy be corrected in production in seconds — which is what keeps a localized app localized after the project is over. The free tools will tell you where you stand today.

More on Laravel Localization

All Laravel Localization articles →

We'd like to use analytics and marketing cookies to understand how the site is used. They stay off unless you accept them. Cookie Policy