Laravel语言文件.抓住丢失的定义



我在我的应用程序中使用Laravel的语言功能。

我遇到的问题是,如果我调用不存在的语言行,返回值是使用的键,例如

Lang::get('messages.doesNotExist');
returns 'messages.doesNotExist'

Laravel是否提供任何方法来找出语言行是否缺失?例如,将丢失的行记录到错误日志中?

我担心的是,我可能没有意识到语言行丢失了,除非用户标记给我。

From docs (http://laravel.com/docs/localization#basic-usage):

)

判断语言文件是否包含一行

if (Lang::has('messages.doesNotExist'))
{
    //
}

我是Lost in Translation的作者,它可以分析您的代码和本地化文件,以找到丢失的翻译和未使用的键。在安装并将其添加到服务提供者之后(如README中所述),您可以使用locale:scan artisan命令生成本地化使用的报告。如:

$ php artisan locale:scan
Preparing files
Looking in /git/lost-in-translation-wrapper/app and git/lost-in-translation-wrapper/resources
Searching translationkeys in 51 files
 51/51 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Found 23 translations.
There are missing translations.
+----------------------------------------------+-------+-----------+---------+
| Key                                          | Group | Namespace | Missing |
+----------------------------------------------+-------+-----------+---------+
| failed                                       | auth  | *         | fr      |
| throttle                                     | auth  | *         | fr      |
| password                                     | auth  | *         | fr      |
| Email                                        | *     | *         | es, fr  |
| Password                                     | *     | *         | es, fr  |
| Confirm Password                             | *     | *         | es, fr  |
| Reset Password                               | *     | *         | es, fr  |
| Name                                         | *     | *         | es, fr  |
| Already registered?                          | *     | *         | es, fr  |
| Register                                     | *     | *         | es      |
| This is a secure area of the application     | *     | *         | es, fr  |
| Confirm                                      | *     | *         | es, fr  |
| Forgot your password? No problem             | *     | *         | es, fr  |
| Email Password Reset Link                    | *     | *         | es, fr  |
| Thanks for signing up! Before getting st ... | *     | *         | es, fr  |
| A new verification link has been sent to ... | *     | *         | es, fr  |
| Resend Verification Email                    | *     | *         | es, fr  |
| Log Out                                      | *     | *         | es, fr  |
| Remember me                                  | *     | *         | es, fr  |
| Forgot your password?                        | *     | *         | es, fr  |
| Log in                                       | *     | *         | es, fr  |
| Whoops! Something went wrong                 | *     | *         | es, fr  |
| Dashboard                                    | *     | *         | es, fr  |
+----------------------------------------------+-------+-----------+---------+
There are unused translations.
*.*.I love programming.
*.auth.invalid

最新更新