答えて

6

Laravelはユーザーがログインしている場合はファサードAuth::check()を使用してチェックするための簡単な方法を提供します。翻訳について

if (Auth::check()) { 
    // The user is logged in... 
} 

、あなたはここで確認することができます:Laravelも使用してフレーズを翻訳する簡単な方法を提供し

/resources 
    /lang 
     /en 
      messages.php 
     /es 
      messages.php 

:ドキュメントごとにLocalization

構造は、次のように定義されていますtrans('string.to.translate')、これはここに見ることができるtrans()です。

messages.phpの内側(両方のlangディレクトリ内)に、翻訳文字列を設定する必要があります。

これら2つと
return [ 
     'welcome' => 'Bienvenido' 
    ]; 

、あなたが例えば、あなたのアプリケーションで以下の操作を行うことができます:

es/messages.php
return [ 
     'welcome' => 'Welcome' 
    ]; 

en/messages.phpであなたのviewインサイド

// Get the user locale, for the sake of clarity, I'll use a fixed string. 
    // Make sure is the same as the directory under lang. 
    App::setLocale('en'); 

// Using blade, we check if the user is logged in. 
    // If he is, we show 'Welcome" in the menu. If the lang is set to 
    // 'es', then it will show "Bienvenido". 
    @if (Auth::check()) 
     <ul> 
      <li> {{ trans('messages.welcome') }} </li> 
     </ul> 
    @endif 
関連する問題