Vite plugin that retrieves Laravel PHP translation files and makes them available as a global JSON variable (`import.meta.env.VITE_LARAVEL_TRANSLATIONS`) for use with i18n frameworks like vue-i18n or react-i18next. Version 0.3.1 supports Vite 3–6 and Node >=12. It uses Vite-specific hooks (`config`, `handleHotUpdate`) and cannot be used as a Rollup plugin. Key differentiators: automatic PHP-to-JSON conversion, HMR support for translation files, and optional namespacing for React compatibility. Alternative to manual JSON generation or PHP-based solutions like `laravel-vue-i18n`.
npm install vite-plugin-laravel-translationsVerified import paths — ran on the pinned version, not inferred.
Shows basic Vite plugin setup and Vue 3 i18n integration using the injected env variable.
Use only with Vite. Do not attempt to use with Rollup or other bundlers.
Always use import.meta.env in your application code.
Use `const laravelTranslations = (await import('vite-plugin-laravel-translations')).default`Set `includeJson: false` explicitly until future clarification.
Verify translations are in `resources/lang/{locale}/` or adjust as needed; custom paths not documented.Install a compatible vite version (e.g., npm i vite@^5.1.3).
Use ES import syntax: `import laravelTranslations from 'vite-plugin-laravel-translations'`
Ensure the plugin is added to the Vite config and access `import.meta.env.VITE_LARAVEL_TRANSLATIONS` inside your app (not in vite.config.js).
Run `npm i vite-plugin-laravel-translations` and ensure vite peer dependency is satisfied.
Use default import: `import laravelTranslations from 'vite-plugin-laravel-translations'`