本文整理汇总了PHP中Language::getLanguageNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getLanguageNames方法的具体用法?PHP Language::getLanguageNames怎么用?PHP Language::getLanguageNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getLanguageNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($par)
{
global $wgRequest, $wgOut;
$this->setHeaders();
$this->outputHeader();
# no UI when including()
if (!$this->including()) {
$code = $wgRequest->getVal('code', $par);
$suppressComplete = $wgRequest->getVal('suppresscomplete', $par);
$suppressEmpty = $wgRequest->getVal('suppressempty', false);
$wgOut->addHTML($this->languageForm($code, $suppressComplete));
} else {
$paramArray = explode('/', $par);
$code = $paramArray[0];
$suppressComplete = isset($paramArray[1]) && (bool) $paramArray[1];
$suppressEmpty = isset($paramArray[2]) && (bool) $paramArray[2];
}
$out = '';
if (array_key_exists($code, Language::getLanguageNames())) {
$out .= $this->getGroupStats($code, $suppressComplete, $suppressEmpty);
} else {
if ($code) {
$wgOut->addWikiMsg('translate-page-no-such-language');
}
}
$wgOut->addHTML($out);
}
示例2: wfPolyglotExtension
/**
* Takes all available languages if none are specified.
*
* @global array $wgPolyglotLanguages
*/
function wfPolyglotExtension()
{
global $wgPolyglotLanguages;
if ($wgPolyglotLanguages === null) {
$wgPolyglotLanguages = array_keys(Language::getLanguageNames());
}
}
示例3: findTitle
/**
* Assuming the user's interface language is fi
* Given input Page, it returns Page/fi if it exists, otherwise Page
* Given input Page/de, it returns Page/fi if it exists, otherwise Page/de if it exists, otherwise Page
* @return Title|null
*/
protected function findTitle($par)
{
global $wgLang, $wgLanguageCode;
// base = title without language code suffix
// provided = the title as it was given
$base = $provided = Title::newFromText($par);
if (strpos($par, '/') !== false) {
$pos = strrpos($par, '/');
$basepage = substr($par, 0, $pos);
$code = substr($par, $pos + 1);
$codes = Language::getLanguageNames(false);
if (isset($codes[$code])) {
$base = Title::newFromText($basepage);
}
}
if (!$base) {
return null;
}
$uiCode = $wgLang->getCode();
$proposed = Title::newFromText($base->getPrefixedText() . "/{$uiCode}");
if ($uiCode !== $wgLanguageCode && $proposed && $proposed->exists()) {
return $proposed;
} elseif ($provided && $provided->exists()) {
return $provided;
} else {
return $base;
}
}
示例4: execute
public function execute()
{
global $wgUser, $wgTranslateWorkflowStates;
if (!$wgTranslateWorkflowStates) {
$this->dieUsage('Message group review not in use', 'disabled');
}
if (!$wgUser->isallowed(self::$right)) {
$this->dieUsage('Permission denied', 'permissiondenied');
}
$requestParams = $this->extractRequestParams();
$group = MessageGroups::getGroup($requestParams['group']);
if (!$group) {
$this->dieUsageMsg(array('missingparam', 'group'));
}
$languages = Language::getLanguageNames(false);
if (!isset($languages[$requestParams['language']])) {
$this->dieUsageMsg(array('missingparam', 'language'));
}
$dbr = wfGetDB(DB_SLAVE);
$groupid = $group->getId();
$currentState = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language']), __METHOD__);
if ($currentState == $requestParams['state']) {
$this->dieUsage('The requested state is identical to the current state', 'sameworkflowstate');
}
$dbw = wfGetDB(DB_MASTER);
$table = 'translate_groupreviews';
$row = array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'], 'tgr_state' => $requestParams['state']);
$index = array('tgr_group', 'tgr_language');
$res = $dbw->replace($table, array($index), $row, __METHOD__);
$logger = new LogPage('translationreview');
$logParams = array($requestParams['language'], $group->getLabel(), $currentState, $requestParams['state']);
$logger->addEntry('group', SpecialPage::getTitleFor('Translate', $groupid), '', $logParams, $wgUser);
$output = array('review' => array('group' => $group->getId(), 'language' => $requestParams['language'], 'state' => $requestParams['state']));
$this->getResult()->addValue(null, $this->getModuleName(), $output);
}
示例5: stripInterlang
public function stripInterlang($content)
{
global $wgContLang;
$lang_mask = "(" . join("|", array_keys(Language::getLanguageNames())) . ")";
$content = preg_replace("@\\[\\[" . $lang_mask . ":[^\\]]*?].*?\\]@si", '', $content);
$content = trim($content);
return $content;
}
示例6: wfPolyglotExtension
function wfPolyglotExtension()
{
global $wgPolyglotLanguages;
if ($wgPolyglotLanguages === null) {
$wgPolyglotLanguages = @$GLOBALS['wgLanguageSelectorLanguages'];
}
if ($wgPolyglotLanguages === null) {
$wgPolyglotLanguages = array_keys(Language::getLanguageNames());
}
}
示例7: execute
function execute($par)
{
global $wgOut;
$wgOut->setPageTitle(wfMsg('communityhiring-header'));
$formDescriptor = array('about-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-about-intro', 'parse'), 'raw' => 1, 'section' => 'aboutyou'), 'given-name' => array('type' => 'text', 'label-message' => 'communityhiring-given', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'family-name' => array('type' => 'text', 'label-message' => 'communityhiring-family', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-line1' => array('type' => 'textarea', 'label-message' => 'communityhiring-address', 'section' => 'aboutyou', 'rows' => '3', 'cols' => '20'), 'address-city' => array('type' => 'text', 'label-message' => 'communityhiring-address-city', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-postal' => array('type' => 'text', 'label-message' => 'communityhiring-address-postal', 'section' => 'aboutyou'), 'address-country' => array('type' => 'text', 'label-message' => 'communityhiring-address-country', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'phone' => array('type' => 'text', 'label-message' => 'communityhiring-phone', 'section' => 'aboutyou'), 'email' => array('type' => 'text', 'label-message' => 'communityhiring-email', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'paragraph-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-paragraphs-intro', 'parse'), 'raw' => 1, 'section' => 'paragraphs', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'significance' => array('type' => 'textarea', 'label-message' => 'communityhiring-significance', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'excitement' => array('type' => 'textarea', 'label-message' => 'communityhiring-excitement', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'experiences' => array('type' => 'textarea', 'label-message' => 'communityhiring-experiences', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'other' => array('type' => 'textarea', 'label-message' => 'communityhiring-other', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1), 'languages' => array('type' => 'textarea', 'options' => array_flip(Language::getLanguageNames()), 'section' => 'demonstrative/languages', 'rows' => '3', 'label-message' => 'communityhiring-languages-label', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'contributor' => array('type' => 'radio', 'label-message' => 'communityhiring-contributor', 'section' => 'demonstrative/involvement', 'options' => array('Yes' => 'yes', 'No' => 'no')), 'usernames' => array('type' => 'textarea', 'rows' => '3', 'cols' => '20', 'label-message' => 'communityhiring-usernames', 'section' => 'demonstrative/involvement', 'vertical-label' => 1), 'wikimedia-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links', 'section' => 'demonstrative/involvement', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'other-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links-other', 'section' => 'demonstrative', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'availability-time' => array('type' => 'text', 'label-message' => 'communityhiring-availability-intro', 'section' => 'availability', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'availability-info' => array('type' => 'textarea', 'label-message' => 'communityhiring-availability-info', 'section' => 'availability', 'rows' => '5', 'cols' => '20', 'vertical-label' => 1), 'relocation' => array('type' => 'radio', 'label-message' => 'communityhiring-relocation-ok', 'section' => 'availability', 'vertical-label' => 1, 'options' => array('Yes' => 'yes', 'No' => 'no', 'It would be hard, but maybe I would' => 'maybe')), 'research' => array('type' => 'textarea', 'rows' => '5', 'label-message' => 'communityhiring-research', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')));
$form = new HTMLForm($formDescriptor, 'communityhiring');
$form->setIntro(wfMsgExt('communityhiring-intro', 'parse'));
$form->setSubmitCallback(array($this, 'submit'));
$form->setTitle($this->getTitle());
$form->show();
}
示例8: buildForm
function buildForm()
{
global $wgScript;
$languages = Language::getLanguageNames(false);
ksort($languages);
$out = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form')) . Xml::fieldset(wfMsg('allmessages-filter-legend')) . Xml::hidden('title', $this->getTitle()) . Xml::openElement('table', array('class' => 'mw-allmessages-table')) . "\n" . '<tr>
<td class="mw-label">' . Xml::label(wfMsg('allmessages-prefix'), 'mw-allmessages-form-prefix') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::input('prefix', 20, str_replace('_', ' ', $this->prefix), array('id' => 'mw-allmessages-form-prefix')) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class='mw-label'>" . wfMsg('allmessages-filter') . "</td>\n\n\t\t\t\t<td class='mw-input'>" . Xml::radioLabel(wfMsg('allmessages-filter-unmodified'), 'filter', 'unmodified', 'mw-allmessages-form-filter-unmodified', $this->filter == 'unmodified' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-all'), 'filter', 'all', 'mw-allmessages-form-filter-all', $this->filter == 'all' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-modified'), 'filter', 'modified', 'mw-allmessages-form-filter-modified', $this->filter == 'modified' ? true : false) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class=\"mw-label\">" . Xml::label(wfMsg('allmessages-language'), 'mw-allmessages-form-lang') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::openElement('select', array('id' => 'mw-allmessages-form-lang', 'name' => 'lang'));
foreach ($languages as $lang => $name) {
$selected = $lang == $this->langCode ? true : false;
$out .= Xml::option($lang . ' - ' . $name, $lang, $selected) . "\n";
}
$out .= Xml::closeElement('select') . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('allmessages-filter-submit')) . "</td>\n\n\t\t\t</tr>" . Xml::closeElement('table') . $this->table->getHiddenFields(array('title', 'prefix', 'filter', 'lang')) . Xml::closeElement('fieldset') . Xml::closeElement('form');
return $out;
}
示例9: languageName
public static function languageName(&$parser, $code = '', $outputLanguage = '')
{
global $wgLang;
if (!$code) {
return '';
}
if (!$outputLanguage) {
$outputLanguage = $parser->getOptions()->getUserLang();
}
$cldr = is_callable(array('LanguageNames', 'getNames'));
if ($outputLanguage !== 'native' && $cldr) {
$languages = LanguageNames::getNames($outputLanguage, LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW_AND_CLDR);
} else {
$languages = Language::getLanguageNames(false);
}
return isset($languages[$code]) ? $languages[$code] : $code;
}
示例10: getNames
/**
* Get localized language names for a particular language, using fallback languages for missing
* items.
*
* @param $code string
* @param $fbMethod int
* @param $list int
* @return an associative array of language codes and localized language names
*/
public static function getNames($code, $fbMethod = self::FALLBACK_NATIVE, $list = self::LIST_MW)
{
$xx = self::loadLanguage($code);
$native = Language::getLanguageNames($list === self::LIST_MW_SUPPORTED);
if ($fbMethod === self::FALLBACK_NATIVE) {
$names = array_merge($native, $xx);
} elseif ($fbMethod === self::FALLBACK_NORMAL) {
// Load missing language names from fallback languages
$fb = $xx;
if (is_callable(array('Language', 'getFallbacksFor'))) {
// MediaWiki 1.19
$fallbacks = Language::getFallbacksFor($code);
foreach ($fallbacks as $fallback) {
// Overwrite the things in fallback with what we have already
$fb = array_merge(self::loadLanguage($fallback), $fb);
}
} else {
// MediaWiki 1.18 or earlier
$fallback = $code;
while ($fallback = Language::getFallbackFor($fallback)) {
// Overwrite the things in fallback with what we have already
$fb = array_merge(self::loadLanguage($fallback), $fb);
}
}
/* Add native names for codes that are not in cldr */
$names = array_merge($native, $fb);
/* As a last resort, try the native name in Names.php */
if (!isset($names[$code]) && isset($native[$code])) {
$names[$code] = $native[$code];
}
} else {
throw new MWException("Invalid value for 2:\$fallback in " . __METHOD__);
}
switch ($list) {
case self::LIST_MW:
case self::LIST_MW_SUPPORTED:
/* Remove entries that are not in fb */
$names = array_intersect_key($names, $native);
/* And fall to the return */
/* And fall to the return */
case self::LIST_MW_AND_CLDR:
return $names;
default:
throw new MWException("Invalid value for 3:\$list in " . __METHOD__);
}
}
示例11: forGroup
public static function forGroup($id)
{
# Fetch from database
$dbr = wfGetDB(DB_SLAVE);
$conds = array('gs_group' => $id);
$res = $dbr->select('groupstats', '*', $conds);
while ($row = $dbr->fetchRow($res)) {
$stats[$row['gs_lang']] = $row;
}
# Go over each language filling missing entries
foreach (Language::getLanguageNames() as $lang => $name) {
if (!empty($stats[$lang])) {
continue;
}
$stats[$lang] = self::forItem($id, $lang);
}
return $stats;
}
示例12: render
/**
* Renders the storyboard tag.
*
* @param $input
* @param array $args
* @param Parser $parser
* @param $frame
*
* @return array
*/
public static function render($input, array $args, Parser $parser, $frame)
{
global $wgScriptPath, $wgStylePath, $wgStyleVersion, $wgContLanguageCode;
global $egStoryboardScriptPath, $egStoryboardWidth, $egStoryboardHeight;
efStoryboardAddJSLocalisation($parser);
// TODO: Combine+minfiy JS files, add switch to use combined+minified version
$parser->getOutput()->addHeadItem(Html::linkedStyle("{$egStoryboardScriptPath}/storyboard.css?{$wgStyleVersion}") . Html::linkedScript("{$wgStylePath}/common/jquery.min.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/jquery/jquery.ajaxscroll.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/tags/Storyboard/storyboard.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/storyboard.js?{$wgStyleVersion}"));
$width = StoryboardUtils::getDimension($args, 'width', $egStoryboardWidth);
$height = StoryboardUtils::getDimension($args, 'height', $egStoryboardHeight);
$languages = Language::getLanguageNames();
if (array_key_exists('language', $args) && array_key_exists($args['language'], $languages)) {
$language = $args['language'];
} else {
$language = $wgContLanguageCode;
}
$parser->getOutput()->addHeadItem(Html::inlineScript("var storyboardLanguage = '{$language}';"));
$output = Html::element('div', array('class' => 'storyboard', 'style' => "height: {$height}; width: {$width};"));
return array($output, 'noparse' => true, 'isHTML' => true);
}
示例13: __construct
/**
* Constructor
*
* @param $langobj Language: the Language Object
* @param $maincode String: the main language code of this language
* @param $variants Array: the supported variants of this language
* @param $variantfallbacks Array: the fallback language of each variant
* @param $flags Array: defining the custom strings that maps to the flags
* @param $manualLevel Array: limit for supported variants
*/
public function __construct($langobj, $maincode, $variants = array(), $variantfallbacks = array(), $flags = array(), $manualLevel = array())
{
global $wgDisabledVariants;
$this->mLangObj = $langobj;
$this->mMainLanguageCode = $maincode;
$this->mVariants = array_diff($variants, $wgDisabledVariants);
$this->mVariantFallbacks = $variantfallbacks;
$this->mVariantNames = Language::getLanguageNames();
$this->mCacheKey = wfMemcKey('conversiontables', $maincode);
$defaultflags = array('A' => 'A', 'T' => 'T', 'R' => 'R', 'D' => 'D', '-' => '-', 'H' => 'H', 'N' => 'N');
$this->mFlags = array_merge($defaultflags, $flags);
foreach ($this->mVariants as $v) {
if (array_key_exists($v, $manualLevel)) {
$this->mManualLevel[$v] = $manualLevel[$v];
} else {
$this->mManualLevel[$v] = 'bidirectional';
}
$this->mFlags[$v] = $v;
}
}
示例14: trailerForm
public static function trailerForm(&$items, $opts)
{
$opts->consumeValue('trailer');
global $wgRequest;
$default = $wgRequest->getVal('trailer', '');
global $wgLang;
if (is_callable(array('LanguageNames', 'getNames'))) {
$languages = LanguageNames::getNames($wgLang->getCode(), LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW);
} else {
$languages = Language::getLanguageNames(false);
}
ksort($languages);
$options = Xml::option(wfMsg('cleanchanges-language-na'), '', $default === '');
foreach ($languages as $code => $name) {
$selected = "/{$code}" === $default;
$options .= Xml::option("{$code} - {$name}", "/{$code}", $selected) . "\n";
}
$str = Xml::openElement('select', array('name' => 'trailer', 'class' => 'mw-language-selector', 'id' => 'sp-rc-language')) . $options . Xml::closeElement('select');
$items['tailer'] = array(wfMsgHtml('cleanchanges-language'), $str);
return true;
}
示例15: __construct
public function __construct($options = array())
{
$this->_defaults[] = $this->_base_defaults;
parent::__construct($options);
if (!isset($this->options['languages']) && isset(Booty::$skinOptions['languages'])) {
$this->options['languages'] = Booty::$skinOptions['languages'];
}
$this->addTemplatePath(dirname(__FILE__) . '/templates');
if (isset($this->options['languages'])) {
$names = Language::getLanguageNames();
$languages = array();
foreach ($this->options['languages'] as $code) {
if (array_key_exists($code, $names)) {
$languages[$code] = $names[$code];
}
}
$this->data['languages'] = $languages;
$context = RequestContext::getMain();
$active = $context->getLanguage();
$this->data['active_language'] = array('name' => $active->fetchLanguageName($active->getCode()), 'code' => $active->getCode());
}
}