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


PHP App::setLocale方法代码示例

本文整理汇总了PHP中App::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP App::setLocale方法的具体用法?PHP App::setLocale怎么用?PHP App::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::setLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: page

 public function page($page = FALSE)
 {
     if ($locale = Cookie::get('locale')) {
         App::setLocale($locale);
     }
     if (!$page) {
         return Redirect::to(Lang::get('navigation.consumer'), 301);
     }
     $nav = array();
     foreach (['consumer', 'exporter'] as $item) {
         $loc = Lang::get('navigation.' . $item);
         $link = strtolower(str_replace(' ', '-', $loc));
         if ($link == $page) {
             $page = $item;
         }
         $nav[$link] = ucfirst($loc);
     }
     if (!View::exists('layouts.public.' . $page)) {
         App::abort(404);
     }
     $sub_nav = array();
     $view = View::make('layouts.public.' . $page);
     switch ($page) {
         case 'exporter':
             $sub_nav = ['assortment', 'horticulture', 'certification', 'contact'];
             $picturebox = new Picturebox\PictureboxManager();
             $view->with('picturebox', $picturebox);
             break;
     }
     $view->with('sub_nav', $sub_nav);
     return $view->with('nav', $nav);
 }
开发者ID:crobays,项目名称:paging,代码行数:32,代码来源:PageController.php

示例2: __construct

 public function __construct()
 {
     $this->middleware('ipblocked');
     $driver = config('database.default');
     $database = config('database.connections');
     $this->db = $database[$driver]['database'];
     $this->dbuser = $database[$driver]['username'];
     $this->dbpass = $database[$driver]['password'];
     $this->dbhost = $database[$driver]['host'];
     if (\Auth::check() == true) {
         if (!\Session::get('gid')) {
             \Session::put('uid', \Auth::user()->id);
             \Session::put('gid', \Auth::user()->group_id);
             \Session::put('eid', \Auth::user()->email);
             \Session::put('ll', \Auth::user()->last_login);
             \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name);
             \Session::put('themes', 'sximo-light-blue');
         }
     }
     if (!\Session::get('themes')) {
         \Session::put('themes', 'sximo');
     }
     if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) {
         $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG;
         \App::setLocale($lang);
     }
     $data = array('last_activity' => strtotime(Carbon::now()));
     \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data);
 }
开发者ID:Yashwanth1,项目名称:aregudam,代码行数:29,代码来源:Controller.php

示例3: getTranslation

 /**
  * GET /api/$version/translation/$lang?/$string.
  *
  * @api
  *
  * @return json
  */
 public function getTranslation($lang, $string = null)
 {
     if (!$string) {
         $string = $lang;
         $lang = 'en';
     }
     try {
         App::setLocale($lang);
     } catch (Exception $e) {
         return Response::json(['error' => 'unsupported language']);
     }
     if (strpos($string, ' ')) {
         // dealing with an array
         $strings = explode(' ', $string);
         $translation = [];
         foreach ($strings as $str) {
             $translation[$str] = Lang::get($str);
         }
     } else {
         // single strings allow for fallback to english.
         // multiples would involve too much
         $translation = Lang::get($string);
         if ($translation == $string and $lang != 'en') {
             App::setLocale(Config::get('app.locale', 'en'));
             $translation = Lang::get($string);
         }
     }
     return Response::json(['translation' => $translation]);
 }
开发者ID:echojc,项目名称:osu-web,代码行数:36,代码来源:APIController.php

示例4: run

 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors
     // The most problem is $output->getFormatter() don't work.
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     \App::setLocale(\Config::get('syncle::MessageLang'));
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
     }
     return $result;
 }
开发者ID:hirokws,项目名称:syncle,代码行数:39,代码来源:BaseCommand.php

