Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Localizer

Laravel Localizer Laravel Package

devwizardhq/laravel-localizer

View on GitHub
Deep Wiki
Context7

Laravel Localizer bridges Laravel translations to your SPA frontend (React/Vue/Inertia) and provides generated language assets, type-safe usage, and global translation helpers.

Frequently asked questions about Laravel Localizer
How does Laravel Localizer integrate with existing Laravel translation files (e.g., lang/en.json)?
The package scans your existing `resources/lang` directory and automatically includes all translation files. It supports both JSON and PHP formats, so no migration is needed. The `localizer:sync` command updates generated TypeScript files to reflect changes in your Laravel translation files.
Can I use Laravel Localizer without Inertia.js or React/Vue? Will it work with vanilla JavaScript?
Yes, the core translation scanning and TypeScript generation work independently of frontend frameworks. The generated TypeScript files can be consumed by any JavaScript frontend, including vanilla JS or Svelte. Inertia.js integration is optional but provides seamless SPA localization.
What Laravel versions are supported, and is there backward compatibility?
Laravel Localizer is designed for Laravel 10 and 11. It leverages Laravel’s built-in translation system, so it won’t break existing `trans()` or `__()` usage. For older versions, check the package’s release notes or consider a forked version if needed.
How does locale detection work, and can I customize it (e.g., URL param, cookie, or user preference)?
Locale detection follows Laravel’s middleware priority (e.g., `Accept-Language` header, session, or route parameters). You can customize this in `config/localizer.php` or extend the middleware to support additional logic like user preferences or cookies.
Will auto-translation via Google Translate overwrite my manual translations?
No, auto-translation only fills missing keys. Existing translations in your `lang/` directory remain untouched. You can disable auto-translation entirely in the config or use a paid Google Translate API key to avoid rate limits.
How do I handle missing translations in production? Does it fall back to the default locale?
Missing translations fall back to the default locale (configurable in `config/localizer.php`). You can also customize this behavior in the middleware or use a placeholder UI (e.g., `{{ __('key') }}` displays the key if translation is missing).
What’s the impact of TypeScript generation on CI/CD build times for large projects?
TypeScript generation is optimized for performance with caching. For large projects, regenerate only changed locales or cache the output. The package also supports incremental builds, so full regeneration isn’t required on every deploy.
Can I use Laravel Localizer with third-party translation packages (e.g., spatie/laravel-translatable)?
Yes, the package auto-discovers translations from vendor packages in `lang/` directories. However, if a third-party package uses custom translation logic (e.g., database-backed), you may need to manually sync those keys or extend the scanner.
How do I dynamically switch locales in the SPA (e.g., user-selected language) without page reloads?
Use the generated TypeScript types to load translations dynamically. Inertia.js supports locale switching via page props or middleware. For vanilla JS, update the `localizer` object in your frontend state and reload translations via the API or a shared store.
Are the generated TypeScript files version-controlled, or should they be regenerated per environment?
Generated TypeScript files are typically version-controlled alongside your Laravel codebase. Regenerate them only when translation files change. For environment-specific overrides (e.g., staging vs. production), use separate `lang/` directories or merge strategies.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky