nobox / lazy-strings-laravel
LazyStrings 的 Laravel 5 服务提供者。
Requires
- php: >=5.5.9
- illuminate/console: 5.2.*
- illuminate/filesystem: 5.2.*
- illuminate/support: 5.2.*
- nobox/lazy-strings: ^5.0
Requires (Dev)
- mockery/mockery: 0.9.*
- orchestra/testbench: 3.2.*
- phpunit/phpunit: 4.7.*
This package is not auto-updated.
Last update: 2024-09-24 19:14:02 UTC
README
LazyStrings 的 Laravel 5 服务提供者。
安装
将 Lazy Strings 添加到 composer.json 文件中。
composer require nobox/lazy-strings-laravel
Laravel 版本
以下是您当前安装的 Laravel 版本可以使用的 lazy strings 版本。
注册 Lazy Strings
在 config/app.php
中的 providers
数组中注册 Lazy Strings 服务提供者。
'providers' => [ Nobox\LazyStrings\LazyStringsServiceProvider::class, ]
发布配置和资源
此包使用一些基本的配置以及来自 bootstrap 的漂亮的 CSS 和 JS。
php artisan vendor:publish
配置
配置非常简单,以下是对每个配置项的描述。更多关于这些配置如何工作的细节可以在 Lazy Strings 仓库 这里 找到。
csv-url
添加 Google 表格的发布 URL。
'csv-url' => 'http://docs.google.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/export?format=csv'
target-folder
此文件夹将位于您的storage
文件夹中,并且它只是保存了您的字符串的JSON
格式备份。默认为lazy-strings
。
'target-folder' => 'lazy-strings'
strings-route
这是用于生成字符串的路由。访问http://my-app.com/lazy/build-copy
,您的字符串将被更新。默认为build-copy
。路由始终位于lazy
前缀下。
'strings-route' => 'build-copy'
nested
是否希望您的生成字符串数组是嵌套的。
'nested' => true,
sheets
在这里指定您的 Google 文档中的所有工作表。
'sheets' => [ 'en' => [0, 1626663029], 'es' => 1329731586, 'pt' => 1443604037 ]
工作原理
Lazy Strings 使用 id => value
约定来访问副本,它将在语言区域文件夹内生成一个 lazy.php
文件。您可以在以下示例文档中看到: https://docs.google.com/a/nobox.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/edit#gid=0。
在这个文档中,您可以通过这种方式访问您的视图中的第一行
trans('lazy.foo') // returns "Hello!"
或者在您的控制器中这样操作
Lang::get('lazy.foo'); // returns "Hello!"
生成您的字符串
每次您需要生成字符串时,只需访问配置中指定的 strings-route
。路由始终位于 lazy
前缀下。例如: http://my-app.com/lazy/build-copy
。
您还可以使用包含的 artisan 命令 php artisan lazy:deploy
。它将做同样的事情。这对于您使用 Forge 或 Envoyer 部署应用程序时来说非常完美。
许可证
MIT