示例5: boot

 /**
  *
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/../../views', 'admin-lte');
     $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'admin');
     $this->mergeConfigFrom(__DIR__ . '/../../config/config.php', 'admin');
     $this->mergeConfigFrom(__DIR__ . '/../../config/theme.php', 'admintheme');
     $this->publishes([__DIR__ . '/../../config/config.php' => config_path('admin.php'), __DIR__ . '/../../config/theme.php' => config_path('admintheme.php')], 'config');
     // Publish migrations
     $migrations = realpath(__DIR__ . '/Database/Migrations');
     $this->publishes([$migrations => $this->app->databasePath() . '/migrations'], 'migrations');
     $this->publishes([__DIR__ . '/../../../public/' => public_path('vendor/sleeping-owl/admin/')], 'assets');
     //we need this, otherwise we have no access to existing session values
     //like the applocale which will be used to set the app language correctly
     app('SleepingOwl\\Admin\\Helpers\\StartSession')->run();
     if (\Config::get('admin.language_switcher') && \Session::has('applocale') && array_key_exists(\Session::get('applocale'), \Config::get('admin.languages'))) {
         \App::setLocale(\Session::get('applocale'));
     } else {
         // This is optional as Laravel will automatically set the fallback language if there is none specified
         \App::setLocale(\Config::get('app.fallback_locale'));
     }
     Admin::instance();
     $this->registerTemplate();
     $this->registerProviders();
     $this->initializeTemplate();
 }
开发者ID:vuthaihoc,项目名称:soa-sentinel,代码行数:28,代码来源:AdminServiceProvider.php

示例6: __construct

 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     $is_admin = Request::is('admin*');
     $is_backend = Request::is('backend*');
     /* Set middleware(s) based on route URLs */
     if ($is_admin || $is_backend) {
         $this->middleware('auth');
         if ($is_backend) {
             // Backend specific middleware
             $this->middleware('auth.backend');
         }
         $this->middleware('auth.permissions');
         if (!Request::is('*users/change-password')) {
             // No validation for stale password if password is being changed
             $this->middleware('auth.pw_6_months');
         }
     }
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name')->all();
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
开发者ID:doptor,项目名称:doptor,代码行数:35,代码来源:BaseController.php

示例7: configureLocale

 /**
  * Detect and set application localization environment (language).
  * NOTE: Don't foreget to ADD/SET/UPDATE the locales array in app/config/app.php!
  *
  */
 private function configureLocale()
 {
     $mLocale = Config::get('app.locale');
     if (!Session::has('locale')) {
         $mFromCookie = Cookie::get('locale', null);
         if ($mFromCookie != null && in_array($mFromCookie, Config::get('app.locales'))) {
             $mLocale = $mFromCookie;
         } else {
             $mFromURI = Request::segment(1);
             if ($mFromURI != null && in_array($mFromURI, Config::get('app.locales'))) {
                 $mLocale = $mFromURI;
             } else {
                 $mFromBrowser = substr(Request::server('http_accept_language'), 0, 2);
                 if ($mFromBrowser != null && in_array($mFromBrowser, Config::get('app.locales'))) {
                     $mLocale = $mFromBrowser;
                 }
             }
         }
         Session::put('locale', $mLocale);
         Cookie::forever('locale', $mLocale);
     } else {
         $mLocale = Session::get('locale');
     }
     App::setLocale($mLocale);
 }
开发者ID:bizcoine,项目名称:ecoinstrader,代码行数:30,代码来源:BaseController.php

