我正在创建标签的输入,有人可以写标签。当然,在两种语言中。但问题是我无法翻译它们。我不知道怎么做。你能帮助我吗?这是我的代码:
JS:
suggestion: function(data) {
return '<li class="list-group-item">' + "@lang('" + "main." + data.name + "')" + '</li>'
}
路线:
Route::group(['prefix'=>'api','middleware' => 'auth'], function(){
Route::get('find', function(Illuminate\Http\Request $request){
$keyword = $request->input('keyword');
Log::info($keyword);
$positions = DB::table('positions')->where('name','like','%'.$keyword.'%')
->select('positions.id','positions.name','positions.display')
->get();
return json_encode($positions);
})->name('api.positions');
});
答案 0 :(得分:0)
最简单的方法是在数据库中添加多个列:
•name_en
•name_fr
•name_es
然后
检查您的目标本地:
$local = 'en';
$positions = DB::table('positions')->where('name_'.
$local,'like','%'.$keyword.'%')
->select('positions.id','positions.name_' . $local .' as
name' ,'positions.display')
->get();