Generate vuejs files directly via command in laravel 5.1

So , i guess you are familiar with vuejs  , or if  not then in simple words vuejs is …

Simple

Write some HTML, grab some JSON, create a Vue instance, that’s it.

Reactive

Expressions & computed properties with transparent dependency tracking.

Components

Compose your application with decoupled, reusable components.

Compact

~23kb min+gzip, no dependency.

Fast

Precise and efficient async batch DOM updates.

Package Ready

Install via NPM or Bower – leverage your favorite eco system!

 

Find more at vuejs.org

 

So , here we are talking about laravel-vue-i18n-generator ,it Generates a vue-i18n compatible include file from your Laravel translations. in simple words this package that allows you to share your Laravel localizations with your vue front-end, using vue-i18n.

ok lets , install this via composer

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

In config/app.php providers:

MartinLindhe\VueInternationalizationGenerator\GeneratorProvider::class,

Then generate the include file with php artisan vue-i18n:generate

 

Here is the basic usage of this package

djust your vue app with something like:

import Vue from 'vue';
import VueInternationalization from 'vue-i18n';

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

Vue.use(VueInternationalization, {
    lang: 'en',
    locales: Locales
});

...

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:

<div class="message">
    <p>{{ trans('message.hello', ['name' => 'visitor']) }}</p>
</div>

Vue template:

<div class="message">
    <p>{{ $t('message.hello', {name: 'visitor'}) }}</p>
</div>

The generated file is an ES6 module & Pluralization don’t work with vue-i18n

 

 

Deven Rathore

Deven is an Entrepreneur, and Full-stack developer, Constantly learning and experiencing new things. He currently runs CodeSource.io and Dunebook.com.

Published by
Deven Rathore

Recent Posts

Top 10 SEO Writing Tips for Beginners 2021

Search Engine Optimization. It’s complicated, to say the least. Search engines, like Google, are constantly…

4 days ago

Should you become a freelancer in 2021? Pros and Cons

Freelancing and working from home was long considered idyllic by many, but the global pandemic…

4 days ago

The Leading Renewable Energy Trends in 2021

The past year saw slowdowns in the ongoing shift toward renewable energy in many countries…

1 week ago

Top 20 Web Developer Portfolio templates

Are you in search for web developer portfolio templates? In this article, I have discussed…

4 weeks ago

The list of top websites to check the grammar of an essay

The hard work and dedication put into an essay should not be thrown away by…

1 month ago

Top Secure Coding Practices Based on OWASP Guidelines

When a good developer makes an app, they don’t leave behind any loose ends. They…

1 month ago