本文整理汇总了PHP中Carbon\Carbon::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::setLocale方法的具体用法?PHP Carbon::setLocale怎么用?PHP Carbon::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::setLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDateAdmissionAttribute
public function getDateAdmissionAttribute()
{
$now = new Carbon();
$dt = new Carbon($this->created_at);
$dt->setLocale('es');
return $dt->diffForHumans($now);
}
示例2: __construct
public function __construct()
{
// Carbon Language
Carbon::setLocale('tr');
// create home page if non exist
count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null;
// create config file if non exist
!\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => 'info@brand.com', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null;
$this->config = json_decode(\File::get(storage_path('.config')));
!\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null;
!\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null;
// get css & js files from custom folder
// css
$css = \File::allFiles(storage_path('app/custom/css'));
if (!empty($css)) {
foreach ($css as $cs) {
$this->css[$cs->getCtime()] = $cs->getRelativePathname();
}
// sort by date
ksort($this->css);
}
// js
$js = \File::allFiles(storage_path('app/custom/js'));
if (!empty($js)) {
foreach ($js as $j) {
$this->js[$j->getCtime()] = $j->getRelativePathname();
}
// sort by date
ksort($this->js);
}
}
示例3: __construct
/**
* @internal param UserRepositoryInterface $userRepository
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('hasOrganization', ['except' => ['index', 'create', 'store']]);
$this->organization = Auth::user()->organization()->first();
Carbon::setLocale('fr');
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/**
* Locale is enabled and allowed to be changed
*/
if (config('locale.status')) {
if (session()->has('locale') && in_array(session()->get('locale'), array_keys(config('locale.languages')))) {
/**
* Set the Laravel locale
*/
app()->setLocale(session()->get('locale'));
/**
* setLocale for php. Enables ->formatLocalized() with localized values for dates
*/
setLocale(LC_TIME, config('locale.languages')[session()->get('locale')][1]);
/**
* setLocale to use Carbon source locales. Enables diffForHumans() localized
*/
Carbon::setLocale(config('locale.languages')[session()->get('locale')][0]);
/**
* Set the session variable for whether or not the app is using RTL support
* for the current language being selected
* For use in the blade directive in BladeServiceProvider
*/
if (config('locale.languages')[session()->get('locale')][2]) {
session(['lang-rtl' => true]);
} else {
session()->forget('lang-rtl');
}
}
}
return $next($request);
}
示例5: boot
public function boot()
{
view()->composer('*', function ($view) {
$view->with('authenticatedUser', Auth::user());
});
Carbon::setLocale('fr');
}
示例6: index
public function index()
{
Carbon::setLocale('de');
setlocale(LC_TIME, 'de_DE.utf8');
$myTipps = Tipp::join('matches', 'tipps.match_id', '=', 'matches.id')->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.home_goals as erg1', 'matches.away_goals as erg2', 'matches.date', 'tipps.*', 'homeclub.club as home', 'awayclub.club as away')->where('tipps.user_id', '=', Auth::id())->orderBy('date')->get();
return view('pages.tipps', compact('myTipps'));
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// get supported locales
$supportedLocales = LaravelLocalization::getSupportedLocales();
// 1. get current locale
$locale = LaravelLocalization::getCurrentLocale();
// 2. check from session
$sessionLocale = session('someline-locale');
if (!empty($sessionLocale)) {
// if supported
if (is_array($supportedLocales) && isset($supportedLocales[$sessionLocale])) {
$locale = $sessionLocale;
}
}
// 3. check from lang
$lang = $request->get('lang');
if (!empty($lang)) {
// if supported
if (is_array($supportedLocales) && isset($supportedLocales[$lang])) {
$locale = $lang;
}
}
// set locale
LaravelLocalization::setLocale($locale);
// set carbon locale
Carbon::setLocale($locale);
return $next($request);
}
示例8: __construct
/**
* Controller constructor.
*/
public function __construct()
{
// load base JS
JavaScript::put(['csrf_token' => csrf_token(), 'base_url' => url('/'), 'app_name' => config('settings.app_name_' . config('app.locale')), 'loading_spinner' => config('settings.loading_spinner'), 'success_icon' => config('settings.success_icon'), 'error_icon' => config('settings.error_icon'), 'info_icon' => config('settings.info_icon'), 'locale' => config('app.locale'), 'multilingual' => config('settings.multilingual')]);
// load modal if an alert is waiting
if (session()->get('alert')) {
JavaScript::put(['modal_alert' => true]);
}
// we set the og meta title
$this->og_meta['og:site_name'] = config('settings.app_name_' . config('app.locale'));
// we manage the locale dependencies
switch (config('app.locale')) {
case 'fr':
// server locale
setlocale(LC_TIME, 'fr_FR.UTF-8');
// carbon locale
Carbon::setLocale('fr');
// og locale
$this->og_meta['og:locale'] = 'fr_FR';
break;
case 'en':
// server locale
setlocale(LC_TIME, 'en_GB.UTF-8');
// carbon locale
Carbon::setLocale('en');
// og locale
$this->og_meta['og:locale'] = 'en_GB';
break;
}
}
示例9: __construct
/**
*
*/
public function __construct()
{
Carbon::setLocale('es');
view()->share('background', $this->setBackground());
view()->share('main_menu', $this->mainMenu());
view()->share('admin_menu', $this->adminMenu());
}
示例10: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
/**
* Application locale defaults for various components
*
* These will be overridden by LocaleMiddleware if the session local is set
*/
/**
* setLocale for php. Enables ->formatLocalized() with localized values for dates
*/
setLocale(LC_TIME, config('app.locale_php'));
/**
* setLocale to use Carbon source locales. Enables diffForHumans() localized
*/
Carbon::setLocale(config('app.locale'));
/**
* Set the session variable for whether or not the app is using RTL support
* For use in the blade directive in BladeServiceProvider
*/
if (config('locale.languages')[config('app.locale')][2]) {
session(['lang-rtl' => true]);
} else {
session()->forget('lang-rtl');
}
}
示例11: __construct
/**
* Controller constructor.
*/
public function __construct()
{
View::share('hideBudgets', false);
View::share('hideCategories', false);
View::share('hideBills', false);
View::share('hideTags', false);
if (Auth::check()) {
$pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'));
$lang = $pref->data;
$this->monthFormat = (string) trans('config.month');
$this->monthAndDayFormat = (string) trans('config.month_and_day');
App::setLocale($lang);
Carbon::setLocale(substr($lang, 0, 2));
$locale = explode(',', trans('config.locale'));
$locale = array_map('trim', $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MONETARY, $locale);
// change localeconv to a new array:
$numberFormatter = numfmt_create($lang, NumberFormatter::CURRENCY);
$localeconv = ['mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)), 'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)), 'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)];
View::share('monthFormat', $this->monthFormat);
View::share('monthAndDayFormat', $this->monthAndDayFormat);
View::share('language', $lang);
View::share('localeconv', $localeconv);
}
}
示例12: __construct
public function __construct()
{
$this->middleware('auth');
$this->middleware('hasOrganization');
$this->organization = Auth::user()->organization()->first();
Carbon::setLocale('fr');
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
/** @var User $user */
$user = $this->auth->user();
if ($user instanceof User && intval($user->blocked) == 1) {
Auth::logout();
return redirect()->route('index');
}
// if logged in, set user language:
$pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'));
App::setLocale($pref->data);
Carbon::setLocale(substr($pref->data, 0, 2));
$locale = explode(',', trans('config.locale'));
$locale = array_map('trim', $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MONETARY, $locale);
return $next($request);
}
示例14: setLocale
/**
* Set the default locale.
*
* @param string $locale
* @return void
*/
public function setLocale($locale)
{
$this->locale = $locale;
//
setlocale(LC_ALL, $locale);
Carbon::setLocale($locale);
}
示例15: __construct
public function __construct()
{
// Set Carbon locale
Carbon::setLocale(app()->getLocale());
// Share current locale to Views
view()->share('locale', app()->getLocale());
}