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


PHP Lang::locale方法代码示例

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


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

示例1: ensureBackwardsCompatibility

 protected function ensureBackwardsCompatibility($messages)
 {
     if (preg_match('/^\\{"[a-z]{2}":/', $messages)) {
         return $messages;
     } else {
         return '{"' . Lang::locale() . '":' . $messages . '}';
     }
 }
开发者ID:natharduini,项目名称:laravel-js-localization,代码行数:8,代码来源:JsLocalizationController.php

示例2: __

function __($phrase, array $replacePhrase = [])
{
    $thisLang = Lang::locale();
    $arrayTranslate = Trans::fillCacheTrans();
    if (isset($arrayTranslate[$phrase][$thisLang])) {
        $phrase = $arrayTranslate[$phrase][$thisLang];
    } else {
        $phrase = Trans::generateTranslation($phrase, $thisLang);
    }
    if (count($replacePhrase)) {
        $phrase = str_replace(array_keys($replacePhrase), array_values($replacePhrase), $phrase);
    }
    return $phrase;
}
开发者ID:arturishe21,项目名称:translations,代码行数:14,代码来源:helpers.php

示例3: index

 public function index()
 {
     $model = $this->settings->model;
     $this->data['sortby'] = Input::get('sortby');
     $this->data['order'] = Input::get('order');
     if (property_exists($model, 'translable')) {
         $model = $model::where('lang', \Lang::locale());
     }
     if ($this->data['sortby'] && $this->data['order']) {
         $this->data['entries'] = $model::orderBy($this->data['sortby'], $this->data['order'])->paginate($this->settings->rowsPerPage);
     } else {
         $this->data['entries'] = $model::paginate($this->settings->rowsPerPage);
     }
     if (!empty($this->settings->list_view) && view()->exists($this->settings->list_view)) {
         return view($this->settings->list_view, $this->data);
     } else {
         return view($this->list_view, $this->data);
     }
 }
开发者ID:ktincheva,项目名称:crud_package,代码行数:19,代码来源:CRUDController.php

示例4: make

 /**
  * The actual HTML creation of the field.
  *
  * @return string
  */
 function make()
 {
     // Set options (parameters)
     foreach (self::$availableOptions as $opt) {
         if ($this->field->{$opt}) {
             $this->addData($opt, $this->field->{$opt});
         }
     }
     $format = $this->field->format;
     if (!$format) {
         $format = "";
         $format .= $this->field->has_date !== false ? trans('sharp::format.date_inputFormat') : "";
         $format .= $this->field->has_time ? (strlen($format) ? " " : "") . trans('sharp::format.time_inputFormat') : "";
         $this->addData("format", $format);
     }
     $this->addData("lang", \Lang::locale());
     // Valuate field (date formatting according to declared format)
     $fieldValue = null;
     if ($this->fieldValue) {
         $d = strtotime($this->fieldValue);
         if ($d) {
             $fieldValue = date($format, $d);
         }
     }
     if (!$this->instance && $this->isListItem) {
         // No instance and part of a list item : this field is meant to be in the template item.
         // In this case, we don't set the "sharp-date" class which will trigger the JS code for
         // the date component creation
         $this->addClass("sharp-date-template");
     } else {
         // Regular case
         $this->addClass("sharp-date");
     }
     // Auto-populate the real sent field
     $str = Form::hidden($this->fieldName, $this->fieldValue, ["class" => "sharp-date-timestamp", "autocomplete" => "off"]);
     // And populate with formatted date the visible input field
     $str .= Form::text("__date__" . $this->fieldName, $fieldValue, $this->attributes);
     return $str;
 }
开发者ID:dvlpp,项目名称:sharp,代码行数:44,代码来源:DateField.php

