vis / translations_l5
L5 的翻译
2.1.1
2021-01-28 13:56 UTC
This package is not auto-updated.
Last update: 2024-09-20 07:20:04 UTC
README
连接
composer require vis/translations_l5
执行表迁移
php artisan migrate --path=vendor/vis/translations_l5/src/Migrations
发布 config 和 js 文件
php artisan vendor:publish --tag=translations --force
在 config/builder/admin.php 文件中 menu 数组添加
array( 'title' => 'Переводы', 'icon' => 'language', 'link' => '/translations/phrases', 'check' => function() { return true; } ),
在 Laravel Blade 低于 5.4 中使用 __() 函数
{{__('привет')}}
在 Laravel Blade 5.4 及以上版本中使用 __t() 函数
{{__t('привет')}}
生成翻译
php artisan translate:generate
生成翻译并在表中创建翻译字段
php artisan translate:table {tables} {fields}
其中 {tables} 表示表名,例如:user,news 和 {fields} 表示字段名,例如:title,description
JavaScript 翻译
<script src="{{route('translate_js', ['lang' => config('app.locale')])}}"></script>