本文整理汇总了PHP中App::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP App::getLocale方法的具体用法?PHP App::getLocale怎么用?PHP App::getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::getLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showIndex
public function showIndex()
{
$page = $this->node;
$tree = Collector::get('root');
$subTree = Tree::getSubTree($tree, $page);
$blocks = null;
if ($subTree) {
$blocks = $subTree->children;
}
foreach ($blocks as $index => $block) {
$blocks[$block->slug] = $block;
unset($blocks[$index]);
}
if (isset($blocks['reporting'])) {
$blocks['reporting']->children = $blocks['reporting']->children->reverse();
$reporting = $blocks['reporting'];
}
$flatArticles = Cache::tags('j_tree')->rememberForever('about_flat_articles_' . App::getLocale(), function () use($page) {
return $page->immediateDescendants()->active()->get();
});
$articles = array();
foreach ($flatArticles as $article) {
$articles[$article->slug] = $article;
}
$pressSections = null;
if (isset($articles['press']) && $articles['press']->count()) {
$pressSubTree = Tree::getSubTree($tree, $articles['press']);
if ($pressSubTree) {
$pressSections = $pressSubTree->children;
}
}
return View::make('about.index', compact('page', 'reporting', 'articles', 'pressSections'));
}
示例2: onStart
public function onStart()
{
if (App::getLocale() == 'en') {
header("Location: /semen-selling");
die;
}
}
示例3: baseUrl
function baseUrl()
{
$fallback = Config::get('app.fallback_locale');
$lang = App::getLocale();
$locale = $lang == $fallback ? '' : '/' . $lang;
return url() . $locale;
}
示例4: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$c = strtolower($this->argument('controller'));
$files = [];
$files[] = mkny_models_path($c) . '.php';
$files[] = mkny_model_config_path($c) . '.php';
$files[] = mkny_presenters_path($c) . 'Presenter.php';
$files[] = mkny_controllers_path($c) . 'Controller.php';
$files[] = mkny_requests_path($c) . 'Request.php';
$files[] = mkny_lang_path(\App::getLocale() . '/' . $c) . '.php';
$errors = [];
foreach ($files as $file) {
if (!$this->files->exists($file)) {
$errors[] = $file;
}
}
if (!$this->option('force') && count($errors)) {
$this->error("Nao foi possivel executar o delete-automatico!\nAlguns arquivos estao ausentes!");
} else {
if ($this->option('force') || $this->confirm("Deseja realmente remover os arquivos: \n'" . implode("',\n'", $files))) {
foreach ($files as $file) {
$this->files->delete($file);
}
$this->info('Deleted!');
}
}
}
示例5: store
/**
* store created user
*
* @param UsersFormRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(UsersFormRequest $request)
{
$data = $request->all();
$user = $this->userRepository->create($data);
$user->attachRole($request->get('role'));
return redirect()->to(\App::getLocale() . '/admin/users');
}
示例6: getAttribute
public function getAttribute($key)
{
if (!isset($this->localizedFields) or !in_array($key, $this->localizedFields)) {
return parent::getAttribute($key);
}
return $this->getTranslation($key, \App::getLocale());
}
示例7: getHome
public function getHome()
{
Session::put('old_RequestSegment2', '');
//is root?
//if (Request::is('/') && Locale::countEnable() > 1) return Redirect::to('/' . App::getLocale(), 301);
//is OnePage?
if (Config::get('core::display.onepage')) {
$data = array();
$data['onepage'] = OnePage::first();
return View::make('theme::public.onepage', $data);
} else {
//Find good page
$urls = Urls::getRoutes();
foreach ($urls as $url) {
if ($url['url'] == '/' && $url['locale_id'] == App::getLocale()) {
$structure = Structure::where('i18n_url', $url['i18n_id'])->first();
if (!empty($structure)) {
if ($structure->structurable_type != 'OnePage') {
$page = $structure->structurable;
return View::make('pager::public.pages.page', compact('page'));
}
}
}
}
return App::abort(404);
}
}
示例8: setUpRoutes
/**
* @param \Illuminate\Foundation\Application $app
*/
protected function setUpRoutes($app)
{
\Route::get('/', ['middleware' => 'localize', function () {
return 'Whoops';
}]);
\Route::get('/ca', ['middleware' => 'localize', function () {
return 'Whoops ca';
}]);
\Route::post('/', ['middleware' => 'localize', function () {
return 'POST answer';
}]);
\Route::get('/es', ['middleware' => 'localize', function () {
return 'Hola mundo';
}]);
\Route::get('/en', ['middleware' => 'localize', function () {
return 'Hello world';
}]);
\Route::get('/en/locale', ['middleware' => 'localize', function () {
return \App::getLocale();
}]);
\Route::get('/es/locale', ['middleware' => 'localize', function () {
return \App::getLocale();
}]);
\Route::get('/api/v1/en/locale', ['middleware' => 'localize:2', function () {
return \App::getLocale();
}]);
\Route::get('/api/v1/es/locale', ['middleware' => 'localize:2', function () {
return \App::getLocale();
}]);
\Route::get('/api/v1/ca/locale', ['middleware' => 'localize:2', function () {
return 'Whoops ca';
}]);
}
示例9: getLangSwitch
function getLangSwitch()
{
$local = App::getLocale();
$host = Config::get('app.host');
$fr = '/fr';
$de = '/de';
$en = '/en';
if ($host == 'convergedmaturity.com' || $host == 'convergedmaturity.co.uk' || $host == 'certus.convergedmaturity.co.uk' || $host == 'dellconverged.app' || $host == 'itf.convergedmaturity.com' || $host == 'infoniqa.convergedmaturity.com') {
$en = '';
} elseif ($host == 'convergedmaturity.fr') {
$fr = '';
} elseif ($host == 'bereit-fuer-konvergente-infrastruktur.de' || $host == 'niteflite.bereit-fuer-konvergente-infrastruktur.de') {
$de = '';
}
switch ($local) {
case 'en':
return "\n\t\t\t<li><a href=" . Request::root() . $fr . "><i class=\"flag fr\"></i> French</a></li>\n\t\t\t<li><a href=" . Request::root() . $de . "><i class=\"flag de\"></i> German</a></li>\n\t\t\t";
break;
case 'fr':
return "\n\t\t\t<li><a href=" . Request::root() . $en . "><i class=\"flag\"></i> English</a></li>\n\t\t\t<li><a href=" . Request::root() . $de . "><i class=\"flag de\"></i> German</a></li>\n\t\t\t";
break;
case 'de':
return "\n\t\t\t<li><a href=" . Request::root() . $en . "><i class=\"flag\"></i> English</a></li>\n\t\t\t<li><a href=" . Request::root() . $fr . "><i class=\"flag fr\"></i> French</a></li>\n\t\t\t";
break;
}
}
示例10: registerRoutes
private function registerRoutes()
{
Route::get('/account', MainController::class . '@index');
Route::get('/account/forms/fields', MainController::class . '@forms');
Route::post('/account/forms/user', MainController::class . '@formUser');
Route::post('/account/forms/password', MainController::class . '@formPassword');
Route::post('/account/forms/card/save', MainController::class . '@formCardSave');
Route::post('/account/forms/autopay/save', MainController::class . '@formAutopaySave');
Route::post('/account/forms/card/remove', MainController::class . '@formCardRemove');
Route::get('/account/orders', MainController::class . '@orders');
Route::get('/account/history', MainController::class . '@history');
Route::get('/account/order/{id}', MainController::class . '@order');
Route::get('/account/order/services/{id}', MainController::class . '@orderServices');
Route::get('/account/order/services/pdf/{id}', MainController::class . '@orderServicesPdf');
Route::get('/account/pay/init/{id}/{target}/{reset}', MainController::class . '@pay');
Route::get('/account/new_card', MainController::class . '@newCard');
Route::post('/account/delete_card', MainController::class . '@deleteCard');
Route::post('/account/autopay', MainController::class . '@autopay');
Route::post('/account/pay_finish', MainController::class . '@payFinish');
Route::get('/account/pay/card', MainController::class . '@card');
Route::get('/account/prepayment', MainController::class . '@prepayment');
Route::post('/account/pay_by_token', MainController::class . '@payByToken');
Route::get('/account/pay/check/{id}', MainController::class . '@checkPay');
Route::post('/account/pay/token', MainController::class . '@token');
Route::post('/account/pay/refund', MainController::class . '@refund');
Route::get('/account/flash/message/{type}', ServiceController::class . '@flash');
Route::get('/account/bonus', MainController::class . '@bonus');
Route::get('/account/order/review/{id}', MainController::class . '@review');
Route::post('/account/order/review', MainController::class . '@reviewOrder');
Route::get('/account/subscriptions', MainController::class . '@subscriptions');
Route::get('/account/customers_cards', MainController::class . '@customersCards');
Route::get('/account/lang/{lang}', ['as' => 'lang.set', 'before' => 'lang.set', function () {
return App::getLocale();
}]);
}
示例11: comments
public function comments($params = array())
{
$settings = array();
$language = false;
$settings['disqus_shortname'] = $this->config->get('laravel-disqus::disqus_shortname');
if (isset($params['disqus_identifier'])) {
$settings['disqus_identifier'] = $params['disqus_identifier'];
}
if (isset($params['disqus_title'])) {
$settings['disqus_title'] = $params['disqus_title'];
}
if (isset($params['disqus_url'])) {
$settings['disqus_url'] = $params['disqus_url'];
}
if (isset($params['disqus_category_id'])) {
$settings['disqus_category_id'] = $params['disqus_category_id'];
}
if (true === $this->config->get('laravel-disqus::auto_set_language')) {
$language = $this->getDisqusLanguage(\App::getLocale());
}
if (isset($params['language'])) {
$language = $params['language'];
}
return \View::make('laravel-disqus::disqus.comments', array('settings' => $settings, 'language' => $language));
}
示例12: geturl
function geturl($url, $attributes = array())
{
if (!$url) {
$url = '/';
}
return LaravelLocalization::getLocalizedURL(App::getLocale(), $url, $attributes);
}
示例13: translate
public function translate($filename, $to)
{
$tc = new TranslateClient();
$tc->setSource(\App::getLocale());
$tc->setTarget($to);
if ($this->hasConnection()) {
if (file_exists(base_path() . '\\resources\\lang\\' . \App::getLocale() . '\\' . $filename . '.php')) {
if ($this->isValidLocale($to)) {
$array = $this->getWordsForTranslate($filename);
$afterTranslate = [];
foreach ($array as $key => $word) {
$afterTranslate[$key] = $tc->translate($word);
}
if (!file_exists(base_path() . '\\resources\\lang\\' . $to)) {
mkdir(base_path() . '\\resources\\lang\\' . $to, 0777, true);
}
$content = '<?php ' . PHP_EOL . 'return' . PHP_EOL . var_export($afterTranslate, true) . '; ?>';
$this->setFileContent($content, $filename, $to);
} else {
throw new \Exception('The location is invalid for option --to');
}
} else {
throw new \Exception('This file name does not exist in the language directory.');
}
} else {
throw new \Exception('Error! Check your internet connection!');
}
}
示例14: day_localize
function day_localize($day, $is = "en", $localize = "tr")
{
$localize = \App::getLocale();
$days['locale']['D'] = [trans('whole::http/helpers.monday'), trans('whole::http/helpers.tuesday'), trans('whole::http/helpers.wednesday'), trans('whole::http/helpers.thursday'), trans('whole::http/helpers.friday'), trans('whole::http/helpers.saturday'), trans('whole::http/helpers.sunday')];
$days['en']['D'] = ['Monday ', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
return $days['locale']['D'][array_search($day, $days[$is]['D'])];
}
示例15: checkLocale
protected function checkLocale()
{
$locale = \App::getLocale();
if ($this->locale != $locale) {
$this->locale = $locale;
}
}