Skip to content

About

Next-gen version of Javaabu/Laravel-JS-Localization

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Localization

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.

About

Next-gen version of Javaabu/Laravel-JS-Localization

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages