Essentially random collection of helper functions, similar to GlobalFunctions.php. More...
Static Public Member Functions | |
static | title ($message, $code, $ns=NS_MEDIAWIKI) |
Does quick normalisation of message name so that in can be looked from the database. | |
static | figureMessage ($text) |
Splits page name into message key and language code. | |
static | getMessageContent ($key, $language, $namespace=NS_MEDIAWIKI) |
Loads page content *without* side effects. | |
static | getContents ($titles, $namespace) |
Fetches contents for pagenames in given namespace without side effects. | |
static | translationChanges ($hours=24, $bots=false, $ns=null) |
Fetches recent changes for titles in given namespaces. | |
static | getLanguageName ($code, $language= 'en') |
Returns a localised language name. | |
static | languageSelector ($language, $selectedId) |
Returns a language selector. | |
static | getLanguageSelector ($language, $labelOption=false) |
Standard language selector in Translate extension. | |
static | getLanguageNames ($code) |
Get translated language names for the languages generally supported for translation in the current wiki. | |
static | messageKeyToGroup ($namespace, $key) |
Returns the primary group message belongs to. | |
static | messageKeyToGroups ($namespace, $key) |
Returns the all the groups message belongs to. | |
static | normaliseKey ($namespace, $key) |
Converts page name and namespace to message index format. | |
static | fieldset ($legend, $contents, $attributes=array()) |
Constructs a fieldset with contents. | |
static | convertWhiteSpaceToHTML ($msg) |
Escapes the message, and does some mangling to whitespace, so that it is preserved when outputted as-is to html page. | |
static | assetPath ($path) |
Construct the web address to given asset. | |
static | cacheFile ($filename) |
Gets the path for cache files. | |
static | groupSelector ($default=false) |
static | addSpecialHelpLink (OutputPage $out, $to, $overrideBaseUrl=false) |
Adds help link with an icon to upper right corner. | |
static | getTokenAction ($token) |
Convenience function that handles BC with changed way of acquiring tokens via API. | |
static | getPlaceholder () |
Returns a random string that can be used as placeholder in strings. | |
static | getIcon (MessageGroup $g, $size) |
Get URLs for icons if available. | |
static | parseLanguageCodes ($codes) |
Parses list of language codes to an array. |
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition at line 14 of file TranslateUtils.php.
static TranslateUtils::addSpecialHelpLink | ( | OutputPage $ | out, | |
$ | to, | |||
$ | overrideBaseUrl = false | |||
) | [static] |
Adds help link with an icon to upper right corner.
OutputPage | $out | |
string | $to | |
bool | $overrideBaseUrl |
Definition at line 349 of file TranslateUtils.php.
Referenced by SpecialPageTranslation::execute(), SpecialTranslations::execute(), SpecialTranslate::execute(), SpecialSupportedLanguages::execute(), SpecialManageGroups::execute(), SpecialMagic::execute(), SpecialLanguageStats::execute(), SpecialTranslationStats::form(), and SpecialImportTranslations::outputForm().
static TranslateUtils::assetPath | ( | $ | path | ) | [static] |
Construct the web address to given asset.
string | $path Path to the resource relative to extensions root directory. |
Definition at line 303 of file TranslateUtils.php.
Referenced by PageTranslationHooks::languages().
static TranslateUtils::cacheFile | ( | $ | filename | ) | [static] |
Gets the path for cache files.
string | $filename |
MWException | If cache directory is not configured. |
Definition at line 315 of file TranslateUtils.php.
Referenced by SpecialManageGroups::execute(), MessageGroupCache::getCacheFileName(), CDBMessageIndex::getReader(), SpecialManageGroups::processSubmit(), SerializedMessageIndex::retrieve(), SpecialManageGroups::showChanges(), CDBMessageIndex::store(), SerializedMessageIndex::store(), and ProcessMessageChanges::writeChanges().
static TranslateUtils::convertWhiteSpaceToHTML | ( | $ | msg | ) | [static] |
Escapes the message, and does some mangling to whitespace, so that it is preserved when outputted as-is to html page.
Line feeds are converted to <br /> and occurrences of leading and trailing and multiple consecutive spaces to non-breaking spaces.
This is also implemented in JavaScript in ext.translate.quickedit.
string | $msg Plain text string. |
Definition at line 288 of file TranslateUtils.php.
Referenced by MessageWebImporter::execute(), TranslationHelpers::getDefinitionBox(), TranslationHelpers::getOtherLanguagesBox(), TranslationHelpers::getTranslationDisplayBox(), SpecialTranslations::showTranslations(), and TranslationHelpers::suggestionField().
static TranslateUtils::fieldset | ( | $ | legend, | |
$ | contents, | |||
$ | attributes = array() | |||
) | [static] |
Constructs a fieldset with contents.
string | $legend Raw html. | |
string | $contents Raw html. | |
array | $attributes Html attributes for the fieldset. |
Definition at line 271 of file TranslateUtils.php.
Referenced by TranslationHelpers::getCheckBox(), TranslationHelpers::getDefinitionBox(), TranslationHelpers::getDocumentationBox(), TranslationHelpers::getLastDiff(), TranslationHelpers::getOtherLanguagesBox(), TranslationHelpers::getSuggestionBox(), and TranslationHelpers::getTranslationDisplayBox().
static TranslateUtils::figureMessage | ( | $ | text | ) | [static] |
Splits page name into message key and language code.
string | $text |
Definition at line 45 of file TranslateUtils.php.
Referenced by SpecialPageTranslationDeletePage::execute(), LanguageEditStats::execute(), ReviewPerLanguageStats::indexOf(), TranslatePerLanguageStats::indexOf(), PageTranslationHooks::onPageContentLanguage(), PageTranslationHooks::preventDirectEditing(), PageTranslationHooks::renderTagPage(), TranslateRenderJob::run(), and PageTranslationHooks::translationPageHeader().
static TranslateUtils::getContents | ( | $ | titles, | |
$ | namespace | |||
) | [static] |
Fetches contents for pagenames in given namespace without side effects.
string|string[] | $titles Database page names. | |
int | $namespace The number of the namespace. |
Definition at line 75 of file TranslateUtils.php.
Referenced by getMessageContent(), ApiQueryMessageTranslations::getTranslations(), and SpecialTranslations::showTranslations().
static TranslateUtils::getIcon | ( | MessageGroup $ | g, | |
$ | size | |||
) | [static] |
Get URLs for icons if available.
MessageGroup | $g | |
int | $size Length of the edge of a bounding box to fit the icon. |
Definition at line 406 of file TranslateUtils.php.
Referenced by ApiQueryMessageGroups::formatGroup(), and SpecialSearchTranslations::makeGroupFacetRows().
static TranslateUtils::getLanguageName | ( | $ | code, | |
$ | language = 'en' | |||
) | [static] |
Returns a localised language name.
string | $code Language code. | |
string | $language Language code of language the the name should be in. |
Definition at line 145 of file TranslateUtils.php.
Referenced by TranslateEditAddons::buttonHack(), GettextFFS::doGettextHeader(), YamlFFS::doHeader(), JavaFFS::doHeader(), DtdFFS::doHeader(), MessageWebImporter::execute(), SpecialTranslationStats::getData(), SimpleFormatWriter::getLanguageNames(), TranslateLogFormatter::getMessageParameters(), PageTranslationLogFormatter::getMessageParameters(), TranslationHelpers::getOtherLanguagesBox(), ShapadoJsFFS::header(), PageTranslationHooks::languages(), SpecialLanguageStats::outputIntroduction(), SpecialTranslations::showTranslations(), and MediaWikiExtensionFFS::writeReal().
static TranslateUtils::getLanguageNames | ( | $ | code | ) | [static] |
Get translated language names for the languages generally supported for translation in the current wiki.
Message groups can have further exclusions.
string | $code |
Definition at line 199 of file TranslateUtils.php.
Referenced by SpecialTranslate::execute(), SpecialTranslate::getFormErrors(), getLanguageName(), getLanguageSelector(), SpecialMessageGroupStats::getMainColumnCell(), SpecialTranslationStash::getTargetLanguage(), MessageGroupBase::getTranslatableLanguages(), MessageUpdateJob::run(), and BlackListTest::setUp().
static TranslateUtils::getLanguageSelector | ( | $ | language, | |
$ | labelOption = false | |||
) | [static] |
Standard language selector in Translate extension.
string | $language Language code of the language the names should be localised to. | |
bool | $labelOption |
Definition at line 176 of file TranslateUtils.php.
Referenced by languageSelector(), SpecialFirstSteps::showPermissions(), SpecialFirstSteps::showSettings(), and SpecialFirstSteps::showUserpage().
static TranslateUtils::getMessageContent | ( | $ | key, | |
$ | language, | |||
$ | namespace = NS_MEDIAWIKI | |||
) | [static] |
Loads page content *without* side effects.
string | $key Message key. | |
string | $language Language code. | |
int | $namespace Namespace number. |
Definition at line 60 of file TranslateUtils.php.
Referenced by GettextFFS::formatDocumentation(), TranslationHelpers::getApertiumSuggestion(), DocumentationAid::getData(), CurrentTranslationAid::getData(), TranslationHelpers::getDocumentationBox(), WikiMessageGroup::getMessage(), TranslationHelpers::getOtherLanguagesBox(), ComplexMessages::getSavedData(), and TranslationHelpers::getYandexSuggestion().
static TranslateUtils::getPlaceholder | ( | ) | [static] |
Returns a random string that can be used as placeholder in strings.
Definition at line 392 of file TranslateUtils.php.
Referenced by SpecialSearchTranslations::__construct(), TranslatablePage::armourNowiki(), TranslatablePage::getParse(), TranslatablePage::sectionise(), GettextFFS::splitPlural(), and RubyYamlFFS::unflattenPlural().
static TranslateUtils::getTokenAction | ( | $ | token | ) | [static] |
Convenience function that handles BC with changed way of acquiring tokens via API.
string | $token |
Definition at line 377 of file TranslateUtils.php.
Referenced by ApiTranslationStash::getParamDescription(), ApiTranslationReview::getParamDescription(), ApiTranslateSandbox::getParamDescription(), ApiHardMessages::getParamDescription(), ApiGroupReview::getParamDescription(), ApiAggregateGroups::getParamDescription(), and ApiTokensTest::testTokenRetrieval().
static TranslateUtils::groupSelector | ( | $ | default = false |
) | [static] |
Definition at line 329 of file TranslateUtils.php.
Referenced by SpecialMessageGroupStats::getform().
static TranslateUtils::languageSelector | ( | $ | language, | |
$ | selectedId | |||
) | [static] |
Returns a language selector.
string | $language Language code of the language the names should be localised to. | |
string | $selectedId The language code that is selected by default. |
Definition at line 161 of file TranslateUtils.php.
Referenced by SpecialMagic::getForm().
static TranslateUtils::messageKeyToGroup | ( | $ | namespace, | |
$ | key | |||
) | [static] |
Returns the primary group message belongs to.
int | $namespace | |
string | $key |
Definition at line 229 of file TranslateUtils.php.
static TranslateUtils::messageKeyToGroups | ( | $ | namespace, | |
$ | key | |||
) | [static] |
Returns the all the groups message belongs to.
int | $namespace | |
string | $key |
Definition at line 241 of file TranslateUtils.php.
Referenced by ReviewPerLanguageStats::indexOf(), TranslatePerLanguageStats::indexOf(), and messageKeyToGroup().
static TranslateUtils::normaliseKey | ( | $ | namespace, | |
$ | key | |||
) | [static] |
Converts page name and namespace to message index format.
int | $namespace | |
string | $key |
Definition at line 258 of file TranslateUtils.php.
Referenced by MessageIndex::checkAndAdd(), MessageIndex::getGroupIds(), and messageKeyToGroups().
static TranslateUtils::parseLanguageCodes | ( | $ | codes | ) | [static] |
Parses list of language codes to an array.
string | $codes Comma separated list of language codes. "*" for all. |
Definition at line 436 of file TranslateUtils.php.
Referenced by MagicExport::writeFiles().
static TranslateUtils::title | ( | $ | message, | |
$ | code, | |||
$ | ns = NS_MEDIAWIKI | |||
) | [static] |
Does quick normalisation of message name so that in can be looked from the database.
string | $message Name of the message | |
string | $code Language code in lower case and with dash as delimiter | |
int | $ns Namespace constant |
Definition at line 23 of file TranslateUtils.php.
Referenced by getMessageContent().
static TranslateUtils::translationChanges | ( | $ | hours = 24 , |
|
$ | bots = false , |
|||
$ | ns = null | |||
) | [static] |
Fetches recent changes for titles in given namespaces.
int | $hours Number of hours. | |
bool | $bots Should bot edits be included. | |
null|int[] | $ns List of namespace IDs. |
Definition at line 108 of file TranslateUtils.php.
Referenced by LanguageEditStats::execute().