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


PHP TranslateUtils::getLanguageName方法代码示例

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


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

示例1: getMessageParameters

 public function getMessageParameters()
 {
     $params = parent::getMessageParameters();
     $type = $this->entry->getFullType();
     if ($type === 'translationreview/message') {
         $targetPage = $this->makePageLink($this->entry->getTarget(), array('oldid' => $params[3]));
         $params[2] = Message::rawParam($targetPage);
     } elseif ($type === 'translationreview/group') {
         /*
          * - 3: language code
          * - 4: label of the message group
          * - 5: old state
          * - 6: new state
          */
         $uiLanguage = $this->context->getLanguage();
         $language = $params[3];
         $targetPage = $this->makePageLinkWithText($this->entry->getTarget(), $params[4], array('language' => $language));
         $params[2] = Message::rawParam($targetPage);
         $params[3] = TranslateUtils::getLanguageName($language, $uiLanguage->getCode());
         $params[5] = $this->formatStateMessage($params[5]);
         $params[6] = $this->formatStateMessage($params[6]);
     } elseif ($type === 'translatorsandbox/rejected') {
         // No point linking to the user page which cannot have existed
         $params[2] = $this->entry->getTarget()->getText();
     } elseif ($type === 'translatorsandbox/promoted') {
         // Gender for the target
         $params[3] = User::newFromId($params[3])->getName();
     }
     return $params;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:30,代码来源:TranslateLogFormatter.php

示例2: doHeader

	protected function doHeader( MessageCollection $collection ) {
		global $wgSitename, $wgTranslateDocumentationLanguageCode;

		$code = $collection->code;
		$name = TranslateUtils::getLanguageName( $code );
		$native = TranslateUtils::getLanguageName( $code, true );

		if ( $wgTranslateDocumentationLanguageCode ) {
			$docu = "\n * See the $wgTranslateDocumentationLanguageCode 'language' for message documentation incl. usage of parameters";
		} else {
			$docu = '';
		}

		$authors = $this->doAuthors( $collection );

		$output = <<<PHP
/** $name ($native)
 * $docu
 * To improve a translation please visit http://$wgSitename
 *
 * @ingroup Language
 * @file
 *
$authors */


PHP;
		return $output;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:29,代码来源:PhpVariables.php

示例3: doHeader

 protected function doHeader(MessageCollection $collection)
 {
     global $wgSitename;
     $code = $collection->code;
     $name = TranslateUtils::getLanguageName($code);
     $native = TranslateUtils::getLanguageName($code, $code);
     $output = "# Messages for {$name} ({$native})\n";
     $output .= "# Exported from {$wgSitename}\n\n";
     return $output;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:10,代码来源:DtdFFS.php

示例4: doHeader

 /**
  * @param $collection MessageCollection
  * @return string
  */
 protected function doHeader(MessageCollection $collection)
 {
     global $wgSitename;
     global $wgTranslateYamlLibrary;
     $code = $collection->code;
     $name = TranslateUtils::getLanguageName($code);
     $native = TranslateUtils::getLanguageName($code, $code);
     $output = "# Messages for {$name} ({$native})\n";
     $output .= "# Exported from {$wgSitename}\n";
     if (isset($wgTranslateYamlLibrary)) {
         $output .= "# Export driver: {$wgTranslateYamlLibrary}\n";
     }
     return $output;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:18,代码来源:YamlFFS.php

示例5: getMessageParameters

 public function getMessageParameters()
 {
     $params = parent::getMessageParameters();
     $legacy = $this->entry->getParameters();
     $type = $this->entry->getFullType();
     switch ($type) {
         case 'pagetranslation/mark':
             $revision = $legacy['revision'];
             $targetPage = $this->makePageLink($this->entry->getTarget(), array('oldid' => $revision));
             $params[2] = Message::rawParam($targetPage);
             break;
         case 'pagetranslation/moveok':
         case 'pagetranslation/movenok':
         case 'pagetranslation/deletefnok':
         case 'pagetranslation/deletelnok':
             $target = $legacy['target'];
             $moveTarget = $this->makePageLink(Title::newFromText($target));
             $params[3] = Message::rawParam($moveTarget);
             break;
         case 'pagetranslation/prioritylanguages':
             $params[3] = $legacy['force'];
             $languages = $legacy['languages'];
             if ($languages !== false) {
                 $lang = $this->context->getLanguage();
                 $languages = array_map('trim', preg_split('/,/', $languages, -1, PREG_SPLIT_NO_EMPTY));
                 $languages = array_map(function ($code) use($lang) {
                     return TranslateUtils::getLanguageName($code, $lang->getCode());
                 }, $languages);
                 $params[4] = $lang->listToText($languages);
             }
             break;
         case 'pagetranslation/associate':
         case 'pagetranslation/dissociate':
             $params[3] = $legacy['aggregategroup'];
             break;
     }
     return $params;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:38,代码来源:PageTranslationLogFormatter.php

示例6: buttonHack

 /**
  * Replace the normal save button with one that says if you are editing
  * message documentation to try to avoid accidents.
  * Hook: EditPageBeforeEditButtons
  */
 static function buttonHack(EditPage $editpage, &$buttons, $tabindex)
 {
     $handle = new MessageHandle($editpage->getTitle());
     if (!$handle->isValid()) {
         return true;
     }
     $context = $editpage->getArticle()->getContext();
     if ($handle->isDoc()) {
         $langCode = $context->getLanguage()->getCode();
         $name = TranslateUtils::getLanguageName($handle->getCode(), $langCode);
         $accessKey = $context->msg('accesskey-save')->plain();
         $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => ++$tabindex, 'value' => $context->msg('translate-save', $name)->text(), 'accesskey' => $accessKey, 'title' => $context->msg('tooltip-save')->text() . ' [' . $accessKey . ']');
         $buttons['save'] = Xml::element('input', $temp, '');
     }
     try {
         $supportUrl = SupportAid::getSupportUrl($handle->getTitle());
     } catch (TranslationHelperException $e) {
         return true;
     }
     $temp = array('id' => 'wpSupport', 'name' => 'wpSupport', 'type' => 'button', 'tabindex' => ++$tabindex, 'value' => $context->msg('translate-js-support')->text(), 'title' => $context->msg('translate-js-support-title')->text(), 'data-load-url' => $supportUrl, 'onclick' => "window.open( jQuery(this).attr('data-load-url') );");
     $buttons['ask'] = Html::element('input', $temp, '');
     return true;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:28,代码来源:TranslateEditAddons.php

示例7: doHeader

 /**
  * @param $collection MessageCollection
  * @return string
  */
 protected function doHeader(MessageCollection $collection)
 {
     if (isset($this->extra['header'])) {
         $output = $this->extra['header'];
     } else {
         global $wgSitename;
         $code = $collection->code;
         $name = TranslateUtils::getLanguageName($code);
         $native = TranslateUtils::getLanguageName($code, $code);
         $output = "# Messages for {$name} ({$native})\n";
         $output .= "# Exported from {$wgSitename}\n";
     }
     return $output;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:18,代码来源:JavaFFS.php

示例8: outputIntroduction

	/**
	 * Output something helpful to guide the confused user.
	 */
	protected function outputIntroduction() {
		global $wgOut, $wgLang, $wgUser;

		$linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
		$languageName = TranslateUtils::getLanguageName( $this->target, false, $wgLang->getCode() );
		$rcInLangLink = $linker->link(
			SpecialPage::getTitleFor( 'Translate', '!recent' ),
			wfMsgHtml( 'languagestats-recenttranslations' ),
			array(),
			array(
				'task' => $wgUser->isAllowed( 'translate-messagereview' ) ? 'acceptqueue' : 'reviewall',
				'language' => $this->target
			)
		);

		$out = wfMessage( 'languagestats-stats-for', $languageName )->rawParams( $rcInLangLink )->parseAsBlock();
		$wgOut->addHTML( $out );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:SpecialLanguageStats.php

示例9: showTranslations

 /**
  * Builds a table with all translations of $title.
  *
  * @param $title Title (default: null)
  * @return void
  */
 function showTranslations(Title $title)
 {
     global $wgOut, $wgUser, $wgLang;
     $sk = $wgUser->getSkin();
     $namespace = $title->getNamespace();
     $message = $title->getDBkey();
     $inMessageGroup = TranslateUtils::messageKeyToGroup($title->getNamespace(), $title->getText());
     if (!$inMessageGroup) {
         $wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => $namespace, 'page_title ' . $dbr->buildLike("{$message}/", $dbr->anyString())), __METHOD__, array('ORDER BY' => 'page_title', 'USE INDEX' => 'name_title'));
     if (!$res->numRows()) {
         $wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
         return;
     } else {
         $wgOut->addWikiMsg('translate-translations-count', $wgLang->formatNum($res->numRows()));
     }
     // Normal output.
     $titles = array();
     foreach ($res as $s) {
         $titles[] = $s->page_title;
     }
     $pageInfo = TranslateUtils::getContents($titles, $namespace);
     $tableheader = Xml::openElement('table', array('class' => 'mw-sp-translate-table sortable'));
     $tableheader .= Xml::openElement('tr');
     $tableheader .= Xml::element('th', null, wfMsg('allmessagesname'));
     $tableheader .= Xml::element('th', null, wfMsg('allmessagescurrent'));
     $tableheader .= Xml::closeElement('tr');
     // Adapted version of TranslateUtils:makeListing() by Nikerabbit.
     $out = $tableheader;
     $canTranslate = $wgUser->isAllowed('translate');
     $ajaxPageList = array();
     $historyText = "&#160;<sup>" . wfMsgHtml('translate-translations-history-short') . "</sup>&#160;";
     foreach ($res as $s) {
         $key = $s->page_title;
         $tTitle = Title::makeTitle($s->page_namespace, $key);
         $ajaxPageList[] = $tTitle->getPrefixedDBkey();
         $code = $this->getCode($s->page_title);
         $text = TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})";
         $text = htmlspecialchars($text);
         if ($canTranslate) {
             $tools['edit'] = TranslationHelpers::ajaxEditLink($tTitle, $text);
         } else {
             $tools['edit'] = $sk->link($tTitle, $text);
         }
         $tools['history'] = $sk->link($tTitle, $historyText, array('action', 'title' => wfMsg('history-title', $tTitle->getPrefixedDBkey())), array('action' => 'history'));
         if (TranslateEditAddons::isFuzzy($tTitle)) {
             $class = 'orig';
         } else {
             $class = 'def';
         }
         $leftColumn = $tools['history'] . $tools['edit'];
         $out .= Xml::tags('tr', array('class' => $class), Xml::tags('td', null, $leftColumn) . Xml::tags('td', array('lang' => $code, 'dir' => Language::factory($code)->getDir()), TranslateUtils::convertWhiteSpaceToHTML($pageInfo[$key][0])));
     }
     $out .= Xml::closeElement('table');
     $wgOut->addHTML($out);
     $vars = array('trlKeys' => $ajaxPageList);
     $wgOut->addScript(Skin::makeVariablesScript($vars));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:67,代码来源:SpecialTranslations.php

示例10: setSubtitle

 /**
  * Set a subtitle like "Manage > FreeCol (open source game) > German"
  * based on group and language code. The language part is not shown if
  * it is 'en', and all three possible parts of the subtitle are linked.
  *
  * @param $group MessageGroup
  * @param $code \string Language code.
  */
 protected function setSubtitle($group, $code)
 {
     global $wgLang;
     $links[] = $this->skin->link($this->getTitle(), wfMsgHtml('translate-manage-subtitle'));
     $links[] = $this->skin->link($this->getTitle(), htmlspecialchars($group->getLabel()), array(), array('group' => $group->getId()));
     // Do not show language part for English.
     if ($code !== 'en') {
         $langname = TranslateUtils::getLanguageName($code, false, $wgLang->getCode());
         $links[] = $this->skin->link($this->getTitle(), htmlspecialchars($langname), array(), array('group' => $group->getId(), 'language' => $code));
     }
     $this->out->setSubtitle(implode(' > ', $links));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:20,代码来源:SpecialManageGroups.php

示例11: messageSelector

 protected function messageSelector()
 {
     $nondefaults = $this->opts->getChangedValues();
     $output = Html::openElement('div', array('class' => 'row tux-messagetable-header'));
     $output .= Html::openElement('div', array('class' => 'nine columns'));
     $output .= Html::openElement('ul', array('class' => 'row tux-message-selector'));
     $tabs = array('default' => '', 'translated' => 'translated', 'untranslated' => 'untranslated');
     $ellipsisOptions = array('outdated' => 'fuzzy');
     $selected = $this->opts->getValue('filter');
     $keys = array_keys($tabs);
     if (in_array($selected, array_values($ellipsisOptions))) {
         $key = $keys[count($keys) - 1];
         $ellipsisOptions = array($key => $tabs[$key]);
         // Remove the last tab
         unset($tabs[$key]);
         $tabs = array_merge($tabs, array('outdated' => $selected));
     } elseif (!in_array($selected, array_values($tabs))) {
         $selected = '';
     }
     $container = Html::openElement('ul', array('class' => 'column tux-message-selector'));
     foreach ($ellipsisOptions as $optKey => $optValue) {
         $container .= $this->ellipsisSelector($optKey, $optValue);
     }
     $sourcelanguage = $this->opts->getValue('sourcelanguage');
     $sourcelanguage = TranslateUtils::getLanguageName($sourcelanguage);
     foreach ($tabs as $tab => $filter) {
         // Messages for grepping:
         // tux-sst-default
         // tux-sst-translated
         // tux-sst-untranslated
         // tux-sst-outdated
         $tabClass = "tux-sst-{$tab}";
         $taskParams = array('filter' => $filter) + $nondefaults;
         ksort($taskParams);
         $href = $this->getTitle()->getLocalUrl($taskParams);
         if ($tab === 'default') {
             $link = Html::element('a', array('href' => $href), $this->msg($tabClass)->text());
         } else {
             $link = Html::element('a', array('href' => $href), $this->msg($tabClass, $sourcelanguage)->text());
         }
         if ($selected === $filter) {
             $tabClass = $tabClass . ' selected';
         }
         $output .= Html::rawElement('li', array('class' => array('column', $tabClass), 'data-filter' => $filter, 'data-title' => $tab), $link);
     }
     // More column
     $output .= Html::openElement('li', array('class' => 'column more')) . '...' . $container . Html::closeElement('li');
     $output .= Html::closeElement('ul');
     $output .= Html::closeElement('div');
     $output .= Html::closeElement('div');
     return $output;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:52,代码来源:SpecialSearchTranslations.php

示例12: languages

 /**
  * @param $data
  * @param $params
  * @param $parser Parser
  * @return string
  */
 public static function languages($data, $params, $parser)
 {
     $currentTitle = $parser->getTitle();
     // Check if this is a source page or a translation page
     $page = TranslatablePage::newFromTitle($currentTitle);
     if ($page->getMarkedTag() === false) {
         $page = TranslatablePage::isTranslationPage($currentTitle);
     }
     if ($page === false || $page->getMarkedTag() === false) {
         return '';
     }
     $status = $page->getTranslationPercentages();
     if (!$status) {
         return '';
     }
     // If priority languages have been set always show those languages
     $priorityLangs = TranslateMetadata::get($page->getMessageGroupId(), 'prioritylangs');
     $priorityForce = TranslateMetadata::get($page->getMessageGroupId(), 'priorityforce');
     $filter = null;
     if (strlen($priorityLangs) > 0) {
         $filter = array_flip(explode(',', $priorityLangs));
     }
     if ($filter !== null) {
         // If translation is restricted to some languages, only show them
         if ($priorityForce === 'on') {
             // Do not filter the source language link
             $filter[$page->getMessageGroup()->getSourceLanguage()] = true;
             $status = array_intersect_key($status, $filter);
         }
         foreach ($filter as $langCode => $value) {
             if (!isset($status[$langCode])) {
                 // We need to show all priority languages even if no translation started
                 $status[$langCode] = 0;
             }
         }
     }
     // Fix title
     $pageTitle = $page->getTitle();
     // Sort by language code, which seems to be the only sane method
     ksort($status);
     // This way the parser knows to fragment the parser cache by language code
     $userLangCode = $parser->getOptions()->getUserLang();
     $userLangDir = $parser->getOptions()->getUserLangObj()->getDir();
     // Should call $page->getMessageGroup()->getSourceLanguage(), but
     // group is sometimes null on WMF during page moves, reason unknown.
     // This should do the same thing for now.
     $sourceLanguage = $pageTitle->getPageLanguage()->getCode();
     $languages = array();
     foreach ($status as $code => $percent) {
         // Get autonyms
         $name = TranslateUtils::getLanguageName($code, $code);
         $name = htmlspecialchars($name);
         // Unlikely, but better safe
         // Add links to other languages
         $suffix = $code === $sourceLanguage ? '' : "/{$code}";
         $targetTitleString = $pageTitle->getDBkey() . $suffix;
         $subpage = Title::makeTitle($pageTitle->getNamespace(), $targetTitleString);
         $classes = array();
         if ($code === $userLangCode) {
             $classes[] = 'mw-pt-languages-ui';
         }
         if ($currentTitle->equals($subpage)) {
             $classes[] = 'mw-pt-languages-selected';
             $classes = array_merge($classes, self::tpProgressIcon($percent));
             $name = Html::rawElement('span', array('class' => $classes), $name);
         } elseif ($subpage->isKnown()) {
             $pagename = $page->getPageDisplayTitle($code);
             if (!is_string($pagename)) {
                 $pagename = $subpage->getPrefixedText();
             }
             $classes = array_merge($classes, self::tpProgressIcon($percent));
             $title = wfMessage('tpt-languages-nonzero')->params($pagename)->numParams(100 * $percent)->text();
             $attribs = array('title' => $title, 'class' => $classes);
             $name = Linker::linkKnown($subpage, $name, $attribs);
         } else {
             /* When language is included because it is a priority language,
              * but translation does not yet exists, link directly to the
              * translation view. */
             $specialTranslateTitle = SpecialPage::getTitleFor('Translate');
             $params = array('group' => $page->getMessageGroupId(), 'language' => $code, 'task' => 'view');
             $classes[] = 'new';
             // For red link color
             $attribs = array('title' => wfMessage('tpt-languages-zero')->text(), 'class' => $classes);
             $name = Linker::link($specialTranslateTitle, $name, $attribs, $params);
         }
         $languages[] = $name;
     }
     // dirmark (rlm/lrm) is added, because languages with RTL names can
     // mess the display
     $lang = Language::factory($userLangCode);
     $sep = wfMessage('tpt-languages-separator')->inLanguage($lang)->escaped();
     $sep .= $lang->getDirMark();
     $languages = implode($sep, $languages);
     $out = Html::openElement('div', array('class' => 'mw-pt-languages noprint', 'lang' => $userLangCode, 'dir' => $userLangDir));
//.........这里部分代码省略.........
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:101,代码来源:PageTranslationHooks.php

示例13: header

    /**
     * @param $code string
     * @param $authors array
     * @return string
     */
    protected function header($code, $authors)
    {
        global $wgSitename;
        $name = TranslateUtils::getLanguageName($code);
        $native = TranslateUtils::getLanguageName($code, $code);
        $authorsList = $this->authorsList($authors);
        /** @cond doxygen_bug */
        return <<<EOT
/** Messages for {$name} ({$native})
 *  Exported from {$wgSitename}
 *
{$authorsList}
 */

var I18n = {

EOT;
        /** @endcond */
    }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:24,代码来源:JavaScriptFFS.php

示例14: languages

    /**
     * @param $data
     * @param $params
     * @param $parser Parser
     * @return string
     */
    public static function languages($data, $params, $parser)
    {
        $title = $parser->getTitle();
        // Check if this is a source page or a translation page
        $page = TranslatablePage::newFromTitle($title);
        if ($page->getMarkedTag() === false) {
            $page = TranslatablePage::isTranslationPage($title);
        }
        if ($page === false || $page->getMarkedTag() === false) {
            return '';
        }
        $status = $page->getTranslationPercentages();
        if (!$status) {
            return '';
        }
        // Fix title
        $title = $page->getTitle();
        // Sort by language code, which seems to be the only sane method
        ksort($status);
        $options = $parser->getOptions();
        if (method_exists($options, 'getUserLang')) {
            $userLangCode = $options->getUserLang();
        } else {
            // Backward compat for MediaWiki 1.17
            global $wgLang;
            $userLangCode = $wgLang->getCode();
        }
        // BC for <1.19
        $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
        $languages = array();
        foreach ($status as $code => $percent) {
            $name = TranslateUtils::getLanguageName($code, false, $userLangCode);
            $name = htmlspecialchars($name);
            // Unlikely, but better safe
            /* Percentages are too accurate and take more
             * space than simple images */
            $percent *= 100;
            if ($percent < 20) {
                $image = 1;
            } elseif ($percent < 40) {
                $image = 2;
            } elseif ($percent < 60) {
                $image = 3;
            } elseif ($percent < 80) {
                $image = 4;
            } else {
                $image = 5;
            }
            $percent = Xml::element('img', array('src' => TranslateUtils::assetPath("resources/images/prog-{$image}.png"), 'alt' => "{$percent}%", 'title' => "{$percent}%", 'width' => '9', 'height' => '9'));
            // Add links to other languages
            $suffix = $code === 'en' ? '' : "/{$code}";
            $_title = Title::makeTitle($title->getNamespace(), $title->getDBkey() . $suffix);
            if ($parser->getTitle()->getText() === $_title->getText()) {
                $name = Html::rawElement('span', array('class' => 'mw-pt-languages-selected'), $name);
                $languages[] = "{$name} {$percent}";
            } else {
                if ($code === $userLangCode) {
                    $name = Html::rawElement('span', array('class' => 'mw-pt-languages-ui'), $name);
                }
                $languages[] = $linker->linkKnown($_title, "{$name} {$percent}");
            }
        }
        $legend = wfMsg('tpt-languages-legend');
        $languages = implode(wfMsg('tpt-languages-separator'), $languages);
        return <<<FOO
<div class="mw-pt-languages">
<table><tbody>

<tr valign="top">
<td class="mw-pt-languages-label"><b>{$legend}</b></td>
<td class="mw-pt-languages-list">{$languages}</td></tr>

</tbody></table>
</div>
FOO;
    }
开发者ID:schwarer2006,项目名称:wikia,代码行数:82,代码来源:PageTranslationHooks.php

示例15: writeReal

    /**
     * @param MessageCollection $collection
     * @return string
     */
    protected function writeReal(MessageCollection $collection)
    {
        $mangler = $this->group->getMangler();
        $code = $collection->getLanguage();
        $block = $this->generateMessageBlock($collection, $mangler);
        if ($block === false) {
            return '';
        }
        // Ugly code, relies on side effects
        // Avoid parsing stuff with fake language code
        // Premature optimization
        $this->read('mul');
        $filename = $this->group->getSourceFilePath($code);
        $cache =& self::$cache[$filename];
        // Generating authors
        if (isset($cache['sections'][$code])) {
            // More premature optimization
            $fromFile = self::parseAuthorsFromString($cache['sections'][$code]);
            $collection->addCollectionAuthors($fromFile);
        }
        $authors = $collection->getAuthors();
        $authors = $this->filterAuthors($authors, $code);
        $authorList = '';
        foreach ($authors as $author) {
            $authorList .= "\n * @author {$author}";
        }
        // And putting all together
        $name = TranslateUtils::getLanguageName($code);
        $native = TranslateUtils::getLanguageName($code, $code);
        $section = <<<PHP
/** {$name} ({$native}){$authorList}
 */
\$messages['{$code}'] = array({$block});
PHP;
        // Store the written part, so that when next language is called,
        // the new version will be used (instead of the old parsed version
        $cache['sections'][$code] = $section;
        // Make a copy we can alter
        $sections = $cache['sections'];
        $priority = array();
        global $wgTranslateDocumentationLanguageCode;
        $codes = array(0, $this->group->getSourceLanguage(), $wgTranslateDocumentationLanguageCode);
        foreach ($codes as $pcode) {
            if (isset($sections[$pcode])) {
                $priority[] = $sections[$pcode];
                unset($sections[$pcode]);
            }
        }
        ksort($sections);
        return implode("\n\n", $priority) . "\n\n" . implode("\n\n", $sections) . "\n";
    }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:55,代码来源:MediaWikiExtensionFFS.php


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