本文整理汇总了PHP中LaravelLocalization::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP LaravelLocalization::setLocale方法的具体用法?PHP LaravelLocalization::setLocale怎么用?PHP LaravelLocalization::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LaravelLocalization
的用法示例。
在下文中一共展示了LaravelLocalization::setLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$params = $this->params;
$localization = \Mcamara\LaravelLocalization\LaravelLocalization::class;
if (class_exists($localization)) {
\LaravelLocalization::setLocale($this->locale);
}
app()->setLocale($this->locale);
if ($this->type == 'Normal') {
// Text send
Mail::raw($params['html'], function ($message) use($params) {
if ($params['attach']) {
$message->attach($params['attach']);
}
$message->to($params['to'])->from(env('MAIL_USERNAME'), $params['fromName'])->subject($params['subject']);
});
} elseif ($this->type == 'Template') {
// Template send
Mail::send($params['templateInvokeName'], $params['xsmtpapi'], function ($message) use($params) {
if ($params['attach']) {
$message->attach($params['attach']);
}
$message->to($params['to'])->from(env('MAIL_USERNAME'), $params['fromName'])->subject($params['subject']);
});
}
$fileDir = $this->getSwiftmailLogDir();
$this->logInfo('[' . Carbon::now($this->local)->format('Y-m-d H:i:s') . ']' . json_encode($params, JSON_UNESCAPED_UNICODE) . chr(10), $fileDir);
}
示例2: doChangeLocale
public function doChangeLocale()
{
$locale = Input::get('locale');
LaravelLocalization::setLocale($locale);
App::setLocale($locale);
Cookie::queue('locale', $locale);
return Response::json(array('status' => true, 'link' => geturl(Input::get('url'))));
}
示例3: config
Route::get(LaravelLocalization::transRoute('routes.account.create'), ['as' => 'account.create', 'uses' => 'Auth\\AccountController@createAccount']);
Route::post(LaravelLocalization::transRoute('routes.account.store'), ['as' => 'account.store', 'uses' => 'Auth\\AccountController@store']);
Route::get(LaravelLocalization::transRoute('routes.account.email'), ['as' => 'account.activation_email', 'uses' => 'Auth\\AccountController@sendActivationEmail']);
Route::get(LaravelLocalization::transRoute('routes.account.activation'), ['as' => 'account.activate', 'uses' => 'Auth\\AccountController@activateAccount']);
// login
Route::get(LaravelLocalization::transRoute('routes.login.index'), ['as' => 'login.index', 'uses' => 'Auth\\AuthController@index']);
Route::post(LaravelLocalization::transRoute('routes.login.login'), ['as' => 'login.login', 'uses' => 'Auth\\AuthController@login']);
// password recovery
Route::get(LaravelLocalization::transRoute('routes.password.index'), ['as' => 'password.index', 'uses' => 'Auth\\PasswordController@index']);
Route::post(LaravelLocalization::transRoute('routes.password.email'), ['as' => 'password.email', 'uses' => 'Auth\\PasswordController@sendResetEmail']);
Route::get(LaravelLocalization::transRoute('routes.password.reset'), ['as' => 'password.reset', 'uses' => 'Auth\\PasswordController@show']);
Route::put(LaravelLocalization::transRoute('routes.password.update'), ['as' => 'password.update', 'uses' => 'Auth\\PasswordController@update']);
});
//public routes
// we define the middlewares to apply according to the config
$group = config('settings.multilingual') ? ['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localize', 'localeSessionRedirect', 'localizationRedirect']] : [];
Route::group($group, function () {
// home
Route::get('/', ['as' => 'home', 'uses' => 'Home\\HomeController@show']);
// news
Route::get(trans('routes.news.index'), ['as' => 'news.index', 'uses' => 'News\\NewsController@index']);
Route::get(trans('routes.news.show'), ['as' => 'news.show', 'uses' => 'News\\NewsController@show']);
// leading team
Route::get(trans('routes.leading_team.index'), ['as' => 'front.leading_team', 'uses' => 'LeadingTeam\\LeadingTeamController@index']);
// palmares
Route::get(trans('routes.palmares.index'), ['as' => 'palmares.index', 'uses' => 'Palmares\\PalmaresController@index']);
// registration
Route::get(trans('routes.registration.index'), ['as' => 'registration.index', 'uses' => 'Registration\\RegistrationController@index']);
// calendar
Route::get(trans('routes.calendar.index'), ['as' => 'calendar.index', 'uses' => 'Calendar\\CalendarController@index']);
// schedule
示例4: function
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::get('auth/register/confirm/{email_token}', 'Auth\\AuthController@confirmEmail');
// Password reset link request routes...
//Route::get('password/email', 'Auth\PasswordController@getEmail');
//Route::post('password/email', 'Auth\PasswordController@postEmail');
// Password reset routes...
//Route::get('auth/password/reset/{token}', 'Auth\PasswordController@getReset');
//Route::post('auth/password', 'Auth\PasswordController@postReset');
/** Home ruta za testiranje **/
Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['auth', 'localize']], function () {
Route::get('/', ['as' => LaravelLocalization::transRoute('routes.home'), function () {
return View::make('index');
}]);
});
Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localize']], function () {
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
Route::get(LaravelLocalization::transRoute('routes.about'), function () {
return view('frontend.institution.index');
});
});
/** OTHER PAGES THAT SHOULD NOT BE LOCALIZED **/
Route::get('admin/dashboard', ['middleware' => 'auth', function () {
return view('layouts.admin.master');
}]);
Route::get('users', 'UsersController@index');
Route::resource(LaravelLocalization::transRoute('routes.institution'), 'InstitutionsController');
Route::resource(LaravelLocalization::transRoute('routes.faculty-bodies'), 'BodiesController');
Route::resource(LaravelLocalization::transRoute('routes.body-types'), 'BodyTypesController');
Route::resource(LaravelLocalization::transRoute('routes.functions'), 'BodyTypeFunctionsController');
Route::resource(LaravelLocalization::transRoute('routes.services'), 'ServicesController');
示例5: function
}
Route::group($routesParams, function () use($node, $_nodeUrl, $templates) {
Route::get($_nodeUrl, function () use($node, $templates) {
if (!isset($templates[$node->template])) {
App::abort(404);
}
list($controller, $method) = explode('@', $templates[$node->template]['action']);
$app = app();
$controller = $app->make($controller);
return $controller->callAction('init', array($node, $method));
});
});
if (LaravelLocalization::setLocale() == "") {
$pathUrl = "/" . Request::path();
} else {
$pathUrl = Request::path();
}
if ($pathUrl == LaravelLocalization::setLocale() . $_nodeUrl) {
Session::put('currentNode', $node);
} else {
Session::put('currentNode', $node);
}
}
}
} catch (Exception $e) {
// todo: implement
}
}
// devel fallback
Route::get('/thereisnospoon', 'Yaro\\Jarboe\\DevelController@showMain');
Route::post('/thereisnospoon', 'Yaro\\Jarboe\\DevelController@handleMain');
示例6: function
<?php
use Illuminate\Routing\Router;
/** @var Router $router */
/*
|--------------------------------------------------------------------------
| Admin routes
|--------------------------------------------------------------------------
*/
$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin|permissions'], function (Router $router) {
$router->group(['prefix' => Config::get('core::core.admin-prefix') . '/place', 'namespace' => 'Modules\\Place\\Http\\Controllers'], function (Router $router) {
$router->resource('places', 'Admin\\PlaceController', ['except' => ['show'], 'names' => ['index' => 'admin.place.place.index', 'create' => 'admin.place.place.create', 'store' => 'admin.place.place.store', 'edit' => 'admin.place.place.edit', 'update' => 'admin.place.place.update', 'destroy' => 'admin.place.place.destroy']]);
});
});
示例7: foreach
<?php
/*
|--------------------------------------------------------------------------
| Frontend Routes
|--------------------------------------------------------------------------
*/
$languages = LaravelLocalization::getSupportedLocales();
foreach ($languages as $language => $values) {
$supportedLocales[] = $language;
}
$locale = Request::segment(1);
if (in_array($locale, $supportedLocales)) {
LaravelLocalization::setLocale($locale);
App::setLocale($locale);
}
Route::get('/', function () {
return Redirect::to(LaravelLocalization::getCurrentLocale(), 302);
});
Route::group(array('prefix' => LaravelLocalization::getCurrentLocale(), 'before' => array('localization', 'before')), function () {
Session::put('my.locale', LaravelLocalization::getCurrentLocale());
// frontend dashboard
Route::get('/', ['as' => 'dashboard', 'uses' => 'HomeController@index']);
// article
Route::get('/article', array('as' => 'dashboard.article', 'uses' => 'ArticleController@index'));
Route::get('/article/{slug}', array('as' => 'dashboard.article.show', 'uses' => 'ArticleController@show'));
// news
Route::get('/news', array('as' => 'dashboard.news', 'uses' => 'NewsController@index'));
Route::get('/news/{slug}', array('as' => 'dashboard.news.show', 'uses' => 'NewsController@show'));
// tags
Route::get('/tag/{slug}', array('as' => 'dashboard.tag', 'uses' => 'TagController@index'));
示例8: app_path
<?php
Route::pattern('id', '[0-9]+');
Route::pattern('slug', '[a-z0-9-]+');
if (file_exists(app_path() . '/routes_dev.php')) {
include app_path() . '/routes_dev.php';
}
include app_path() . '/routes_backend.php';
include 'view_composers.php';
Route::group(array('prefix' => LaravelLocalization::setLocale()), function () {
Route::post('/app/change-locale', 'HomeController@doChangeLocale');
Route::post('/rates/refresh', 'HomeController@doRefreshRates');
/* Calculators */
Route::post('/calculator/refinance', 'CalculatorController@doRefinanceCalculation');
Route::post('/calculator/consumer', 'CalculatorController@doConsumerCalculation');
Route::post('/calculator/cash', 'CalculatorController@doCashCalculation');
Route::post('/calculator/deposit', 'CalculatorController@doDepositCalculation');
Route::post('/calculator/get-deposit-interest', 'CalculatorController@getDepositInterest');
/* end Calculators */
Route::post('/apply-form/product', 'ApplyController@doApplyProduct');
Route::post('/apply-form/business', 'ApplyController@doApplyBusiness');
Route::post('/apply-form/deposit', 'ApplyController@doApplyDeposit');
Route::post('/feedback/send', 'FeedbackController@doSendFeedback');
Route::post('/apply-form/subscriber', 'ApplyController@doApplySubscriber');
Route::get('/form-deposit-compare', 'PrivatePersonsController@formDepositCompare');
Route::get('/about/press/{slug}-{id}', 'AboutController@showSinglePressItem');
Route::post('/about/press/load', 'AboutController@doLoadPressItems');
// map
Route::post('/map/filter', 'MapController@doFilter');
// async
Route::post('/async/add-card-to-compare', 'AsyncController@addCardToCompare');
示例9: setActive
function setActive($path)
{
$prefix = LaravelLocalization::setLocale() . '/' . request()->segment(2);
if (request()->is($prefix . $path) || request()->is($prefix . $path . '/*')) {
return "class=active";
}
return '';
}
示例10: function
<?php
use Illuminate\Routing\Router;
/** @var Router $router */
$router->group(['prefix' => 'blog'], function (Router $router) {
$locale = LaravelLocalization::setLocale() ?: App::getLocale();
$router->get('posts', ['as' => $locale . '.blog', 'uses' => 'PublicController@index', 'middleware' => config('asgard.blog.config.middleware')]);
$router->get('posts/{slug}', ['as' => $locale . '.blog.slug', 'uses' => 'PublicController@show', 'middleware' => config('asgard.blog.config.middleware')]);
});
示例11: function
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('sitemap.xml', function () {
$content = View::make('general.sitemap');
return Response::make($content, '200')->header('Content-Type', 'text/xml');
});
Route::get('generatesitemap', function () {
return Artisan::call('generatesitemap');
});
Route::group(array('prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter'), function () {
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
Route::get('terms', ['as' => 'terms', function () {
return View::make('home.terms');
}]);
Route::get('contact', ['as' => 'contact', 'uses' => 'HomeController@getContact']);
Route::get('search', ['as' => 'search', 'uses' => 'HomeController@search']);
Route::post('contact', ['as' => 'contact.post', 'uses' => 'HomeController@postContact']);
Route::get('users/login', ['as' => 'login', 'uses' => 'AuthController@getLogin']);
Route::post('users/login', ['before' => 'csrf', 'as' => 'login.post', 'uses' => 'AuthController@postLogin']);
Route::get('users/logout', ['as' => 'logout', 'uses' => 'AuthController@getLogout']);
Route::get('users/register', ['as' => 'register', 'uses' => 'AuthController@getRegister']);
Route::post('users/register', ['as' => 'register.post', 'uses' => 'AuthController@postRegister']);
Route::get('users/resend-validation', ['as' => 'resend-validation', 'uses' => 'AuthController@getResendValidationEmail']);
Route::post('users/resend-validation', ['as' => 'resend-validation.post', 'uses' => 'AuthController@postResendValidationEmail']);
Route::get('users/register/verify/{confirmation_code}', ['as' => 'verify-register', 'uses' => 'AuthController@verifyRegister']);
示例12: startSendTemplate
/**
* It's you can send template mail
* @param string $uri Api Url
* @return json
*/
private function startSendTemplate($uri)
{
// Def send params
$params = ['apiUser' => $this->getApiUser(), 'apiKey' => $this->getApiKey(), 'from' => $this->getFrom(), 'fromName' => $this->getFromName(), 'to' => '', 'cc' => $this->cc, 'bcc' => $this->bcc, 'replyTo' => $this->replyTo, 'xsmtpapi' => '', 'subject' => $this->subject, 'attach' => $this->attach, 'templateInvokeName' => ''];
// Set the gateway corresponding method
foreach ($this->to as $gateway => $mails) {
$params['to'] = isset($this->to[$gateway]) ? $this->to[$gateway] : null;
$params['cc'] = isset($this->cc[$gateway]) ? $this->cc[$gateway] : null;
$params['bcc'] = isset($this->bcc[$gateway]) ? $this->bcc[$gateway] : null;
$params['xsmtpapi'] = $this->xsmtpapi[$gateway];
$params['templateInvokeName'] = $this->templateInvokeName[$gateway];
if ('swiftmail' == $gateway) {
if ($this->getQueue()) {
$job = (new MailSender('Template', $params, $this->getLocale()))->onQueue($this->getQueueTarget());
$this->dispatch($job);
break;
}
$this->swiftMailTemplateSend($params);
} else {
$localization = \Mcamara\LaravelLocalization\LaravelLocalization::class;
if (class_exists($localization)) {
\LaravelLocalization::setLocale($this->getLocale());
}
app()->setLocale($this->getLocale());
$params['to'] = isset($params['to']) ? implode(';', $params['to']) : null;
$params['cc'] = isset($params['cc']) ? implode(';', $params['cc']) : null;
$params['bcc'] = isset($params['bcc']) ? implode(';', $params['bcc']) : null;
$this->apiMailSend($uri, $gateway, $params);
}
}
}
示例13: array_except
$__env->startSection('content');
?>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<?php
echo $__env->make('template.lang', array_except(get_defined_vars(), array('__data', '__path')))->render();
?>
<div class="row">
<div class="col-lg-12">
<form action="<?php
echo e(URL::asset(LaravelLocalization::setLocale() . DIRECTORY_SEPARATOR . 'admin-product-edit/' . $product->id));
?>
" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="usr">Заглавие: </label>
<input name="title" value="<?php
echo e($product->title);
?>
" type="text" class="form-control" id="usr">
</div>
<input type="hidden" name="_token" value="<?php
echo e(csrf_token());
?>
">
示例14: array_keys
}
}
$urls = array_keys($otherTreeUrl);
if ($urls && count($urls) && in_array($startUrl, $urls)) {
if (isset($otherTreeUrl[$startUrl])) {
$configName = $otherTreeUrl[$startUrl];
$path = app_path() . '/config/packages/vis/builder/' . $configName . '.php';
$definition = (require_once $path);
$model = $definition['model'];
$slug = end($arrSegments);
if (!isset($slugTree)) {
$node = $model::where("slug", 'like', $slug)->first();
if (isset($node->id)) {
$_nodeUrl = $node->getUrlNoLocation();
$templates = $definition['templates'];
Route::group(array('prefix' => LaravelLocalization::setLocale()), function () use($node, $_nodeUrl, $templates) {
Route::get($_nodeUrl, function () use($node, $templates) {
if (!isset($templates[$node->template])) {
App::abort(404);
}
list($controller, $method) = explode('@', $templates[$node->template]['action']);
$app = app();
$controller = $app->make($controller);
return $controller->callAction('init', array($node, $method));
});
});
}
}
}
}
}
示例15: array_except
$__env->startSection('content');
?>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<?php
echo $__env->make('template.lang', array_except(get_defined_vars(), array('__data', '__path')))->render();
?>
<div class="row">
<div class="col-lg-12">
<form action="<?php
echo e(URL::asset(LaravelLocalization::setLocale() . DIRECTORY_SEPARATOR . 'admin-category-edit/' . $category->id));
?>
" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="usr">Заглавие: </label>
<input name="title" value="<?php
echo e($category->title);
?>
" type="text" class="form-control" id="usr">
</div>
<input type="hidden" name="_token" value="<?php
echo e(csrf_token());
?>
">
<div class="form-group">