A Laravel site suddenly displays Russian UI to a US user because the middleware misparses Accept-Language. Or hreflang misconfigured, causing Google to flag the English version as duplicate. A client from the UK couldn't place an order — dates showed in American format and currency in dollars instead of pounds. These are typical globalization pains, solvable by proper localization.
We have been configuring English localization for SaaS and e-commerce for years. Our experience spans 15+ projects with complex translation logic. We guarantee that after setup your site will be correctly detected by browsers and Google will properly index multilingual versions. Contact us for a consultation to assess the scope of work for your project.
How to determine user language on the server?
On the server, the language is determined by the Accept-Language header. However, relying solely on it is risky: the user may expect a different language. Best practice is priority: explicit parameter in URL (lang), cookie/session, then Accept-Language.
Middleware on Laravel is the standard approach:
// App\Http\Middleware\SetLocale public function handle(Request $request, Closure $next): mixed { $locale = $request->get('lang') ?? $request->session()->get('locale') ?? $this->parseAcceptLanguage($request->header('Accept-Language')); $locale = in_array($locale, $this->available) ? $locale : 'en'; App::setLocale($locale); return $next($request); } Parsing Accept-Language with quality (q-factor):
private function parseAcceptLanguage(?string $header): string { if (!$header) return 'en'; preg_match_all('/([a-z]{2})(?:-[A-Z]{2})?(?:;q=([0-9.]+))?/', $header, $m); $langs = array_combine($m[1], array_map( fn($q) => $q === '' ? 1.0 : (float) $q, $m[2] )); arsort($langs); foreach (array_keys($langs) as $lang) { if (in_array($lang, $this->available)) return $lang; } return 'en'; } Why hreflang is critical for international SEO?
Without hreflang, search engines may show the wrong version or penalize for duplicates. The English version must be explicitly specified for regions en-US, en-GB, en-AU. Be sure to include x-default — a page for languages not in the list. According to Google documentation, proper hreflang configuration increases visibility by 30-50%. More on the standard can be found on Wikipedia.
<link rel="alternate" hreflang="en" href="https://example.com/en/" /> <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/" /> <link rel="alternate" hreflang="ru" href="https://example.com/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" /> Data formatting: Intl API vs manual conversion
Intl API is the standard for internationalization in JavaScript. It is 10 times better than manual conversion: it handles all regional nuances without additional code. The Intl API is essential for modern localization.
| Locale | Date | Number | Currency |
|---|---|---|---|
| en-US | March 28 | 1,234,567.89 | $99.99 |
| en-GB | 28 March | 1,234,567.89 | £99.99 |
| en-AU | 28 March | 1,234,567.89 | depends on scope |
Example in TypeScript:
const date = new Date('2024-03-28'); new Intl.DateTimeFormat('en-US', { dateStyle: 'long' }).format(date); // "March 28, 2024" new Intl.DateTimeFormat('en-GB', { dateStyle: 'long' }).format(date); // "28 March 2024" For currency, use currency:
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(99.99); // "$99.99" Why pluralization is a localization bottleneck?
English nouns have two numbers: singular and plural. However, many languages (Russian, Arabic) have more rules. Laravel uses trans_choice with indexes, but on the frontend Intl.PluralRules handles it more flexibly. Without proper pluralization, errors like "1 items" instead of "1 item" occur. We always check plural forms for all translations.
How do we choose translation storage?
The choice between files, database, and cloud services depends on the project. Files (PHP, JSON) are fast and simple but hard to scale for large teams. Database is convenient for dynamic translations but adds latency. Cloud solutions (Lokalise, Crowdin) are for enterprise with continuous localization.
| Storage | Speed | Flexibility | Team collaboration |
|---|---|---|---|
| Files | high | low | manual sync |
| Database | medium | high | via admin panel |
| Cloud services | medium | high | automatic sync |
What is included in the work
- Audit of current localization: identifying errors in middleware, hreflang, formats.
- Middleware configuration for language detection with correct priority.
- Hreflang configuration for main regions and x-default.
- Adaptation of date, number, and currency formats via Intl API.
- Writing tests to verify localization on different browsers.
- Documentation on translation structure and process for adding new languages.
- Training the team on using the translation system.
Work process
- Analytics — audit current code, identify localization issues.
- Design — choose translation storage (files, database, or cloud).
- Implementation — write middleware, integrate translations, hreflang.
- Testing — verify on different browsers, devices, regions.
- Deploy — release to production, monitor errors.
Timelines and cost
Timeline — from 1 to 3 business days for a typical site. For complex projects with custom translations or integrations, up to 5 days. Cost calculated individually — contact us for an estimate.
Typical localization mistakes
- Incorrect order of locale sources (Accept-Language not last).
- Missing x-default in hreflang.
- Using manual date formatting instead of Intl API.
- Forgetting plural forms in translations.
Avoiding these will give you stable localization that properly serves English-speaking users and improves international search rankings.
Order English localization setup and get a turnkey solution with quality guarantee. Contact us for a consultation.







