yazeedobaid / laravel-lang
Laravel翻译的模块化导出,适用于前端和API使用。
0.1
2018-06-17 11:51 UTC
This package is auto-updated.
Last update: 2024-09-27 00:03:12 UTC
README
Laravel-Lang
Laravel翻译的模块化导出,适用于前端和API使用。
此包受到了基于Laravel构建的CMS工作方式以及它们如何结构化成大型应用程序包的启发。在这些CMS中,每个包都有自己的lang目录。
此外,此包还有一个排除数组,用于排除这些模块化包中每个lang目录中的lang文件。最后,在导出完成后,会触发一个事件。
安装
使用Composer在项目的根目录中要求此包。
$ composer require yazeedobaid/laravel-lang
资产发布
要发布包的配置文件,请使用
php artisan vendor:publish --provider=YazeedObaid\Lang\LaravelLangServiceProvider --tag=config
用法
将此路由添加到您的前端或将其作为API调用。 http://your-web-app/js/lang.js
配置文件
配置文件包含用于翻译的路由配置、应用于路由的中间件数组、指定事件通道的事件频道。
'paths'和'files_to_exclude'数组的关键字必须相同,因为这些关键字定义了每个包名称(别名)。请随意选择您喜欢的名称。
示例配置文件
以下是一个示例,展示如何获取包含排除翻译文件的包的路径
'paths' => [ /** * For each package in your project you can define the relative path to that * package from your root app directory to the lang directory in that package * to use it in export to Vue. The default path to Laravel applications which * is /resources/lang is set by default to you * */ /** * Default path is the resources/lang path. * */ 'default' => '/resources/lang', /** * Here you define a path for each package you want to export the * translations for. * */ 'my-package' => '/packages/myPckage/src/resources/lang' ], 'files_to_exclude' => [ /** * In each package you define above in the paths array you can exclude files * in that package and not to include them in export to Vue process. Use the * same key you use above to exclude files in each package. The below is an * example of excluding the auth file in default Laravel translations * location. * */ /*'default' => [ 'auth' ]*/ ]
注意事项
此包受到了kg-bot/laravel-localization-to-vue的启发。