Search by

javaabu / js-localization

dash8xjavaabun4ff4h

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.

Package info

github.com/Javaabu/js-localization

pkg:composer/javaabu/js-localization

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

dev-main / 1.x-dev 2026-11-10 09:59 UTC

This package is auto-updated.

Last update: 2026-11-15 10:50:34 UTC


README

Tests codecov Latest Version on Packagist License: MIT

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:missing lists keys your PHP, Blade, JS and TSX use that a locale lacks. php artisan lang:translate --to=dv fills 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.