本文整理汇总了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);
}
示例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);
}
示例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]);
}
示例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;
}
示例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();
}
示例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());
}
示例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);
}
示例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');
}
}
示例9: __construct
public function __construct()
{
$lang = Session::get('locale');
if ($lang != null) {
\App::setLocale($lang);
}
}
示例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'))));
}
示例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);
}
示例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);
}
}
示例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()]);
}
示例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);
}
示例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);
}
}