本文整理汇总了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;
}
示例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;
}