当前位置: 首页>>代码示例>>PHP>>正文


PHP Carbon::setLocale方法代码示例

本文整理汇总了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);
 }
开发者ID:sibasbo,项目名称:sibas,代码行数:7,代码来源:Facultative.php

示例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);
     }
 }
开发者ID:karpuzkan,项目名称:laravel,代码行数:31,代码来源:ConfigMiddleware.php

示例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');
 }
开发者ID:iris-it,项目名称:irispass-webapp-laravel,代码行数:10,代码来源:OrganizationController.php

示例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);
 }
开发者ID:blomdahldaniel,项目名称:laravel-5-boilerplate,代码行数:40,代码来源:LocaleMiddleware.php

示例5: boot

 public function boot()
 {
     view()->composer('*', function ($view) {
         $view->with('authenticatedUser', Auth::user());
     });
     Carbon::setLocale('fr');
 }
开发者ID:otsaan,项目名称:e-blog,代码行数:7,代码来源:AppServiceProvider.php

示例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'));
 }
开发者ID:sewede,项目名称:footipp,代码行数:7,代码来源:TippsController.php

示例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);
 }
开发者ID:someline,项目名称:starter-framework,代码行数:35,代码来源:LocaleMiddleware.php

示例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;
     }
 }
开发者ID:Okipa,项目名称:una.app,代码行数:33,代码来源:Controller.php

示例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());
 }
开发者ID:jrafaelca,项目名称:kitchen_manager,代码行数:10,代码来源:BaseController.php

示例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');
     }
 }
开发者ID:blomdahldaniel,项目名称:laravel-5-boilerplate,代码行数:30,代码来源:AppServiceProvider.php

示例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);
     }
 }
开发者ID:zjean,项目名称:firefly-iii,代码行数:29,代码来源:Controller.php

示例12: __construct

 public function __construct()
 {
     $this->middleware('auth');
     $this->middleware('hasOrganization');
     $this->organization = Auth::user()->organization()->first();
     Carbon::setLocale('fr');
 }
开发者ID:iris-it,项目名称:irispass-webapp-laravel,代码行数:7,代码来源:UsersManagementController.php

示例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);
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:33,代码来源:Authenticate.php

示例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);
 }
开发者ID:nova-framework,项目名称:system,代码行数:13,代码来源:LanguageManager.php

示例15: __construct

 public function __construct()
 {
     // Set Carbon locale
     Carbon::setLocale(app()->getLocale());
     // Share current locale to Views
     view()->share('locale', app()->getLocale());
 }
开发者ID:lbausch,项目名称:laravel-cornerstone,代码行数:7,代码来源:CornerstoneController.php


注:本文中的Carbon\Carbon::setLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。