示例5: showDetailsRow

 /**
  * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table.
  * It defaults to showing all connected translations and their CRUD buttons.
  *
  * It's enabled by:
  * - setting the $crud['details_row'] variable to true;
  * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow');
  */
 public function showDetailsRow($id)
 {
     // get the info for that entry
     $model = $this->crud['model'];
     $this->data['entry'] = $model::find($id);
     $this->data['entry']->addFakes($this->getFakeColumnsAsArray());
     $this->data['original_entry'] = $this->data['entry'];
     $this->data['crud'] = $this->crud;
     if (property_exists($model, 'translatable')) {
         $this->data['translations'] = $this->data['entry']->translations();
         // create a list of languages the item is not translated in
         $this->data['languages'] = \Dick\TranslationManager\Models\Language::all();
         $this->data['languages_already_translated_in'] = $this->data['entry']->translationLanguages();
         $this->data['languages_to_translate_in'] = $this->data['languages']->diff($this->data['languages_already_translated_in']);
         $this->data['languages_to_translate_in'] = $this->data['languages_to_translate_in']->reject(function ($item) {
             return $item->abbr == \Lang::locale();
         });
     }
     // load the view from /resources/views/vendor/dick/crud/ if it exists, otherwise load the one in the package
     return $this->firstViewThatExists('vendor.dick.crud.details_row', 'crud::details_row', $this->data);
 }
开发者ID:hramose,项目名称:crud,代码行数:29,代码来源:CrudController.php

示例6: explode

<?php

$lang = Lang::locale();
$url = explode('/', Request::url());
$url = implode('/', array_slice($url, 4));
?>
<!doctype html>
<html>
    <head>
        <base href="{{ url('/') }}">
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>@yield('title') | Landoretti</title>
        <link rel="icon" href="img/favicon.ico">
        <link rel="stylesheet" href="/css/normalize.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <link rel="stylesheet" href="/css/style.css">
    </head>
    <body>
        <header>
        	<img src="/img/Logo.gif" alt="Landoretti logo" class="logo">
        	@include('layout.adminbar')
        	@include('layout.navbar')
        </header>
        <main>
    		@yield('content')
        </main>
        <footer>
            @include('layout.footer')
        </footer>
开发者ID:timpressive,项目名称:art-auction,代码行数:31,代码来源:master.blade.php

示例7: lang

 private function lang($text, $params = [], $options = null)
 {
     switch ($options) {
         case 'lower':
             return Lang::lower($text, $params);
         case 'capital':
             return Lang::capital($text, $params);
         case 'locale':
             return Lang::locale($text, $params);
     }
     return Lang::lang($text, $params);
 }
开发者ID:vincium,项目名称:bourg-la-reine,代码行数:12,代码来源:Template.php

示例8: save

 /**
  * Overwriting the Eloquent save() method, to set a default translation language, if necessary.
  */
 public function save(array $options = [])
 {
     if (isset($this->translatable)) {
         // set a default language (the one the user is currently using)
         if (!isset($this->translation_lang) || $this->translation_lang == '') {
             $this->translation_lang = \Lang::locale();
         }
         // TODO: if some untranslatable attributes are empty, but its parent's are filled, copy them
     }
     parent::save();
 }
开发者ID:RSivakov,项目名称:crud,代码行数:14,代码来源:CrudTrait.php

示例9: getSearchResult

        /**
         * Retourne les résultats d'une recherche
         *
         * @param string $query : l'expression à rechercher
         *
         * @return CrawledContent $resultsContainigQuery
         */
        public static function getSearchResult($query)
        {
            $calledClass = get_called_class();
            return self::search($query, $values)->select('crawled_contents.id', 'url', 'title', 'content', 'language', 'deleted_at', DB::raw('COUNT(log_outgoing_links.id) AS count'), DB::raw(self::caseWhen(DB::raw('language'), array(Lang::locale() => static::SAME_LANGUAGE), 0) . ' + ' . self::caseWhen(self::substr(DB::raw('language'), 1, 2), array(substr(Lang::locale(), 0, 2) => static::SAME_PRIMARY_LANGUAGE), 0) . ' +
						COUNT(DISTINCT key_words.id) * ' . static::KEY_WORD_SCORE . ' + ' . self::findAndCount(DB::raw('content'), $query) . ' * ' . static::COMPLETE_QUERY_SCORE . ' + ' . self::findAndCount(DB::raw('content'), $values) . ' * ' . static::ONE_WORD_SCORE . '
						AS score
					'))->leftJoin('log_outgoing_links', 'log_outgoing_links.crawled_content_id', '=', 'crawled_contents.id')->leftJoin('crawled_content_key_word', 'crawled_content_key_word.crawled_content_id', '=', 'crawled_contents.id')->leftJoin('key_words', function ($join) use($calledClass, $values) {
                $join->on('crawled_content_key_word.key_word_id', '=', 'key_words.id')->on('key_words.word', 'in', DB::raw('(' . implode(', ', array_maps(array('normalize', 'strtolower', array($calledClass, 'quote')), $values)) . ')'));
            })->groupBy('crawled_contents.id')->orderBy('score', 'desc');
        }
