coding-socks / lost-in-translation
此软件包可以帮助您在Laravel blade文件中找到缺失的翻译字符串
v0.3.3
2024-08-13 14:21 UTC
Requires
- php: ^8.0
- illuminate/console: ^9.0 || ^10.0 || ^11.0
- illuminate/filesystem: ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^9.0 || ^10.0 || ^11.0
- illuminate/translation: ^9.0 || ^10.0 || ^11.0
- illuminate/view: ^9.0 || ^10.0 || ^11.0
- nikic/php-parser: ^4.18 || ^5.0
Requires (Dev)
- orchestra/testbench: ^7.3 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.5 || ^10.5
README
此软件包可以帮助您在Laravel blade文件中找到缺失的翻译字符串。
安装
您可以使用Composer轻松安装此软件包,只需运行以下命令
composer require coding-socks/lost-in-translation --dev
用法
您可以使用以下命令列出特定位置的缺失翻译。
php artisan lost-in-translation:find {locale}
示例
php artisan lost-in-translation:find nl
有时建议使用-v
标志来增加详细程度。在详细模式下,命令将警告和错误打印到标准输出。
发布
仅发布配置文件
php artisan vendor:publish --tag=lost-in-translation-config
仅发布命令类
php artisan vendor:publish --tag=lost-in-translation-commands
默认值
该命令将app.locale
视为您应用程序的默认区域设置。
该命令扫描您的lang
目录,与默认和目标区域设置进行比较。
该命令扫描您的app
和resources/views
目录以检索翻译。
该命令在您的blade和应用文件中检测以下内容
@lang('key')
Blade指令被编译为app('translator')->get('key')
__('key')
对__
函数的任何调用trans('key')
对trans
函数的任何调用trans_choice('key', x)
对trans_choice
函数的任何调用app('translator')->get('key')
对translator
的任何直接get
方法调用App::make('translator')->get('key')
对translator
的任何直接get
方法调用Lang::get('key')
对Lang
外观的任何get
静态调用<<<'blade'
带有blade
标签的nowdoc中的内联组件被编译,并扫描其内容。
帮助
Description:
Find missing translation strings in your Laravel blade files
Usage:
lost-in-translation:find [options] [--] <locale>
Arguments:
locale The locale to be checked
Options:
--sorted Sort the values before printing
--no-progress Do not show the progress bar
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
实现
此实现读取您的所有blade文件,将它们编译为PHP(illuminate/view),然后将它们解析为PHP(nikic/php-parser),最后在AST中找到相关节点。
在我看来,这比使用正则表达式更干净且错误更少。