javaabu / js-localization
Use your Laravel translations in JavaScript: export them for @javaabu/i18n, load them on Blade pages with no setup, keep them in sync with Vite, find missing lines and fill them with AI.
Requires
- php: ^8.4
- javaabu/manifest: ^1.0@dev
- laravel/framework: ^12.0 || ^13.0
Requires (Dev)
- javaabu/boost-javaabu-guidelines: ^1.4
- laravel/ai: ^1.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.5.3 || ^12.5.8
Suggests
- laravel/ai: Fill in missing translations with AI: php artisan lang:translate (^1.0)
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-15 10:50:34 UTC
README
Your Laravel translations in JavaScript, with @javaabu/i18n's __(), trans() and trans_choice(): the same keys, arguments and output as in PHP. The successor of Laravel-JS-Localization.
- Blade pages need no setup: the helpers are on
window, with the page's locale loaded from a cached endpoint, through javaabu/manifest. - Inertia and SPA bundles load lines from a Vite plugin, one lazy chunk per locale, updated live as you edit
lang/. php artisan lang:missinglists keys your PHP, Blade, JS and TSX use that a locale lacks.php artisan lang:translate --to=dvfills them in with AI through laravel/ai, keeping placeholders and plurals intact.
<script> document.addEventListener('DOMContentLoaded', async () => { await I18n.ready(); alert(__('Welcome, :name!', { name: 'އަލީ' })); }); </script>
const { __, trans_choice } = useTranslation() return <p>{trans_choice("messages.apples", count)}</p>
Documentation
You'll find the documentation on https://docs.javaabu.com/js-localization, and in the docs folder.
AI coding assistants can start from llms.txt. The package ships a Laravel Boost skill and guideline, which Boost finds by itself. See AI assistants.
Quick start
composer require javaabu/js-localization
php artisan manifest:check # installs @javaabu/i18n from npm
Blade pages work now. For Inertia, React or Vue:
// vite.config.js: manifest() also runs this package's Vite plugin import manifest from "./vendor/javaabu/manifest/dist/vite.js" export default defineConfig({ plugins: [laravel({ input: ["resources/js/app.tsx"] }), manifest(), react()], })
// resources/js/app.tsx import { configure } from "@javaabu/i18n" import { loader } from "@javaabu/js-localization/translations" configure({ loader })
| Using | Read |
|---|---|
| Blade | Blade pages |
| Inertia, React, Vue | Inertia and bundled apps, Vite plugin |
| Laravel-JS-Localization today | Migrating |
Testing
composer install && pnpm install # @javaabu/i18n is linked from ../i18n until it's on npm composer test # PHPUnit composer lint # Pint pnpm lint && pnpm format:check && pnpm typecheck pnpm build # dist/, committed pnpm test:coverage # Vitest: the Blade script, the Vite plugin, real Vite builds and a dev server
Changelog
Please see CHANGELOG for what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@javaabu.com instead of using the issue tracker.
License
MIT. See LICENSE.md.