我是新手拉拉维尔 4.0.
- 如何从中获取整个数组
lang/en/texts.php
?
- 有没有
Lang::getAll()
method?
我的目标是在我的基本控制器中生成关键字/描述,将它们填充到主刀片模板中 DOM 的元标记和其他位置。如果我的方法完全错误,请告诉我!
从关联数组生成关键字和描述不是问题,而是缺乏有关框架的知识。而且,我在谷歌上搜索了很长一段时间才来到这里......
使用刀片模板:
这是我的基本控制器:
class HomeController extends BaseController {
protected $layout = 'layouts.master';
private $keyWords = array();
private function getKeyWords () {
// ???
}
public function getIndex() {
return View::make('home')
->with('errorcanvas', trans('texts.canvas'))
->with('errortextwebgl', trans('texts.webgl'))
...;
}
...
}
我发现了一些东西API http://laravel.com/api/4.1/Illuminate/Translation/FileLoader.html:
Illuminate\Translation\FileLoader load()
它加载给定的消息locale
...
You can 获取整个数组 http://laravel.com/docs/localization with Lang::get()
.
$array = Lang::get('pagination'); // return entire array
$text = Lang::get('pagination.next'); // return single item
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)