本文整理汇总了PHP中TranslateUtils::getMessageContent方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslateUtils::getMessageContent方法的具体用法?PHP TranslateUtils::getMessageContent怎么用?PHP TranslateUtils::getMessageContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslateUtils
的用法示例。
在下文中一共展示了TranslateUtils::getMessageContent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMessage
/**
* Returns of stored translation of message specified by the $key in language
* code $code.
*
* @param string $key Key of the message.
* @param string $code Language code.
* @return string|null The translation or null if it doesn't exists.
*/
public function getMessage($key, $code)
{
if ($code && $this->getSourceLanguage() !== $code) {
return TranslateUtils::getMessageContent($key, $code);
} else {
return TranslateUtils::getMessageContent($key, false);
}
}
示例2: getData
public function getData()
{
$translation = null;
$title = $this->handle->getTitle();
$translation = TranslateUtils::getMessageContent($this->handle->getKey(), $this->handle->getCode(), $title->getNamespace());
Hooks::run('TranslatePrefillTranslation', array(&$translation, $this->handle));
$fuzzy = MessageHandle::hasFuzzyString($translation) || $this->handle->isFuzzy();
$translation = str_replace(TRANSLATE_FUZZY, '', $translation);
return array('language' => $this->handle->getCode(), 'fuzzy' => $fuzzy, 'value' => $translation);
}
示例3: getData
public function getData()
{
global $wgTranslateDocumentationLanguageCode, $wgContLang;
if (!$wgTranslateDocumentationLanguageCode) {
throw new TranslationHelperException('Message documentation is disabled');
}
$page = $this->handle->getKey();
$ns = $this->handle->getTitle()->getNamespace();
$info = TranslateUtils::getMessageContent($page, $wgTranslateDocumentationLanguageCode, $ns);
return array('language' => $wgContLang->getCode(), 'value' => $info, 'html' => $this->context->getOutput()->parse($info));
}
示例4: formatDocumentation
protected function formatDocumentation( $key ) {
global $wgTranslateDocumentationLanguageCode;
if ( !$this->offlineMode ) return '';
$code = $wgTranslateDocumentationLanguageCode;
if ( !$code ) return '';
$documentation = TranslateUtils::getMessageContent( $key, $code, $this->group->getNamespace() );
if ( !is_string( $documentation ) ) return '';
$lines = explode( "\n", $documentation );
$out = '';
foreach ( $lines as $line ) {
$out .= "#. [Wiki] $line\n";
}
return $out;
}
示例5: getDocumentationBox
public function getDocumentationBox()
{
global $wgTranslateDocumentationLanguageCode, $wgOut;
if (!$wgTranslateDocumentationLanguageCode) {
return null;
}
$page = $this->handle->getKey();
$ns = $this->handle->getTitle()->getNamespace();
$title = Title::makeTitle($ns, $page . '/' . $wgTranslateDocumentationLanguageCode);
$edit = self::ajaxEditLink($title, wfMsgHtml('translate-edit-contribute'));
$info = TranslateUtils::getMessageContent($page, $wgTranslateDocumentationLanguageCode, $ns);
$class = 'mw-sp-translate-edit-info';
$gettext = $this->formatGettextComments();
if ($info !== null && $gettext) {
$info .= Html::element('hr');
}
$info .= $gettext;
// The information is most likely in English
$divAttribs = array('dir' => 'ltr', 'lang' => 'en', 'class' => 'mw-content-ltr');
if (strval($info) === '') {
global $wgLang;
$info = wfMsg('translate-edit-no-information');
$class = 'mw-sp-translate-edit-noinfo';
// The message saying that there's no info, should be translated
$divAttribs = array('dir' => $wgLang->getDir(), 'lang' => $wgLang->getCode());
}
$class .= ' mw-sp-translate-message-documentation';
$contents = $wgOut->parse($info);
// Remove whatever block element wrapup the parser likes to add
$contents = preg_replace('~^<([a-z]+)>(.*)</\\1>$~us', '\\2', $contents);
return TranslateUtils::fieldset(wfMsgHtml('translate-edit-information', $edit, $page), Html::rawElement('div', $divAttribs, $contents), array('class' => $class));
}
示例6: getSavedData
/**
* Gets saved data from Mediawiki namespace
* @return Array
*/
protected function getSavedData()
{
$data = TranslateUtils::getMessageContent($this->databaseMsg, $this->language);
if (!$data) {
return array();
} else {
return $this->parse($data);
}
}
示例7: getDocumentationBox
public function getDocumentationBox()
{
global $wgTranslateDocumentationLanguageCode;
if (!$wgTranslateDocumentationLanguageCode) {
throw new TranslationHelperException('Message documentation language code is not defined');
}
$context = RequestContext::getMain();
$page = $this->handle->getKey();
$ns = $this->handle->getTitle()->getNamespace();
$title = Title::makeTitle($ns, $page . '/' . $wgTranslateDocumentationLanguageCode);
$edit = self::ajaxEditLink($title, $context->msg('translate-edit-contribute')->escaped());
$info = TranslateUtils::getMessageContent($page, $wgTranslateDocumentationLanguageCode, $ns);
$class = 'mw-sp-translate-edit-info';
// The information is most likely in English
$divAttribs = array('dir' => 'ltr', 'lang' => 'en', 'class' => 'mw-content-ltr');
if (strval($info) === '') {
$info = $context->msg('translate-edit-no-information')->text();
$class = 'mw-sp-translate-edit-noinfo';
$lang = $context->getLanguage();
// The message saying that there's no info, should be translated
$divAttribs = array('dir' => $lang->getDir(), 'lang' => $lang->getCode());
}
$class .= ' mw-sp-translate-message-documentation';
$contents = $context->getOutput()->parse($info);
// Remove whatever block element wrapup the parser likes to add
$contents = preg_replace('~^<([a-z]+)>(.*)</\\1>$~us', '\\2', $contents);
return TranslateUtils::fieldset($context->msg('translate-edit-information')->rawParams($edit)->escaped(), Html::rawElement('div', $divAttribs, $contents), array('class' => $class));
}