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


PHP Language::fetchLanguageNames方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $mwLanguages = $this->loadMediaWiki();
     $gtLanguages = $this->loadGettext();
     $clLanguages = $this->loadCLDR();
     $all = Language::fetchLanguageNames(null, 'all');
     $allkeys = array_keys($all + $mwLanguages + $gtLanguages + $clLanguages);
     sort($allkeys);
     $this->output(sprintf("%12s %3s %3s %4s\n", 'Code', 'MW', 'Get', 'CLDR'));
     foreach ($allkeys as $code) {
         $mw = isset($mwLanguages[$code]) ? '+' : '';
         $gt = isset($gtLanguages[$code]) ? '+' : '';
         $cl = isset($clLanguages[$code]) ? '+' : '';
         if ($mw === '') {
             $fallbacks = Language::getFallbacksFor($code);
             foreach ($fallbacks as $fcode) {
                 if ($fcode !== 'en' && isset($mwLanguages[$fcode])) {
                     $mw = '.';
                 }
             }
         }
         $error = '';
         if (substr_count(sprintf('%s%s%s', $mw, $gt, $cl), '+') > 1) {
             $error = $this->tryMatch($code, $mw, $gtLanguages, $clLanguages);
         }
         $this->output(sprintf("%12s %-3s %-3s %-4s %s\n", $code, $mw, $gt, $cl, $error));
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:28,代码来源:plural-comparison.php

示例2: execute

 public function execute()
 {
     $user = $this->getUser();
     $requestParams = $this->extractRequestParams();
     $group = MessageGroups::getGroup($requestParams['group']);
     $code = $requestParams['language'];
     if (!$group || MessageGroups::isDynamic($group)) {
         $this->dieUsageMsg(array('missingparam', 'group'));
     }
     $stateConfig = $group->getMessageGroupStates()->getStates();
     if (!$stateConfig) {
         $this->dieUsage('Message group review not in use', 'disabled');
     }
     if (!$user->isAllowed(self::$right)) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     if ($user->isBlocked()) {
         $this->dieUsage('You have been blocked', 'blocked');
     }
     $requestParams = $this->extractRequestParams();
     $languages = Language::fetchLanguageNames();
     if (!isset($languages[$code])) {
         $this->dieUsageMsg(array('missingparam', 'language'));
     }
     $targetState = $requestParams['state'];
     if (!isset($stateConfig[$targetState])) {
         $this->dieUsage('The requested state is invalid', 'invalidstate');
     }
     if (is_array($stateConfig[$targetState]) && isset($stateConfig[$targetState]['right']) && !$user->isAllowed($stateConfig[$targetState]['right'])) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     self::changeState($group, $code, $targetState, $user);
     $output = array('review' => array('group' => $group->getId(), 'language' => $code, 'state' => $targetState));
     $this->getResult()->addValue(null, $this->getModuleName(), $output);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:35,代码来源:ApiGroupReview.php

示例3: execute

 public function execute()
 {
     $users = 10;
     // For number of translations, limited to [0,20]
     $mean = 15;
     $stddev = 20;
     $stash = new TranslationStashStorage(wfGetDB(DB_MASTER));
     $languages = array_keys(Language::fetchLanguageNames());
     for ($i = 0; $i < $users; $i++) {
         $username = 'Pupu' . wfRandomString(6);
         $password = wfRandomString(12);
         $email = "{$username}.{$password}@blackhole.io";
         $user = TranslateSandbox::addUser($username, $password, $email);
         $language = $languages[rand(0, count($languages) - 1)];
         $count = wfGaussMs($mean, $stddev);
         $count = min(20, $count);
         $count = max(0, $count);
         for ($j = 0; $j < $count; $j++) {
             $title = Title::makeTitle(NS_MEDIAWIKI, wfRandomString(24) . '/' . $language);
             $value = array('Pupu söi');
             for ($k = rand(0, 20); $k > 0; $k--) {
                 $value[] = wfRandomString(rand(1, 28));
             }
             $value = implode("\n", $value);
             $translation = new StashedTranslation($user, $title, $value);
             $stash->addTranslation($translation);
         }
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:29,代码来源:generateRandomSandboxData.php

示例4: execute

 public function execute($sub)
 {
     if (!$this->userCanExecute($this->getUser())) {
         $this->displayRestrictionError();
         return;
     }
     $out = $this->getOutput();
     $out->addModules('ext.SpellingDictionary.viewByLanguage');
     $out->setPageTitle($this->msg('title-view-by-language'));
     $out->addWikiMsg('view-by-lang-intro');
     // Building a language selector
     // Display languages in their native name
     $languages = Language::fetchLanguageNames(null, 'mwfile');
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $options["{$code} - {$name}"] = $code;
     }
     $formDescriptor = array('language' => array('type' => 'select', 'label-message' => 'sd-admin-select-language', 'required' => true, 'options' => $options, 'section' => 'section-chooselanguage'));
     $form = HTMLForm::factory('ooui', $formDescriptor, $this->getContext());
     $form->setId('languageSelectionForm');
     $form->setMessagePrefix('view-by-lang');
     $form->setSubmitText(wfMessage('sd-admin-view-selected-language')->text());
     // Callback function
     $form->setSubmitCallback(array($this, 'showSpellings'));
     $form->show();
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-SpellingDictionary,代码行数:27,代码来源:SpecialViewByLanguage.php

示例5: getName

 /**
  * Take a code as input, and search a language name for it in
  * a given language via Language::fetchLanguageNames() or
  * else via the Babel language names CDB
  *
  * @param $code String: Code to get name for.
  * @param $language String: Code of language to attempt to get name in,
  *                  defaults to language of code.
  * @return String (name of language) or false (invalid language code).
  */
 public static function getName($code, $language = null)
 {
     wfProfileIn(__METHOD__);
     global $wgBabelLanguageNamesCdb;
     // Get correct code, even though it should already be correct.
     $code = self::getCode($code);
     if ($code === false) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $language = $language === null ? $code : $language;
     $names = Language::fetchLanguageNames($language, 'all');
     if (isset($names[$code])) {
         wfProfileOut(__METHOD__);
         return $names[$code];
     }
     $codes = false;
     try {
         $namesCdb = CdbReader::open($wgBabelLanguageNamesCdb);
         $codes = $namesCdb->get($code);
     } catch (CdbException $e) {
         wfDebug(__METHOD__ . ": CdbException caught, error message was " . $e->getMessage());
     }
     wfProfileOut(__METHOD__);
     return $codes;
 }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:36,代码来源:BabelLanguageCodes.class.php

示例6: validSpecialPageAliasesProvider

 public function validSpecialPageAliasesProvider()
 {
     $codes = array_keys(Language::fetchLanguageNames('mwfile'));
     $data = [];
     foreach ($codes as $code) {
         $specialPageAliases = $this->getSpecialPageAliases($code);
         if ($specialPageAliases !== []) {
             $data[] = [$code, $specialPageAliases];
         }
     }
     return $data;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:SpecialPageAliasTest.php

示例7: fetchDirectory

 /**
  * This is horribly inefficient. Subclasses have more efficient
  * implementation of this.
  */
 public function fetchDirectory($pattern)
 {
     $files = array();
     $languages = Language::fetchLanguageNames(null, 'mwfile');
     foreach (array_keys($languages) as $code) {
         // Hack for core
         if (strpos($pattern, 'Messages*.php') !== false) {
             $code = ucfirst(strtr($code, '-', '_'));
         }
         $url = str_replace('*', $code, $pattern);
         $file = $this->fetchFile($url);
         if ($file) {
             $files[$url] = $file;
         }
     }
     return $files;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:21,代码来源:HttpFetcher.php

示例8: languageSelector

 /**
  * JavsScript selector for language codes.
  * @return JsSelectToInput
  */
 protected static function languageSelector()
 {
     if (is_callable(array('LanguageNames', 'getNames'))) {
         $lang = RequestContext::getMain()->getLanguage();
         $languages = LanguageNames::getNames($lang->getCode(), LanguageNames::FALLBACK_NORMAL);
     } else {
         $languages = Language::fetchLanguageNames();
     }
     ksort($languages);
     $selector = new XmlSelect('mw-language-selector', 'mw-language-selector');
     foreach ($languages as $code => $name) {
         $selector->addOption("{$code} - {$name}", $code);
     }
     $jsSelect = new JsSelectToInput($selector);
     $jsSelect->setSourceId('mw-language-selector');
     return $jsSelect;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:21,代码来源:UserToggles.php

示例9: getNames

 /**
  * Get localized language names for a particular language, using fallback languages for missing
  * items.
  *
  * @param $code string
  * @param $fbMethod int
  * @param $list int
  * @throws Exception
  * @return array 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::fetchLanguageNames(null, $list === self::LIST_MW_SUPPORTED ? 'mwfile' : 'mw');
     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 Exception("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 Exception("Invalid value for 3:\$list in " . __METHOD__);
     }
 }
开发者ID:Plover-Y,项目名称:mediawiki-extensions-cldr,代码行数:56,代码来源:LanguageNames.body.php

示例10: getFormFields

 protected function getFormFields()
 {
     // Get default from the subpage of Special page
     $defaultName = $this->par;
     $page = array();
     $page['pagename'] = array('type' => 'text', 'label-message' => 'pagelang-name', 'default' => $defaultName);
     // Options for whether to use the default language or select language
     $selectoptions = array((string) $this->msg('pagelang-use-default')->escaped() => 1, (string) $this->msg('pagelang-select-lang')->escaped() => 2);
     $page['selectoptions'] = array('id' => 'mw-pl-options', 'type' => 'radio', 'options' => $selectoptions, 'default' => 1);
     // Building a language selector
     $userLang = $this->getLanguage()->getCode();
     $languages = Language::fetchLanguageNames($userLang, 'mwfile');
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $options["{$code} - {$name}"] = $code;
     }
     $page['language'] = array('id' => 'mw-pl-languageselector', 'cssclass' => 'mw-languageselector', 'type' => 'select', 'options' => $options, 'label-message' => 'pagelang-language', 'default' => $this->getConfig()->get('LanguageCode'));
     return $page;
 }
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:20,代码来源:SpecialPageLanguage.php

示例11: __construct

 /**
  * Constructor
  *
  * @param Language $langobj
  * @param string $maincode The main language code of this language
  * @param array $variants The supported variants of this language
  * @param array $variantfallbacks The fallback language of each variant
  * @param array $flags Defining the custom strings that maps to the flags
  * @param array $manualLevel Limit for supported variants
  */
 public function __construct($langobj, $maincode, $variants = [], $variantfallbacks = [], $flags = [], $manualLevel = [])
 {
     global $wgDisabledVariants;
     $this->mLangObj = $langobj;
     $this->mMainLanguageCode = $maincode;
     $this->mVariants = array_diff($variants, $wgDisabledVariants);
     $this->mVariantFallbacks = $variantfallbacks;
     $this->mVariantNames = Language::fetchLanguageNames();
     $this->mCacheKey = wfMemcKey('conversiontables', $maincode);
     $defaultflags = ['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;
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:30,代码来源:LanguageConverter.php

示例12: getFormFields

 protected function getFormFields()
 {
     $par = $this->par;
     $request = $this->getRequest();
     $formDescriptor = array();
     $formDescriptor['dbname'] = array('label-message' => 'createwiki-label-dbname', 'type' => 'text', 'default' => $request->getVal('cwDBname') ? $request->getVal('cwDBname') : $par, 'size' => 20, 'required' => true, 'validation-callback' => array(__CLASS__, 'validateDBname'), 'name' => 'cwDBname');
     $formDescriptor['founder'] = array('label-message' => 'createwiki-label-founder', 'type' => 'text', 'default' => $request->getVal('cwFounder'), 'size' => 20, 'required' => true, 'validation-callback' => array(__CLASS__, 'validateFounder'), 'name' => 'cwFounder');
     $formDescriptor['sitename'] = array('label-message' => 'createwiki-label-sitename', 'type' => 'text', 'default' => $request->getVal('cwSitename'), 'size' => 20, 'name' => 'cwSitename');
     // Building a language selector (attribution:
     // includes/specials/SpecialPageLanguage.php L68)
     $languages = Language::fetchLanguageNames(null, 'mwfile');
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $options["{$code} - {$name}"] = $code;
     }
     $formDescriptor['language'] = array('type' => 'select', 'options' => $options, 'label-message' => 'createwiki-label-language', 'default' => $request->getVal('cwLanguage') ? $request->getVal('cwLanguage') : 'en', 'name' => 'cwLanguage');
     $formDescriptor['private'] = array('type' => 'check', 'label-message' => 'createwiki-label-private', 'name' => 'cwPrivate');
     $formDescriptor['reason'] = array('label-message' => 'createwiki-label-reason', 'type' => 'text', 'default' => $request->getVal('wpreason'), 'size' => 45, 'required' => true);
     return $formDescriptor;
 }
开发者ID:Reception123,项目名称:CreateWiki,代码行数:21,代码来源:SpecialCreateWiki.php

示例13: showWikiForm

 function showWikiForm($wiki)
 {
     $out = $this->getOutput();
     $wiki = $this->lookupWikiDetails($wiki);
     if (!$wiki) {
         $out->addHTML('<div class="errorbox">' . wfMessage('managewiki-missing')->escaped() . '</div>');
         return false;
     }
     if (!$this->getRequest()->wasPosted()) {
         $out->addWikiMsg('managewiki-header', $wiki->wiki_dbname);
     }
     $languages = Language::fetchLanguageNames(null, 'mwfile');
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $options["{$code} - {$name}"] = $code;
     }
     $formDescriptor = array('dbname' => array('label-message' => 'managewiki-label-dbname', 'type' => 'text', 'size' => 20, 'default' => $wiki->wiki_dbname, 'disabled' => true, 'name' => 'mwDBname'), 'sitename' => array('label-message' => 'managewiki-label-sitename', 'type' => 'text', 'size' => 20, 'default' => $wiki->wiki_sitename, 'required' => true, 'name' => 'mwSitename'), 'language' => array('label-message' => 'managewiki-label-language', 'type' => 'select', 'default' => $wiki->wiki_language, 'options' => $options, 'name' => 'mwLanguage'), 'closed' => array('type' => 'check', 'label-message' => 'managewiki-label-closed', 'name' => 'cwClosed', 'default' => $wiki->wiki_closed == 1 ? 1 : 0), 'private' => array('type' => 'check', 'label-message' => 'managewiki-label-private', 'name' => 'cwPrivate', 'disabled' => !$this->getUser()->isAllowed('managewiki-restricted'), 'default' => $wiki->wiki_private == 1 ? 1 : 0), 'reason' => array('label-message' => 'managewiki-label-reason', 'type' => 'text', 'size' => 45, 'required' => true));
     $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'changeForm');
     $htmlForm->setMethod('post')->setSubmitCallback(array($this, 'onSubmitInput'))->prepareForm()->show();
 }
开发者ID:Reception123,项目名称:CreateWiki,代码行数:21,代码来源:SpecialManageWiki.php

示例14: getName

 /**
  * Take a code as input, and search a language name for it in
  * a given language via Language::fetchLanguageNames() or 
  * else via the Babel language names CDB
  *
  * @param $code String: Code to get name for.
  * @param $language String: Code of language to attempt to get name in,
  *                  defaults to language of code.
  * @return String (name of language) or false (invalid language code).
  */
 public static function getName($code, $language = null)
 {
     wfProfileIn(__METHOD__);
     global $wgBabelLanguageNamesCdb;
     // Get correct code, even though it should already be correct.
     $code = self::getCode($code);
     if ($code === false) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $language = $language === null ? $code : $language;
     $names = Language::fetchLanguageNames($language, 'all');
     if (isset($names[$code])) {
         wfProfileOut(__METHOD__);
         return $names[$code];
     }
     $namesCdb = CdbReader::open($wgBabelLanguageNamesCdb);
     $codes = $namesCdb->get($code);
     wfProfileOut(__METHOD__);
     return $codes;
 }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:31,代码来源:BabelLanguageCodes.class.php

示例15: execute

 /**
  * Shows the page to the user.
  * @param string $sub: The subpage string argument (if any).
  *  [[Special:SpellingDictionary/subpage]].
  */
 public function execute($sub)
 {
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('title-special'));
     // Parses message from .i18n.php as wikitext and adds it to the
     // page output.
     $out->addWikiMsg('intro-paragraph');
     // Building a language selector
     // Display languages in their native name
     $languages = Language::fetchLanguageNames(null, 'mwfile');
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $options["{$code} - {$name}"] = $code;
     }
     $formDescriptor = array('word' => array('type' => 'text', 'label-message' => 'spell-dict-word', 'required' => true), 'language' => array('type' => 'select', 'label-message' => 'spell-dict-language', 'required' => true, 'options' => $options));
     $form = HTMLForm::factory('vform', $formDescriptor, $this->getContext());
     $form->setSubmitText(wfMessage('add-word-form-submit')->text());
     //Callback function
     $form->setSubmitCallback(array('SpecialSpellingDictionary', 'store'));
     $form->show();
 }
开发者ID:barbu110,项目名称:mediawiki-spelling-dictionary,代码行数:27,代码来源:SpecialSpellingDictionary.php


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