示例8: __construct

 public function __construct()
 {
     /* Set the Language Based on Agent Browser */
     $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
     $lang = substr($languages[0], 0, 2);
     App::setLocale($lang);
     /* Load Assets */
     Asset::add('bootstraptheme', 'assets/css/bootstrap-spacelab.css');
     Asset::add('bootstrapresponsive', 'assets/css/bootstrap-responsive.css');
     Asset::add('charisma', 'assets/css/charisma-app.css');
     Asset::add('uniform', 'assets/css/uniform.default.css');
     Asset::add('elfinder', 'assets/css/elfinder.min.css');
     Asset::add('opaicons', 'assets/css/opa-icons.css');
     Asset::add('famfam', 'assets/css/famfam.css');
     Asset::add('jqueryloadermin', 'assets/css/jquery.loader-min.css');
     Asset::add('reportula', 'assets/css/reportula.css');
     Asset::add('jquery', 'assets/js/jquery-2.0.3.min.js');
     Asset::add('datatables', 'assets/js/jquery.dataTables.min.js', 'jquery');
     Asset::add('jqueryloader', 'assets/js/jquery.loader-min.js', 'jquery');
     Asset::add('main', 'assets/js/main.js', 'TableTools');
     Asset::add('modal', 'assets/js/bootstrap-modal.js', 'jquery');
     /* Get Monolog instance from Laravel */
     $monolog = Log::getMonolog();
     /* Add the FirePHP handler */
     $monolog->pushHandler(new \Monolog\Handler\FirePHPHandler());
     /* Resolve Database Names Myslq and Postgres */
     if (Config::get('database.default') == 'mysql') {
         $this->tables = array('job' => 'Job', 'client' => 'Client', 'files' => 'Files', 'media' => 'Media', 'pool' => 'Pool', 'path' => 'Path', 'filename' => 'Filename', 'file' => 'File', 'jobfiles' => 'JobFiles', 'jobmedia' => 'JobMedia');
     } else {
         $this->tables = array('job' => 'job', 'client' => 'client', 'files' => 'files', 'media' => 'media', 'pool' => 'pool', 'path' => 'path', 'filename' => 'filename', 'file' => 'file', 'jobfiles' => 'jobfiles', 'jobmedia' => 'jobmedia');
     }
 }
开发者ID:erpio,项目名称:Reportula,代码行数:32,代码来源:BaseController.php

示例9: __construct

 public function __construct()
 {
     $lang = Session::get('locale');
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
开发者ID:quannh02,项目名称:thuexeweb,代码行数:7,代码来源:LangController.php

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

示例11: handle

 public function handle($request, \Closure $next)
 {
     if ($request->has('language')) {
         $request->session()->put('language', $request->get('language'));
     }
     \App::setLocale($request->session()->get('language') ?: config('app.locale'));
     return $next($request);
 }
开发者ID:stjanilofts,项目名称:normx,代码行数:8,代码来源:KalUpdateLocale.php

示例12: __construct

 /**
  * Create a new filter instance.
  * @param  Guard $auth
  * @return void
  */
 public function __construct(Guard $auth)
 {
     $this->auth = $auth;
     $lang = Session::get('locale');
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
开发者ID:sumitglobussoft,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:13,代码来源:Authenticate.php

示例13: indexAction

 public function indexAction($sub)
 {
     App::setLocale("en");
     if (Input::get("lang") === "nl") {
         App::setLocale("nl");
     }
     return View::make("index/index", ["post" => Post::first()]);
 }
开发者ID:fajars87,项目名称:tutorial-laravel-4-multisites,代码行数:8,代码来源:IndexController.php

示例14: testAcTrans

 public function testAcTrans()
 {
     $defaultErrorMessage = ac_trans("messages.unauthorized.default");
     $this->assertEquals('You are not authorized to access this page.', $defaultErrorMessage);
     App::setLocale('fr');
     $defaultErrorMessageFr = ac_trans("messages.unauthorized.default");
     $this->assertNotEquals('You are not authorized to access this page.', $defaultErrorMessageFr);
     $this->assertEquals("Vous n'êtes pas autorisé à accéder à cette page.", $defaultErrorMessageFr);
 }
开发者ID:abada,项目名称:authority-controller,代码行数:9,代码来源:AcHelpersTest.php

示例15: __construct

 /**
  * Create a new filter instance.
  *
  * @param  Guard  $auth
  * @return void
  */
 public function __construct(Guard $auth)
 {
     $this->auth = $auth;
     $lang = \Session::get('user_locale');
     //        echo'<pre>';print_r($lang);die("dxsvg");
     if ($lang != null) {
         \App::setLocale($lang);
     }
 }
开发者ID:sumitglobussoft,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:15,代码来源:RedirectIfAuthenticated.php


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