In Laravel 5.x we have lang class which will help us to retrieving string in different languages that will help us to easily support multiple languages.
The folder structure for /resources/lang files are
/resources
/lang
/en
messages.php
/es
messages.php
Example:
Language files always give an array of keyed strings.
<?php
return array(
'welcome' => 'Welcome to our application'
);
Note: we can also change our default language by changing in the app/config/app.php configuration file.
App::setLocale('es');
Configuring The Locale
All the configuration of locale is stored in the config/app.php.We can also change the active language at runtime using the setLocale method on the App facade:
Example:
Route::get('welcome/{locale}', function ($locale) {
App::setLocale($locale);
//
});
By this way we can make our site multilingual.
0 Comment(s)