當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Languages::local方法代碼示例

本文整理匯總了PHP中Languages::local方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::local方法的具體用法?PHP Languages::local怎麽用?PHP Languages::local使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Languages的用法示例。


在下文中一共展示了Languages::local方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findOptions

 /**
  * Get language options for in desired language. Useful to build a Select widget.
  *
  * @param array|string|int $selected - An array of language codes to mark as selected
  * @param array            $pool     (optional) - An array of language codes to be displayed. Leave null to show all.
  * @param string           $lang     (optional) - Get language names for this language.
  *
  * @return array
  */
 public static function findOptions($selected = array(), $pool = null, $lang = null)
 {
     if (!is_array($selected)) {
         $selected = array($selected);
     }
     $native = Languages::all()->listAll('name');
     if (is_array($pool)) {
         $native = array_intersect_key($native, array_flip($pool));
     }
     if ($lang === null) {
         $lang = Lang::get();
     }
     // try to get languages in author language
     $local = Languages::local()->listAll($lang);
     // if languages not found, use english ones
     if ($local === false) {
         $local = Languages::local()->listAll();
     }
     $options = array();
     foreach ($native as $code => $info) {
         $options[] = array($code, in_array($code, $selected), sprintf("[%s] %s%s", strtoupper($code), isset($local[$code]) ? $local[$code] . ' || ' : '', $info['name']));
     }
     return $options;
 }
開發者ID:siimsoni,項目名稱:languages,代碼行數:33,代碼來源:extension.driver.php

示例2: getAllLangs

 public static function getAllLangs($lc = null)
 {
     if ($lc === null) {
         $lc = self::getLangCode();
     }
     if (!($languages = Languages::local()->listAll($lc))) {
         $languages = Languages::local()->listAll();
     }
     return $languages;
 }
開發者ID:siimsoni,項目名稱:frontend_localisation,代碼行數:10,代碼來源:class.FLang.php


注:本文中的Languages::local方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。