stefro/laravel-lang-country
A Laravel package providing ready-to-use language and country lists, ISO codes, localized names, and validation rules for country and language codes. It simplifies building multilingual, country-aware forms and APIs with consistent reference data and less boilerplate.
What it actually is. A thin, config-driven lookup layer over Laravel's native locale system. It maps country → language(s) and country → date notation, then sets/reads app()->getLocale(). It is not an i18n framework: no string translation, no pluralization, no currency/number formatting, no time zones. Scope it as a resolution helper, not a localization platform.
Architecture fit. Fits cleanly into the request lifecycle: middleware resolves a country (session, user profile, or geo-IP), derives the language, and sets the locale before controllers run; a facade/helper exposes the country-specific date pattern to views and formatters. It composes with a translation source (JSON lang files, spatie/laravel-translatable) provided only one component owns locale-setting — conflicts with mcamara/laravel-localization are a configuration-discipline issue, not a hard incompatibility.
Integration feasibility. Composer-installable, MIT, no runtime services, data shipped as static PHP arrays. Wiring is roughly a day for a competent Laravel developer. The real effort is product decisions (supported locale set, fallback order) and translation coverage — neither of which the package solves.
Technical risk. Predominantly data risk, not code risk:
en-GB vs en-US, pt-BR vs pt-PT, zh-Hans/zh-Hant, es-419, Arabic variants, and genuinely multi-official countries (BE, CA, CH, IN, ZA, SG) don't reduce to one country = one language. User preference should outrank geography.intl/CLDR anyway and this package is a partial stopgap.Key questions to resolve before committing:
zh-Hans, sr-Latn) or only ISO-3166 ↔ ISO-639-1?config:cache (no closures)?Stack fit. Server-side only. For Blade/Livewire, call the helper at the display edge when rendering dates. For Inertia, SPAs, and APIs, ship locale plus a formatting hint in a shared prop/bootstrap payload and format client-side with Intl.DateTimeFormat — do not re-implement PHP date tokens in JavaScript. If you must expose the raw pattern, write and unit-test a PHP→ICU/date-fns token converter; m/d/Y versus d/m/Y is a data-integrity concern, not cosmetics.
Migration path. Additive and flag-gated:
LocaleResolver and DateFormatService interfaces so the vendor dependency is replaceable in one file.Compatibility. Verify the composer constraint against our Laravel version; confirm the config publishes under a non-colliding key; ensure it contains no closures (breaks config:cache). For multi-tenant apps, locale is per-request global state — resolve inside the request, never in a service-provider boot or singleton, or tenants will leak locales into each other under Octane. Reset locale explicitly in queued jobs.
Sequencing. Dependency + config (day 1) → wrapper + tests (days 2–3) → country signal with caching (week 1) → flagged middleware rollout (week 2) → client-side formatting parity (weeks 2–3). Translation coverage runs in parallel and is almost always the long pole.
Maintenance. Low code maintenance, ongoing data maintenance. Pin the version, review on every Laravel upgrade and quarterly for mapping/data drift, and keep config plus overrides in version control. Given the bus factor, budget a fork/vendor path. Licensing cost is zero; ongoing engineering cost is small but non-zero.
Support. Community-only: GitHub issues, no SLA, no vendor escalation. Name an internal owner, document the resolution chain and date-format contract in the team wiki, and expect recurring support questions about why a date renders as dd/mm.
Scaling. Runtime cost is negligible — in-memory array lookups. The only scaling concern is country detection: geo-IP lookups add latency and rate limits, so cache per IP, persist the resolved country on the user record, and refresh conservatively. Otherwise stateless, provided locale is reset per request and per job under Octane and queue workers.
Failure modes and mitigations.
Ramp-up. A Laravel developer integrates in under a day; the wrapper and tests add two to three days. The organizational ramp is the real cost: product and design decisions on the supported locale matrix, fallback rules, and date-input UX, plus a QA matrix that grows with every locale added. Recommend launching with a small, high-value locale set rather than enabling the full country list on day one.
How can I help you explore Laravel packages today?