title: Laravel 5.0, Multi Language Website
body: <p>Following is what I have done to achieve multi lingual feature for static text.</p>
  
  <p>Step 1: Open up config/app.php and add the following below 'locale' => 'xx'.</p>
  
  <pre><code>'locales' =&gt; ['en' =&gt; 'English', 'sv' =&gt; 'Swedish'],
  </code></pre>
  
  <p>Step 2: Prefix your routes</p>
  
  <p>To prefix our routes, we change the map method in app/Providers/RouteServiceProvider.php. Change the map method to the following:</p>
  
  <pre><code>public function map(Router $router, Request $request)
  {
      $locale = $request-&gt;segment(1);
      $this-&gt;app-&gt;setLocale($locale);
  
      $router-&gt;group(['namespace' =&gt; $this-&gt;namespace, 'prefix' =&gt; $locale], function($router) {
          require app_path('Http/routes.php');
      });
  }
  </code></pre>
  
  <p>Then add this to the top of the file:</p>
  
  <pre><code>use Illuminate\Routing\Router;
  use Illuminate\Http\Request;
  </code></pre>
  
  <p>Step 3: Create a language middleware</p>
  
  <p>Now create a file named Language.php in app/Http/Middleware with this content:</p>
  
  <pre><code>&lt;?php namespace App\Http\Middleware;
  
  use Closure;
  use Illuminate\Routing\Redirector;
  use Illuminate\Http\Request;
  use Illuminate\Foundation\Application;
  use Illuminate\Contracts\Routing\Middleware;
  
  class Language implements Middleware {
  
      public function __construct(Application $app, Redirector $redirector, Request $request) {
          $this-&gt;app = $app;
          $this-&gt;redirector = $redirector;
          $this-&gt;request = $request;
      }
  
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          // Make sure current locale exists.
          $locale = $request-&gt;segment(1);
  
          if ( ! array_key_exists($locale, $this-&gt;app-&gt;config-&gt;get('app.locales'))) {
              $segments = $request-&gt;segments();
              $segments[0] = $this-&gt;app-&gt;config-&gt;get('app.fallback_locale');
  
              return $this-&gt;redirector-&gt;to(implode('/', $segments));
          }
  
          $this-&gt;app-&gt;setLocale($locale);
  
          return $next($request);
      }
  
  }
  </code></pre>
  
  <p>Now make that middleware run on all requests by adding it to the $middleware property in app/Http/Kernel.php. It is recommended to add it to the top of the array.</p>
  
  <pre><code>protected $middleware = [
      'App\Http\Middleware\Language',
      'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
      'Illuminate\Cookie\Middleware\EncryptCookies',
      'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
      'Illuminate\Session\Middleware\StartSession',
      'Illuminate\View\Middleware\ShareErrorsFromSession',
      'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
  ];
  </code></pre>
  
  <p>All the above has been taken from <a href="https://laracasts.com/discuss/channels/tips/example-on-how-to-use-multiple-locales-in-your-laravel-5-website" rel="nofollow">here</a></p>
  
  <p>After doing all above, my routes do not pick the language automatically ... 
  my root is</p>
  
  <pre><code>Route::get('/', 'WelcomeController@index');
  Route::get('/about', 'WelcomeController@about');
  </code></pre>
  
  <p>And if I give complete path in pages like
  <a href="http://localhost:8000/pl/about" rel="nofollow">http://localhost:8000/pl/about</a></p>
  
  <p>It works.</p>
  
  <p>But I want that it should automatically pick the path means there should not be need of giving complete URLs in pages.</p>
  
  <p>is it correct and how this can be achieved?</p>
  
  <p>I know that in some way I need to work on routes.php but I don't know how to make it work.</p>
  
  <p>I have very limited knowledge in Laravel as I am working on my first project in Laravel</p>