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>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.
composer require javaabu/js-localization
php artisan manifest:check # installs @javaabu/i18n from npmBlade 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 |
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 serverPlease see CHANGELOG for what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email info@javaabu.com instead of using the issue tracker.
MIT. See LICENSE.md.