Registry / web-framework / laravel-vue-i18n

laravel-vue-i18n

JSON →
library2.8.0jsnpmunverified

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.

npm install laravel-vue-i18n
INSTALL
IMPORT
SIG · LARAVEL-VUE-I18N
L
laravel-vue-i18n
web-frameworkjavascriptv2.8.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

i18nVue
import { i18nVue } from 'laravel-vue-i18n'
import i18nVue from 'laravel-vue-i18n'
Named export in ESM. CommonJS users: const { i18nVue } = require('laravel-vue-i18n').
__
import { __ } from 'laravel-vue-i18n'
const __ = require('laravel-vue-i18n').__
Named export. Available globally after plugin install, but can also be imported explicitly for composition API usage.
tran
import { tran } from 'laravel-vue-i18n'
Named export. Alias for __. Also available as trans (deprecated).
i18nPlugin (Vite)
import i18n from 'laravel-vue-i18n/vite'
import i18n from 'laravel-vue-i18n'
Vite plugin is a separate subpath import, not the default export.

Sets up the plugin with Vite glob import for JSON translations and uses __() helper in component.

// Install: npm install laravel-vue-i18n // main.js import { createApp } from 'vue' import { i18nVue } from 'laravel-vue-i18n' const app = createApp({ template: '<h1>{{ __("Welcome") }}</h1>' }) app.use(i18nVue, { lang: 'en', resolve: async (lang) => { const langs = import.meta.glob('../lang/*.json') return await langs[`../lang/${lang}.json`]() } }) app.mount('#app') // resources/lang/en.json: { "Welcome": "Welcome" }
Debug
Known issues
breakingIn 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.
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.
affects: >=2.8.0
gotchaThe 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.
fix
Add `lang/php_*.json` to your `.gitignore` file.
affects: >=1.0.0
gotchaIf 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.
fix
Use the Vite plugin `i18n()` in your `vite.config.js`, or manually convert your PHP translation files to JSON.
affects: >=1.0.0
deprecatedThe `trans` function is deprecated in favor of `tran`.
fix
Replace `trans()` with `tran()` or `__()` in your codebase.
affects: >=2.0.0
gotchaWhen using SSR, the `resolve` method must not return a Promise. You must provide an eager-loaded object.
fix
Use `import.meta.glob('...', { eager: true })` and return `langs[path].default` synchronously.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: __ is not a function
The plugin may not have been installed correctly, or the import path is wrong.
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.
Missed translation key: 'some.key'
The translation file for the current language might not contain that key, or the file was not loaded.
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.
Cannot find module 'laravel-vue-i18n/vite'
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.
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).
Upgrade
Version history
2.8.0latest on npm
Audit
Dependencies
vuerequiredPeer dependency — Vue 3 required
Agent activity
6 hits · last 30 days
node
6
Resources
laravel-vue-i18n — npm install laravel-vue-i18n · libregistry