本文整理汇总了PHP中Illuminate\Foundation\Application::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getLocale方法的具体用法?PHP Application::getLocale怎么用?PHP Application::getLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Application
的用法示例。
在下文中一共展示了Application::getLocale方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates new instance.
*
* @param \Illuminate\Foundation\Application $app
* @param \Arcanedev\Localization\Contracts\RouteTranslatorInterface $routeTranslator
* @param \Arcanedev\Localization\Contracts\LocalesManagerInterface $localesManager
*/
public function __construct(Application $app, RouteTranslatorInterface $routeTranslator, LocalesManagerInterface $localesManager)
{
$this->app = $app;
$this->routeTranslator = $routeTranslator;
$this->localesManager = $localesManager;
$this->localesManager->setDefaultLocale($this->app->getLocale());
}
示例2: determine
/**
* Determine the locale for the current module.
*
* @return string
*/
public function determine()
{
$default = $this->app->getLocale();
if ($this->currentSection() === 'auth') {
return $this->isValidBackLocale($this->app->request->segment(1)) ? $this->app->request->segment(1) : $default;
}
if ($this->currentSection() === 'back') {
// User might not be set yet if called in a service provider so a fallback is provided
if ($this->app->auth->user() !== null) {
return $this->app->auth->user()->locale;
}
return $default;
}
return $this->isValidLocale($this->app->request->segment(1)) ? $this->app->request->segment(1) : $default;
}
示例3: initBaseController
/**
* Initialize the base controller sharing important data to all views
*
* @return void
*/
public function initBaseController()
{
$lang = $this->app->getLocale();
$now = $this->carbon->now();
$this->view->share('lang', $lang);
$this->view->share('now', $now);
}
示例4: collectVisitData
/**
* Collects the data for the site view model
*
* @return array
*/
protected function collectVisitData()
{
$request = $this->request;
$user = $request->user();
$userId = $user ? $user->getKey() : null;
return ['user_id' => $userId, 'http_referer' => $request->server('HTTP_REFERER'), 'url' => $request->fullUrl(), 'request_method' => $request->method(), 'request_path' => $request->getPathInfo(), 'http_user_agent' => $request->server('HTTP_USER_AGENT'), 'http_accept_language' => $request->server('HTTP_ACCEPT_LANGUAGE'), 'locale' => $this->app->getLocale(), 'request_time' => $request->server('REQUEST_TIME')];
}
示例5: setDefaultLocale
/**
* Set the default locale.
*
* @param string $defaultLocale
*
* @return self
*/
public function setDefaultLocale($defaultLocale = null)
{
if (is_null($defaultLocale)) {
$defaultLocale = $this->app->getLocale();
}
$this->isDefaultLocaleSupported($defaultLocale);
$this->defaultLocale = $defaultLocale;
// TODO: Refresh locales & supportedLocales collection [Locale entity => default property]
return $this;
}
示例6: __construct
/**
* Prep the PHPTAL object
*
* @param
* $app
*/
public function __construct($app)
{
$this->app = $app;
$this->config = $app['config'];
$this->phptal = new \PHPTAL();
// Override the defaults with information from config file
$preFilters = $this->config->get('phptal.preFilters', []);
$postFilters = $this->config->get('phptal.postFilters', []);
$encoding = $this->config->get('phptal.translationEncoding', 'UTF-8');
$outputMode = $this->config->get('phptal.outputMode', \PHPTAL::HTML5);
$phpCodeDestination = $this->config->get('phptal.phpCodeDestination', $app['path.storage'] . '/framework/views');
$forceReparse = $this->config->get('phptal.forceParse', true);
$templateRepositories = $this->config->get('phptal.templateRepositories', $app['path.base'] . '/resources/views' . (TEMPLATE_ID ? '/' . TEMPLATE_ID : ''));
$translationClass = $this->config->get('phptal.translationClass');
$translationDomain = $this->config->get('phptal.translationDomain', 'messages');
$translationLanguage = [$this->app->getLocale()];
// Setting up translation settings
$this->translationSettings['encoding'] = $encoding;
if (!empty($translationClass)) {
$this->setTranslator($translationLanguage, $translationDomain, $translationClass);
}
// Setting up all the filters
if (!empty($preFilters)) {
foreach ($preFilters as $filter) {
$this->phptal->addPreFilter($filter);
}
}
if (!empty($postFilters)) {
$filterChain = new PHPTALFilterChain();
foreach ($postFilters as $filter) {
$filterChain->add($filter);
}
$this->phptal->setPostFilter($filterChain);
}
$this->phptal->setForceReparse($forceReparse);
$this->phptal->setOutputMode($outputMode);
$this->phptal->setTemplateRepository($templateRepositories);
$this->phptal->setPhpCodeDestination($phpCodeDestination);
}
示例7: getLocale
/**
* Get the current application locale.
*
* @return string
* @static
*/
public static function getLocale()
{
return \Illuminate\Foundation\Application::getLocale();
}
示例8: getCurrentLocale
/**
* Get current locale
*
* @return string
*/
public function getCurrentLocale()
{
return $this->app->getLocale();
}
示例9:
function __construct(Application $app, Store $session)
{
$this->locale = $app->getLocale();
$this->session = $session;
}
示例10: setTimeLocale
/**
* Sets the time locale
*
* @param string $locale
* @return void
*/
public function setTimeLocale($locale = null)
{
$locale = $locale ?: $this->session->get('_locale', $this->app->getLocale());
setlocale(LC_TIME, $this->config->get('translatable.full_locales.' . $locale, null));
Carbon::setLocale($locale);
}
示例11: systemInfo
/**
* @param Application $app
* @return mixed
*/
protected function systemInfo(Application $app)
{
return ['locale' => $app->getLocale(), 'systemLocales' => $this->system_locales()->toArray(), 'locales' => $this->system_locales()->filter(function ($item) {
return $item->activated == true;
})->toArray(), 'systemModules' => $this->system_modules()->toArray()];
}