1. Go to this page and download the library: Download now-here/laravel-gettext library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* Default locale: this will be the default for your application all
* localized strings. Is to be supposed that all strings are written
* on this language.
*/
'locale' => 'es_ES',
/**
* Supported locales: An array containing all allowed languages
*/
'supported-locales' => array(
'es_ES',
'en_US',
'it_IT',
'es_AR',
),
/**
* Changes the current language and returns to previous page
* @return Redirect
*/
public function changeLang($locale=null)
{
LaravelGettext::setLocale($locale);
return Redirect::to(URL::previous());
}
<ul>
@foreach(Config::get('laravel-gettext.supported-locales') as $locale)
<li><a href="/lang/{{$locale}}">{{$locale}}</a></li>
@endforeach
</ul>
/**
* Paths where Poedit will search recursively for strings to translate.
* All paths are relative to app/ (don't use trailing slash).
*
* Remember to call artisan gettext:update after change this.
*/
'source-paths' => array(
'Http/Controllers',
'../resources/views',
'foo/bar', // app/foo/bar
),