andywer/js-localization
Bring Laravel's translations to JavaScript. An artisan command exports your PHP lang files, and a lightweight client-side translator looks up keys and replaces placeholders at runtime, so backend and frontend share the same strings with no duplication. Works with any frontend stack.
lang/ files) rendered into a JS file, so front-end copy stops being hardcoded. That is enough to justify shipping a first locale set without buying a translation-management platform — and enough to know whether the demand is real before spending on one.Lang.get() helper — is an Artisan command, a config file, and ~100 lines of glue. This package is a reference implementation of that pattern, which lets you price the "build" option honestly: days, not quarters. The strategic conclusion is usually "adopt the pattern, vendor the code," not "add the dependency."lang/ files as the single source of truth and the front end as a consumer. That is an architectural decision with product consequences: how copy changes ship (deploy vs. CMS vs. TMS), who can edit strings (engineers vs. translators vs. marketing), and whether a typo fix requires a release.lang/de directory" rather than a front-end refactor. That lowers the marginal cost of each new market and turns expansion from a project into a roadmap line item. It also gives you a credible date to give sales or partnerships about a new-language launch.Consider it when:
lang/ files are already the trusted source of copy.Look elsewhere when:
composer.json and last commit date before any estimate is trusted.laravel-vue-i18n, i18next fed by an exported JSON artifact, or your TMS's CDN delivery.Migration note: isolate the export behind your own Blade directive or small service so swapping in an in-house Artisan command later is a one-file change, not a hunt.
To executives: Today the same copy exists twice — once in PHP, once hardcoded in JavaScript — and the two drift. Every new market or copy change costs double work and produces user-visible bugs where the server says one thing and the page says another. This package closes the gap by making the PHP translation files the single source of truth and handing the same strings to the browser. The payoff is strategic: launching a new locale becomes a content exercise instead of an engineering project, directly lowering the cost and risk of each market we enter — and giving us a repeatable, dateable expansion motion.
The honest caveat: the package is small, old, single-maintainer, and effectively unmaintained. That is acceptable because what we actually want is the pattern, not the code. Recommendation: adopt the approach, vendor roughly a hundred lines in-house behind a single interface, and generate the file at deploy time rather than on request. We get the localization win at near-zero cost and near-zero long-term dependency risk. If we later move to a TMS or a full SPA stack, we replace one file.
To engineering: This is glue, not architecture — it reads lang/ and emits a JS object with a Lang.get() / Lang.choice() helper. Before we commit, confirm our Laravel and PHP versions resolve against it, and assume a fork. Two things matter beyond compatibility: treat the output as a build artifact written at deploy time, not a runtime write to public/, and audit both escaping (translation values interpolated into a JS file are an XSS surface) and scope (do not export admin, email, or internal error groups to a public payload). Keep Lang.choice parity with Laravel's pluralization rules tested rather than assumed — it is reimplemented in JS and will drift. Own the boundary so a future move to JSON artifacts or a TMS pipeline is a contained change.
How can I help you explore Laravel packages today?