开发者ID:kylekatarnls,项目名称:sbp,代码行数:17,代码来源:big_file.php

示例10: smartDate

 public static function smartDate($timestamp)
 {
     $timeDiff = time() - $timestamp;
     // same day
     if ($timeDiff > -60 * 60 * 24) {
         // in more than -3h
         if ($timeDiff < -60 * 60 * 3) {
             return Lang::locale('in') . ' ' . ceil(-$timeDiff / 3600) . 'h';
         }
         // in more than -1h
         if ($timeDiff < -60 * 60) {
             $min = ceil(-$timeDiff % 3600 / 60);
             if ($min == 0) {
                 $min = '';
             } else {
                 if ($min == 60) {
                     $min = '';
                     $timeDiff -= 60 * 60;
                 } else {
                     $min = str_pad($min, 2, '0', STR_PAD_LEFT);
                 }
             }
             return Lang::locale('in') . ' ' . floor(-$timeDiff / 3600) . 'h' . $min;
         }
         // in more than -1 min
         if ($timeDiff < -60) {
             $min = ceil(-$timeDiff / 60);
             if ($min == 60) {
                 return Lang::locale('in') . ' 1h';
             }
             return Lang::locale('in') . ' ' . $min . ' min';
         }
         // in more than now
         if ($timeDiff < 0) {
             $sec = ceil(-$timeDiff);
             if ($sec == 60) {
                 return Lang::locale('in') . ' 1 min';
             }
             return Lang::locale('in') . ' ' . $sec . 's';
         }
         // now
         if ($timeDiff == 0) {
             return Lang::locale('now');
         }
         // less than 1 min ago
         if ($timeDiff < 60) {
             return Lang::locale('ago', [$timeDiff . 's']);
         }
         // less than 1h ago
         if ($timeDiff < 60 * 60) {
             $min = floor($timeDiff / 60);
             if ($min == 0) {
                 $min = '';
             }
             return Lang::locale('ago', [$min . ' min']);
         }
         // less than 3h ago
         if ($timeDiff < 60 * 60 * 3) {
             $min = floor($timeDiff % 3600 / 60);
             if ($min == 0) {
                 $min = '';
             } else {
                 if ($min == 60) {
                     $min = '';
                     $timeDiff += 60 * 60;
                 } else {
                     $min = ' ' . str_pad($min, 2, '0', STR_PAD_LEFT);
                 }
             }
             return Lang::locale('ago', [floor($timeDiff / 3600) . 'h' . $min]);
         }
         // less than 1 day ago
         if ($timeDiff < 60 * 60 * 24) {
             return Lang::locale('ago', [floor($timeDiff / 3600) . 'h']);
         }
     }
     // same month
     if (date('Y-m') == date('Y-m', $timestamp)) {
         return utf8_encode(strftime('%d %b', $timestamp)) . self::getTime($timestamp);
     }
     // same year
     if (date('Y') == date('Y', $timestamp)) {
         return utf8_encode(strftime('%d %b', $timestamp));
     }
     return utf8_encode(strftime('%d %b %Y', $timestamp));
 }
开发者ID:vincium,项目名称:bourg-la-reine,代码行数:86,代码来源:Format.php


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