语言重定向laravel

时间:2018-03-27 07:25:48

标签: php laravel lang

我有slug的类别。
示例:public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ProductViewHolder> { private Context mCtx; private List<Question> qaList; RecyclerViewClickListener recyclerViewClickListener; public void setRecyclerViewClickListener(RecyclerViewClickListener recyclerViewClickListener) { this.recyclerViewClickListener = recyclerViewClickListener; } public ProductsAdapter(Context mCtx, List<Question> qaList) { this.mCtx = mCtx; this.qaList = qaList; } public interface RecyclerViewClickListener { void recyclerViewListClicked(View v, int position); } @Override public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(mCtx); View view = inflater.inflate(R.layout.product_list, null); return new ProductViewHolder(view); } @Override public void onBindViewHolder(ProductViewHolder holder, int position) { Question que = qaList.get(position); holder.textViewQue.setText(que.getQue()); holder.textViewA.setText(que.getopA()); holder.textViewB.setText(que.getopB()); holder.textViewC.setText(que.getopC()); holder.textViewD.setText(que.getopD()); holder.textViewAns.setText(que.getAns()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { recyclerViewClickListener.recyclerViewListClicked(view,position); } }); } @Override public int getItemCount() { return qaList.size(); } public static class ProductViewHolder extends RecyclerView.ViewHolder{ TextView textViewQue, textViewA, textViewB, textViewC, textViewD, textViewAns; public ProductViewHolder(View itemView) { super(itemView); textViewQue = itemView.findViewById(R.id.tv_Que); textViewA = itemView.findViewById(R.id.tvOpt_A); textViewB = itemView.findViewById(R.id.tvOpt_B); textViewC = itemView.findViewById(R.id.tvOpt_C); textViewD = itemView.findViewById(R.id.tvOpt_D); textViewAns = itemView.findViewById(R.id.tv_Ans); } } - 这是英文slug
mRvData.setAdapter(productsAdapter); productsAdapter.setRecyclerViewClickListener(new ProductsAdapter.RecyclerViewClickListener() { @Override public void recyclerViewListClicked(View v, int position) { Toast.makeText(getApplicationContext(),"Position to Click:"+position,Toast.LENGTH_SHORT).show(); } }); - 但这是俄罗斯slu ..

当我在此页面上切换语言时,它们不会被翻译。如何用某种语言重定向slug?

我的中间件Language.php:

site.com/category/auto

路线:

site.com/category/mashini

CategoryController:

public function handle($request, Closure $next)
{
    if (Session::has('applocale') AND array_key_exists(Session::get('applocale'), Config::get('langs'))) {
        App::setLocale(Session::get('applocale'));
    }
    else { // This is optional as Laravel will automatically set the fallback language if there is none specified
        App::setLocale(Config::get('app.fallback_locale'));
    }
    return $next($request);
}

0 个答案:

没有答案