本文整理汇总了PHP中LaravelLocalization类的典型用法代码示例。如果您正苦于以下问题:PHP LaravelLocalization类的具体用法?PHP LaravelLocalization怎么用?PHP LaravelLocalization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LaravelLocalization类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
// retrieve all the user_ids from DB
$users = DB::table('users')->pluck('id');
// create posts for a single user only
// $users = ['0'=>'34'];
//echo '<pre>'; print_r($users); echo '</pre>'; exit;
// retrieve all the taxon_ids from DB
$taxons = DB::table('blog_taxons')->pluck('id');
// the following commneted lines add the same user for each post
//factory(App\Models\Posts\Post::class, 5)->create([
// 'user_id' => $faker->randomElement($users)
//]);
// the following lines add a diferent user for each post
foreach (range(1, 5) as $index) {
//the following lines make use of the model factory
//$post = factory(App\Models\Posts\Post::class)->create([
// 'user_id' => $faker->randomElement($users)
//]);
$post = App\Models\Posts\Post::create(['title' => ucwords(implode(' ', $faker->words(5))), 'is_public' => $faker->boolean, 'identifier' => $faker->slug, 'post_type' => $faker->word, 'content' => implode(' ', $faker->paragraphs(3)), 'content_data' => implode(' ', $faker->paragraphs(3)), 'draft' => implode(' ', $faker->paragraphs(3)), 'producer_name' => $faker->word, 'youtube_code' => $faker->word, 'copyright_holder' => $faker->word, 'reference_link_target' => $faker->word, 'source_of_supply' => $faker->word, 'user_id' => $faker->randomElement($users)]);
foreach (LaravelLocalization::getSupportedLocales() as $locale => $data) {
if ($locale != LaravelLocalization::getCurrentLocale()) {
$post->translateOrNew($locale);
$post->translate($locale)->title = strtoupper($locale) . '::' . ucwords(implode(' ', $faker->words(5)));
//$post->translate($locale)->slug = $faker->slug;
$post->translate($locale)->identifier = $faker->slug;
$post->translate($locale)->content = implode(' ', $faker->paragraphs(3));
$post->translate($locale)->content_data = implode(' ', $faker->paragraphs(3));
$post->translate($locale)->draft = implode(' ', $faker->paragraphs(3));
}
}
$post->save();
if (count($taxons)) {
$post->taxons()->attach($faker->randomElement($taxons));
}
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$inputs = Request::all();
$reglas = array('nombre' => 'required', 'correo' => 'email', 'comentarios' => 'required|max:300');
$mensajes = array('required' => trans('error.requerido'), 'email' => trans('error.correo'));
$validar = Validator::make($inputs, $reglas, $mensajes);
if ($validar->fails()) {
//return back('#gracias')->withErrors($validar)->withInput();
return Redirect::to(\LaravelLocalization::getCurrentLocale() . '/' . trans('menu.contacto') . '#about')->withErrors($validar)->withInput();
} else {
$contacto = new Contacto();
$contacto->email = Request::get('correo');
$contacto->save();
$contactName = Request::get('nombre');
$contactEmail = Request::get('correo');
$contactMessage = Request::get('comentarios');
$contactAddres = Request::get('direccion');
$data = array('name' => $contactName, 'email' => $contactEmail, 'description' => $contactMessage, 'addres' => $contactAddres);
Mail::send('layouts.email', $data, function ($message) use($contactEmail, $contactName) {
$message->from($contactEmail, $contactName);
$message->to('contacto@fundacionvivemejor.org', 'Contacto Fundacion Vive Mejor')->subject('Solicitud vía WEB');
$message->cc($contactEmail, $contactName);
});
return Redirect::to(\LaravelLocalization::getCurrentLocale() . '/' . trans('menu.contacto') . '?gracias#gracias');
}
}
示例3: 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);
}
示例4: geturl
function geturl($url, $attributes = array())
{
if (!$url) {
$url = '/';
}
return LaravelLocalization::getLocalizedURL(App::getLocale(), $url, $attributes);
}
示例5: 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'))));
}
示例6: datatable
public function datatable()
{
$pages = $this->model->select('*');
return Datatables::of($pages)->addColumn('action', function ($p) {
return '<a target="_blanc" href="' . LaravelLocalization::getLocalizedURL(App::getLocale(), route('front.page', ['slug' => $p->slug])) . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-search"></i> View</a> <a href="' . action('Dashboard\\PagesController@destroy', ['id' => $p->id]) . '" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-remove"></i> Delete</a>';
})->editColumn('title', function ($p) {
return '<a href="' . action('Dashboard\\PagesController@edit', ['id' => $p->id]) . '">' . $p->title . '</a>';
})->editColumn('created_at', '{!! $created_at->diffForHumans() !!}')->editColumn('updated_at', '{!! $updated_at->diffForHumans() !!}')->make(true);
}
示例7: getSwitchLocale
/**
* @param Request $request
* @param $locale
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function getSwitchLocale(Request $request, $locale)
{
// check if supported
$supportedLanguagesKeys = \LaravelLocalization::getSupportedLanguagesKeys();
if (!in_array($locale, $supportedLanguagesKeys)) {
abort(404);
}
// store in session
session(['someline-locale' => $locale]);
// check if has redirect url
$redirect_url = '/';
if ($request->has('redirect_url')) {
$redirect_url = $request->get('redirect_url');
}
return redirect($redirect_url);
}
示例8: seoURL
public static function seoURL($domain_id, $lang = '')
{
$domain = Domain::find($domain_id);
$clean_chars = function ($string) {
$string = str_replace(' ', '-', $string);
// Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9\\-]/', '', $string);
// Removes special chars.
return preg_replace('/-+/', '-', strtolower($string));
// Replaces multiple hyphens with single one.
};
$domain_name = self::formatDiacritics($clean_chars($domain->name));
if (empty($lang)) {
$lang = LaravelLocalization::getCurrentLocale();
}
return URL::route('domain.details', ['name' => $domain_name, 'id' => $domain->id]);
}
示例9:
<?php
/*
|--------------------------------------------------------------------------
| Language Settings
|--------------------------------------------------------------------------
*/
$lang = null;
if (App::environment() == 'testing') {
$lang = 'fr';
}
LaravelLocalization::setLocale($lang);
示例10: 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-add'));
?>
" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="usr">Заглавие: </label>
<input name="title" type="text" class="form-control" id="usr">
</div>
<input type="hidden" name="_token" value="<?php
echo e(csrf_token());
?>
">
<div class="form-group">
<label for="usr">Кратко описание: </label>
<textarea name='summary' class="form-control" rows="3" id="comment"></textarea>
示例11: route
<li><a href="{{ route('dashboard.index') }}"><i class="fa fa-dashboard"></i> {{ trans('core::core.breadcrumb.home') }}</a></li>
<li><a href="{{ route('admin.site.site.index') }}">{{ trans('site::sites.title.sites') }}</a></li>
<li class="active">{{ trans("site::sites.title.$operation site") }}</li>
</ol>
@stop
@section('styles')
{!! Theme::script('js/vendor/ckeditor/ckeditor.js') !!}
{!! Theme::style('css/vendor/iCheck/flat/blue.css') !!}
@stop
@section('content')
<?php
if (!isset($supportedLocales)) {
$supportedLocales = LaravelLocalization::getSupportedLocales();
}
if (!isset($activeLocale)) {
$allLocales = array_keys($supportedLocales);
$activeLocale = $allLocales[0];
}
?>
{!! Form::open(['route' => ["admin.site.site.$route", $model->id], 'method' => "$method"]) !!}
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">{{ trans('core::core.title.translatable fields') }}</h3>
</div>
示例12:
<!doctype html>
<html lang="ja">
<link href="{{asset("frontend/common/css/import.css")}}" rel="stylesheet" type="text/css" media="all" />
<script src="{{asset('/frontend/common/js/jquery.min.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.bxslider.min.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.rollover.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.flatheights.js')}}"></script>
<script src="{{asset('/frontend/common/js/top.js')}}"></script>
<script src="{{asset('/frontend/common/js/analytics.js')}}"></script>
@include('frontend/element/header')
<body>
<?php
$url = LaravelLocalization::getCurrentLocale() . '/inquiry';
?>
{!! Form::open( ['method' => 'post', 'id'=>'frmContact', 'url' => $url]) !!}
<section id="contact">
<div class="container">
<header>
<h2 style="visibility: visible; animation-name: fadeInDown;" class="wow fadeInDown animated">{{trans('common.lbl_inquiry')}}</h2>
<p style="visibility: visible; animation-delay: 0.1s; animation-name: fadeInUp;" class="wow fadeInUp animated" data-wow-delay="0.1s">{{trans('common.lbl_sub_title')}}
</p>
</header>
<div class="row">
<div class="formrow">
<div class="form-group col-md-3 formleft">
<span>{{trans('common.lbl_inquiry_company')}}</span><span class="icnMust">{{trans('common.icnMust')}}</span>
</div>
<div class="form-group col-md-9">
<input name="company" placeholder="{{trans('common.lbl_inquiry_company')}}" class="form-control" id="company" type="text" value="{{Input::old('company')}}">
示例13: foreach
<link href="{{{ Module::asset('formbuilder:css/styles.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
{!! Form::open(['route' => ['admin.formbuilder.formbuilder.update', $form->id], 'method' => 'put', 'files' => true]) !!}
{!! Form::hidden("id", $form->id) !!}
<div class="row">
<div class="col-xs-12">
<div class="nav-tabs-custom">
@include('partials.form-tab-headers', ['fields' => ['title', 'body']])
<div class="tab-content">
<?php
$i = 0;
?>
<?php
foreach (LaravelLocalization::getSupportedLocales() as $locale => $language) {
?>
<?php
++$i;
?>
<div class="tab-pane {{ App::getLocale() == $locale ? 'active' : '' }}" id="tab_{{ $i }}">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#tab_form_{{ $i }}" aria-expanded="false" onclick="">{!! trans('formbuilder::formbuilder.tab.form') !!}</a>
</li>
<li class="">
<a data-toggle="tab" href="#tab_mail_{{ $i }}" aria-expanded="false" onclick="">{!! trans('formbuilder::formbuilder.tab.mail') !!}</a>
</li>
<li class="">
示例14: function
<?php
/**
* Ajax Routes
*/
Route::group(['prefix' => LaravelLocalization::setLocale() . "/" . LaravelLocalization::transRoute('routes.admin'), 'middleware' => ['localize', 'localeSessionRedirect', 'localizationRedirect']], function () {
Route::get(LaravelLocalization::transRoute('routes.blog') . '/data_blog', 'ChildrenFriendly\\Blog\\Controllers\\PostController@data_blog');
Route::get(LaravelLocalization::transRoute('routes.blog') . '/data_blog_trash', 'ChildrenFriendly\\Blog\\Controllers\\PostController@data_blog_trashed');
});
Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localize', 'localeSessionRedirect', 'localizationRedirect']], function () {
//HOTELS
Route::get(LaravelLocalization::transRoute('routes.admin/blog'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@index');
Route::get(LaravelLocalization::transRoute('routes.admin/blog/trash'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@index(true)');
Route::get(LaravelLocalization::transRoute('routes.admin/blog/new'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@create');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/store'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@store');
Route::get(LaravelLocalization::transRoute('routes.admin/blog/edit'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@edit');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/update'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@update');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/remove'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@destroy');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/remove_force'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@forceDestroy');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/restore'), 'ChildrenFriendly\\Blog\\Controllers\\PostController@restore');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/categories/store'), 'ChildrenFriendly\\Blog\\Controllers\\CategoriesController@store');
Route::get(LaravelLocalization::transRoute('routes.admin/blog/categories/edit'), 'ChildrenFriendly\\Blog\\Controllers\\CategoriesController@edit');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/categories/update'), 'ChildrenFriendly\\Blog\\Controllers\\CategoriesController@update');
Route::post(LaravelLocalization::transRoute('routes.admin/blog/categories/remove'), 'ChildrenFriendly\\Blog\\Controllers\\CategoriesController@destroy');
});
示例15:
<!doctype html>
<html lang="ja">
<link href="{{asset("frontend/common/css/import.css")}}" rel="stylesheet" type="text/css" media="all" />
<script src="{{asset('/frontend/common/js/jquery.min.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.bxslider.min.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.rollover.js')}}"></script>
<script src="{{asset('/frontend/common/js/jquery.flatheights.js')}}"></script>
<script src="{{asset('/frontend/common/js/top.js')}}"></script>
<script src="{{asset('/frontend/common/js/analytics.js')}}"></script>
@include('frontend/element/header')
<body>
<form>
<section id="contact">
<?php
$locale = LaravelLocalization::getCurrentLocale();
?>
<?php
$inquiry = 'frontend/element/locale/' . $locale . '/inquiry';
?>
@include($inquiry)
</section>
</form>
@include('frontend/element/footer')
</body>
</html>