PHP code example of longman / laravel-multilang
1. Go to this page and download the library: Download longman/laravel-multilang 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/ */
longman / laravel-multilang example snippets
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Longman\LaravelMultiLang\Middleware\MultiLang::class,
];
MultiLang::routeGroup(function($router) {
MultiLang::routeGroup(function($router) {
// your routes and route groups here
});
App::setLocale('en');
$string = t('Your translatable string');
$string = t('The :attribute must be a date after :date.', ['attribute' => 'Start Date', 'date' => '7 April 1986']);
@t('Your translatable string')
$url = lang_url('users'); // which returns /en/users depending on your language (locale)
$url = lang_url('users', [], null, 'ka'); // which returns /ka/users ignoring current locale
$url = lang_url('en/users', [], null, 'ka'); // also returns /ka/users
$url = lang_route('users'); // which returns en.users depending on your language (locale)
app('multilang')->setScope('admin');