php - 使用 Laravel 5.8 获取所有本地化字符串
问题描述
如何获取文件语言的所有本地化字符串?
当我使用Lang::get();
时,我得到一个错误。我需要获取组密钥。但是我怎样才能得到所有的语言字符串,以及组和键呢?
解决方案
在您的config/filesystems.php
文件中添加以下内容:
'lang' => [
'driver' => 'local',
'root' => base_path('resources/lang/en'),
],
然后,您可以使用此磁盘遍历所有文件,并从每个文件中获取内容:
foreach (Storage::disk('lang')->files('') as $file)
{
dd(Lang::get(explode('.php', $file)[0])); // you can use something else then explode to get just the name of the file without the extension
}
推荐阅读
- java - 如何在控制器响应时间上设置 Json PropertyNamingStrategy
- google-apps-script - Google Script onChange 触发器在未进行任何更改时执行(一夜之间)
- eclipse-che - 在 kubernetes 集群(不是 minikube)上部署 Eclipse Che v7
- ruby - 如果哈希数组具有属性/值对,我如何编写 rspec 测试
- python - 如果包含某些单词,则提取 html 表中的文本
- c# - Oracle 编号映射 (ODP.NET)
- rest - 如何将 api body x-www-form-urlencoded 转换为原始纯文本/文本
- vue.js - TypeError:无法读取未定义的属性“缓存”-VueJS
- mysql - 如何在 MYSQL 数据库 varchar() 表列中搜索是否存在任何“关键字”字符串列表?
- angular - 嵌套 Angular Material 自定义组件主题