saniolab / laravel-vue-i18n-generator
Generates a vue-i18n compatible include file from your Laravel translations.
Package info
github.com/saniolab/laravel-vue-i18n-generator
pkg:composer/saniolab/laravel-vue-i18n-generator
Requires
- php: ^8.3
- ext-json: *
- ext-mbstring: *
- illuminate/console: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.5.50|^12.5.8|^13.0.0
- dev-main
- 1.0.0
- 0.1.48
- 0.1.47
- 0.1.46
- 0.1.45
- 0.1.44
- 0.1.43
- 0.1.42
- 0.1.41
- 0.1.40
- 0.1.39
- 0.1.38
- 0.1.37
- 0.1.36
- 0.1.35
- 0.1.34
- 0.1.33
- 0.1.32
- 0.1.31
- 0.1.30
- 0.1.29
- 0.1.28
- 0.1.27
- 0.1.26
- 0.1.25
- 0.1.24
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-dependabot/github_actions/actions/checkout-6
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-7
This package is auto-updated.
Last update: 2026-03-23 16:10:53 UTC
README
Generates a vue-i18n compatible bundle from your Laravel translations, for use with a Vue front end. Optional vuex-i18n output is supported via config.
This package is a maintained fork of https://github.com/martinlindhe/laravel-vue-i18n-generator.
Requirements
- PHP 8.2 or higher (use a version that matches your Laravel release)
- Laravel 12 or 13
Install
composer require saniolab/laravel-vue-i18n-generator --dev
The service provider is registered automatically via composer.json extra.laravel.providers.
Publish the config when you need to customize paths or the target i18n library:
php artisan vendor:publish --provider="Saniolab\VueInternationalizationGenerator\GeneratorProvider"
Adjust jsPath, jsFile, and other options in config/vue-i18n-generator.php as needed.
Using vue-i18n
Install the Vue library, then generate the locale file:
npm i vue-i18n
php artisan vue-i18n:generate
The default es6 output is a module with a default export (a locale → messages map). Example with Vue 3 and vue-i18n 9+:
import { createApp } from 'vue'; import { createI18n } from 'vue-i18n'; import messages from './vue-i18n-locales.generated'; const i18n = createI18n({ legacy: false, locale: document.documentElement.lang.slice(0, 2), messages, }); createApp(App).use(i18n).mount('#app');
Using vuex-i18n
npm i vuex-i18n vuex
In config/vue-i18n-generator.php, set 'i18nLib' => 'vuex-i18n', then run php artisan vue-i18n:generate.
import Vue from 'vue'; import Vuex from 'vuex'; import vuexI18n from 'vuex-i18n'; import Locales from './vue-i18n-locales.generated.js'; const store = new Vuex.Store(); Vue.use(vuexI18n.plugin, store); Vue.i18n.add('en', Locales.en); Vue.i18n.add('de', Locales.de); Vue.i18n.set(startLocale);
Output formats
Use --format with es6 (default), umd, or json:
php artisan vue-i18n:generate --format umd
With umd, the bundle exposes window.vuei18nLocales for use without a bundler.
Multiple files (lazy loading)
php artisan vue-i18n:generate --multi php artisan vue-i18n:generate --multi-locales
Parameters (named placeholders)
Laravel :name placeholders are converted to vue-i18n {name} style.
lang/en/message.php:
return [ 'hello' => 'Hello :name', ];
Vue:
<p>{{ $t('message.hello', { name: 'visitor' }) }}</p>
Notices
- Default output is an ES6 module (
export default …). - Advanced Laravel pluralization as in the docs is not fully mirrored in vue-i18n / vuex-i18n in all cases.