在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):innocenzi/laravel-vue-lang开源软件地址(OpenSource Url):https://github.com/innocenzi/laravel-vue-lang开源编程语言(OpenSource Language):TypeScript 87.2%开源软件介绍(OpenSource Introduction):
Localization for Vue and Laravel
This package allows to easily setup localization with a Laravel application using Vue. It is based on
Installation$ yarn add laravel-vue-lang With the Laravel Mix extensionThis package ships with a Laravel Mix extension. You can include it and call Your const mix = require('laravel-mix');
require('laravel-vue-lang/mix');
mix
// ...
.lang(); Without the extensionIf you prefer manual configuration, you will need to add a rule to load your translations, and a const mix = require('laravel-mix');
mix
// ...
.webpackConfig({
resolve: {
alias: {
'@lang': path.resolve('./resources/lang'),
},
},
module: {
rules: [
{
test: /resources[\\\/]lang.+\.(php)$/,
loader: 'php-array-loader',
},
],
},
}); UsageRegister the plugin in your Javascript: import { Lang } from 'laravel-vue-lang';
// Register the plugin
Vue.use(Lang, {
locale: 'fr',
fallback: 'en',
ignore: {
fr: ['validation'],
},
});
// Register Vue
const app = new Vue({
el: '#app',
}); You can now use the following in any Vue file:
Example: <template>
<div>
<span>{{ __('messages.hello') }}</span>
</div>
</template>
<script>
export default {
created() {
console.log(this.__('messages.hello'));
},
};
</script> Root-level translationsIt is possible to have a root-level set of translations, such as a // resources/lang/fr.php
<?php
return [
'Hey you' => 'Salut toi'
]; <!-- Component.vue -->
<template>
<div>
<span>{{ __('Hey you') }}</span>
<!-- Salut toi -->
</div>
</template> This is possible by working around Options
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论