{"id":18486,"library":"laravel-vue-i18n","title":"Laravel Vue i18n","description":"Laravel Vue i18n version 2.8.0 is a Vue 3 plugin that connects Laravel localization files (JSON and PHP) with Vue applications, including Inertia.js support. It mirrors Laravel's translation functions (__(), trans_choice(), Lang.get(), etc.) in Vue components and templates. Release cadence is active: multiple fixes and features released monthly. Key differentiators: native Laravel localization syntax, Vite plugin to auto-convert PHP translations, SSR support, and reactive current locale. Ships TypeScript types.","status":"active","version":"2.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/xico2k/laravel-vue-i18n","tags":["javascript","laravel","vue","vue3","inertiajs","typescript"],"install":[{"cmd":"npm install laravel-vue-i18n","lang":"bash","label":"npm"},{"cmd":"yarn add laravel-vue-i18n","lang":"bash","label":"yarn"},{"cmd":"pnpm add laravel-vue-i18n","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency — Vue 3 required","package":"vue","optional":false}],"imports":[{"note":"Named export in ESM. CommonJS users: const { i18nVue } = require('laravel-vue-i18n').","wrong":"import i18nVue from 'laravel-vue-i18n'","symbol":"i18nVue","correct":"import { i18nVue } from 'laravel-vue-i18n'"},{"note":"Named export. Available globally after plugin install, but can also be imported explicitly for composition API usage.","wrong":"const __ = require('laravel-vue-i18n').__","symbol":"__","correct":"import { __ } from 'laravel-vue-i18n'"},{"note":"Named export. Alias for __. Also available as trans (deprecated).","symbol":"tran","correct":"import { tran } from 'laravel-vue-i18n'"},{"note":"Vite plugin is a separate subpath import, not the default export.","wrong":"import i18n from 'laravel-vue-i18n'","symbol":"i18nPlugin (Vite)","correct":"import i18n from 'laravel-vue-i18n/vite'"}],"quickstart":{"code":"// Install: npm install laravel-vue-i18n\n\n// main.js\nimport { createApp } from 'vue'\nimport { i18nVue } from 'laravel-vue-i18n'\n\nconst app = createApp({\n  template: '<h1>{{ __(\"Welcome\") }}</h1>'\n})\n\napp.use(i18nVue, {\n  lang: 'en',\n  resolve: async (lang) => {\n    const langs = import.meta.glob('../lang/*.json')\n    return await langs[`../lang/${lang}.json`]()\n  }\n})\n\napp.mount('#app')\n\n// resources/lang/en.json: { \"Welcome\": \"Welcome\" }","lang":"typescript","description":"Sets up the plugin with Vite glob import for JSON translations and uses __() helper in component."},"warnings":[{"fix":"Ensure your project uses `vue` types directly. If you encounter type errors, remove any custom augmentations of `@vue/runtime-core` and use `vue` instead.","message":"In v2.8.0, the way Vue augmentation was changed — now it augments `vue` instead of `@vue/runtime-core`. If you rely on custom type augmentation, you might need to update your tsconfig or type declarations.","severity":"breaking","affected_versions":">=2.8.0"},{"fix":"Add `lang/php_*.json` to your `.gitignore` file.","message":"The Vite plugin `laravel-vue-i18n/vite` generates `php_*.json` files in your `lang` folder during dev. These can be accidentally committed to version control if not ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the Vite plugin `i18n()` in your `vite.config.js`, or manually convert your PHP translation files to JSON.","message":"If you use PHP translations (array-based) without the Vite plugin, they must be converted to JSON. The plugin does this automatically. Without it, PHP translations will not be available.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace `trans()` with `tran()` or `__()` in your codebase.","message":"The `trans` function is deprecated in favor of `tran`.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use `import.meta.glob('...', { eager: true })` and return `langs[path].default` synchronously.","message":"When using SSR, the `resolve` method must not return a Promise. You must provide an eager-loaded object.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you call `app.use(i18nVue, ...)` after creating the Vue app, and import `__` from 'laravel-vue-i18n' if using composition API without plugin global.","cause":"The plugin may not have been installed correctly, or the import path is wrong.","error":"TypeError: __ is not a function"},{"fix":"Check that your JSON translation files include the key. For PHP translations, ensure the Vite plugin is configured and you have run `npm run dev` to generate the php_*.json files.","cause":"The translation file for the current language might not contain that key, or the file was not loaded.","error":"Missed translation key: 'some.key'"},{"fix":"Run `npm install laravel-vue-i18n` to ensure it's installed. Import using correct path: `import i18n from 'laravel-vue-i18n/vite'` (not from the main package).","cause":"The Vite plugin is imported from a subpath that may not be resolved correctly if the package is not installed or if the import is malformed.","error":"Cannot find module 'laravel-vue-i18n/vite'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}