PHPackages                             spacemudd/laravel-vue-i18n-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. spacemudd/laravel-vue-i18n-generator

ActiveLibrary[Localization &amp; i18n](/categories/localization)

spacemudd/laravel-vue-i18n-generator
====================================

Generates a vue-i18n compatible include file from your Laravel translations.

0.1.47(5y ago)020.6k↑141.9%MITPHPPHP &gt;=5.5.0

Since Nov 9Pushed 2y agoCompare

[ Source](https://github.com/spacemudd/laravel-vue-i18n-generator)[ Packagist](https://packagist.org/packages/spacemudd/laravel-vue-i18n-generator)[ Docs](http://github.com/spacemudd/laravel-vue-i18n-generator)[ RSS](/packages/spacemudd-laravel-vue-i18n-generator/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (51)Used By (0)

Get started
===========

[](#get-started)

`composer require spacemudd/laravel-vue-i18n-generator --dev`

`php artisan vendor:publish --provider="MartinLindhe\VueInternationalizationGenerator\GeneratorProvider"`

About
-----

[](#about)

Laravel 8 package that allows you to share your [Laravel localizations](https://laravel.com/docs/8.x/localization)with your [vue](http://vuejs.org/) front-end, using [vue-i18n](https://github.com/kazupon/vue-i18n) or [vuex-i18n](https://github.com/dkfbasel/vuex-i18n).

Forked from [martinlindhe/laravel-vue-i18n-generator](https://github.com/martinlindhe/laravel-vue-i18n-generator)

Laravel 5.7 notice!
-------------------

[](#laravel-57-notice)

Configuration paths have changed in Laravel 5.7, in order for this package to function properly you need to configure correct paths for jsPath and jsFile in your `config\vue-i18n-generator.php`.

Install the package
-------------------

[](#install-the-package)

In your project: `composer require martinlindhe/laravel-vue-i18n-generator --dev`

### For Laravel 5.4 and below:

[](#for-laravel-54-and-below)

For older versions of the framework:

Register the service provider in `config/app.php`

```
MartinLindhe\VueInternationalizationGenerator\GeneratorProvider::class,
```

Next, publish the package default config:

```
php artisan vendor:publish --provider="MartinLindhe\VueInternationalizationGenerator\GeneratorProvider"

```

Using vue-i18n
--------------

[](#using-vue-i18n)

Next, you need to install one out of two supported VueJs i18n libraries. We support [vue-i18n](https://github.com/kazupon/vue-i18n) as default library. Beside that we also support [vuex-i18n](https://github.com/dkfbasel/vuex-i18n).

When you go with the default option, you only need to install the library through your favorite package manager.

### vue-i18n

[](#vue-i18n)

```
npm i --save vue-i18n

```

```
yarn add vue-i18n

```

Then generate the include file with

```
php artisan vue-i18n:generate

```

Assuming you are using a recent version of vue-i18n (&gt;=6.x), adjust your vue app with something like:

```
import Vue from 'vue';
import VueInternationalization from 'vue-i18n';
import Locale from './vue-i18n-locales.generated';

Vue.use(VueInternationalization);

const lang = document.documentElement.lang.substr(0, 2);
// or however you determine your current app locale

const i18n = new VueInternationalization({
    locale: lang,
    messages: Locale
});

const app = new Vue({
    el: '#app',
    i18n,
    components: {
       ...
    }
}
```

For older vue-i18n (5.x), the initialization looks something like:

```
import Vue from 'vue';
import VueInternationalization from 'vue-i18n';
import Locales from './vue-i18n-locales.generated.js';

Vue.use(VueInternationalization);

Vue.config.lang = 'en';

Object.keys(Locales).forEach(function (lang) {
  Vue.locale(lang, Locales[lang])
});

...
```

Using vuex-i18n
---------------

[](#using-vuex-i18n)

### vuex-i18n

[](#vuex-i18n)

```
npm i --save vuex-i18n

```

```
yarn add vuex-i18n vuex

```

Next, open `config/vue-i18n-generator.php` and do the following changes:

```
- 'i18nLib' => 'vue-i18n',
+ 'i18nLib' => 'vuex-i18n',
```

Then generate the include file with

```
php artisan vue-i18n:generate

```

Assuming you are using a recent version of vuex-i18n, adjust your vue app with something like:

```
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);

// set the start locale to use
Vue.i18n.set(Spark.locale);

require('./components/bootstrap');

var app = new Vue({
    store,
    mixins: [require('spark')]
});
```

Output Formats
--------------

[](#output-formats)

You can specify the output formats from `es6`, `umd`, or `json` with the `--format` option. (defaults to `es6`)

```
php artisan vue-i18n:generate --format {es6,umd,json}

```

### Use case example for UMD module

[](#use-case-example-for-umd-module)

```
php artisan vue-i18n:generate --format umd

```

An UMD module can be imported into the browser, build system, node and etc.

Now you can include the generated script in the browser as a normal script and reference it with window.vuei18nLocales.

```

// in your js
Vue.use(VueI18n)
Vue.config.lang = Laravel.language
Object.keys(window.vuei18nLocales).forEach(function (lang) {
  Vue.locale(lang, window.vuei18nLocales[lang])
})
```

You can still require/import it in your build system as stated above.

One advantage of doing things like this is you are not obligated to do a build of your javascript each time a the translation files get changed/saved. A good example is if you have a backend that can read and write to your translation files (like Backpack). You can listen to a save event there and call vue-i18n-generator.

Generating Multiple Files
-------------------------

[](#generating-multiple-files)

Sometimes you may want to generate multiple files as you want to make use of lazy loading. As such, you can specify that the generator produces multiple files within the destination directory.

There are two options:

1. One file per laravel module language file using switch `--multi`
2. One file per locale using switch `--multi-locales`

```
php artisan vue-i18n:generate --multi{-locales}

```

Parameters
----------

[](#parameters)

The generator adjusts the strings in order to work with vue-i18n's named formatting, so you can reuse your Laravel translations with parameters.

resource/lang/message.php:

```
return [
    'hello' => 'Hello :name',
];
```

in vue-i18n-locales.generated.js:

```
...
    "hello": "Hello {name}",
...
```

Blade template:

```

    {{ trans('message.hello', ['name' => 'visitor']) }}

```

Vue template:

```

    {{ $t('message.hello', {name: 'visitor'}) }}

```

Notices
-------

[](#notices)

- The generated file is an ES6 module.

The more sophisticated pluralization localization as described [here](https://laravel.com/docs/5.5/localization#pluralization) is not supported since neither vue-i18n or vuex-i18n support this.

License
=======

[](#license)

Under [MIT](LICENSE)

###  Health Score

33

—

LowBetter than 76% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~53 days

Total

48

Last Release

2021d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

0.1.1PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/09004ee6840ecc95c73b74511971759a31049b972cd8a12347a22caf86e4db2b?d=identicon)[spacemudd](/maintainers/spacemudd)

---

Top Contributors

[![martinlindhe](https://avatars.githubusercontent.com/u/181531?v=4)](https://github.com/martinlindhe "martinlindhe (52 commits)")[![voydz](https://avatars.githubusercontent.com/u/373533?v=4)](https://github.com/voydz "voydz (4 commits)")[![murrant](https://avatars.githubusercontent.com/u/39462?v=4)](https://github.com/murrant "murrant (2 commits)")[![madeITBelgium](https://avatars.githubusercontent.com/u/20304892?v=4)](https://github.com/madeITBelgium "madeITBelgium (2 commits)")[![netpok](https://avatars.githubusercontent.com/u/6945600?v=4)](https://github.com/netpok "netpok (2 commits)")[![marcoocram](https://avatars.githubusercontent.com/u/6926933?v=4)](https://github.com/marcoocram "marcoocram (2 commits)")[![gerpo](https://avatars.githubusercontent.com/u/11218560?v=4)](https://github.com/gerpo "gerpo (1 commits)")[![jcharcosset](https://avatars.githubusercontent.com/u/36884315?v=4)](https://github.com/jcharcosset "jcharcosset (1 commits)")[![Jellyfrog](https://avatars.githubusercontent.com/u/759887?v=4)](https://github.com/Jellyfrog "Jellyfrog (1 commits)")[![kenfdev](https://avatars.githubusercontent.com/u/3941889?v=4)](https://github.com/kenfdev "kenfdev (1 commits)")[![Konafets](https://avatars.githubusercontent.com/u/363363?v=4)](https://github.com/Konafets "Konafets (1 commits)")[![krns](https://avatars.githubusercontent.com/u/7387295?v=4)](https://github.com/krns "krns (1 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (1 commits)")[![ottoszika](https://avatars.githubusercontent.com/u/7945963?v=4)](https://github.com/ottoszika "ottoszika (1 commits)")[![periloso](https://avatars.githubusercontent.com/u/5249810?v=4)](https://github.com/periloso "periloso (1 commits)")[![rabrowne85](https://avatars.githubusercontent.com/u/8293543?v=4)](https://github.com/rabrowne85 "rabrowne85 (1 commits)")[![Raymonf](https://avatars.githubusercontent.com/u/8991740?v=4)](https://github.com/Raymonf "Raymonf (1 commits)")[![RSchwan](https://avatars.githubusercontent.com/u/9384498?v=4)](https://github.com/RSchwan "RSchwan (1 commits)")[![sandofvega](https://avatars.githubusercontent.com/u/34006175?v=4)](https://github.com/sandofvega "sandofvega (1 commits)")[![shareef1989](https://avatars.githubusercontent.com/u/4285706?v=4)](https://github.com/shareef1989 "shareef1989 (1 commits)")

---

Tags

laravelvue-i18n

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spacemudd-laravel-vue-i18n-generator/health.svg)

```
[![Health](https://phpackages.com/badges/spacemudd-laravel-vue-i18n-generator/health.svg)](https://phpackages.com/packages/spacemudd-laravel-vue-i18n-generator)
```

###  Alternatives

[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

299.6k](/packages/erag-laravel-lang-sync-inertia)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5614.3k1](/packages/longman-laravel-multilang)[kerigard/laravel-lang-ru

Ru lang for Laravel

1815.9k](/packages/kerigard-laravel-lang-ru)[laradevs/spanish

labels translated to spanish

166.2k](/packages/laradevs-spanish)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
