rmariuzzo / Laravel-JS-Localization

🌐 Convert your Laravel messages and consume them in the front-end!
https://github.com/rmariuzzo/laravel-js-localization
MIT License
598 stars 171 forks source link

How to use in vue #165

Closed joe94113 closed 2 years ago

joe94113 commented 2 years ago

development environment

// package.json
"laravel-mix": "^6.0.6",
"vue": "^2.6.14",
// composer.json
"laravel/framework": "^8.65",
"mariuzzo/laravel-js-localization": "^1.9",

In webpack.mix.js,remember npm i laravel-mix-serve

require("laravel-mix-serve");
mix.serve("php artisan lang:js");

In app.blade.php

<script src="{{ asset('messages.js') }}"></script>

In vue

<template>
<p>{{ Lang.get("admin.login") }}</p>
</template>

<script>
export default {
    data: () => ({
        Lang: Lang,
    }),
};