TranslateUtils Class Reference

Essentially random collection of helper functions, similar to GlobalFunctions.php. More...

List of all members.

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.

Detailed Description

Essentially random collection of helper functions, similar to GlobalFunctions.php.

Definition at line 14 of file TranslateUtils.php.


Member Function Documentation

static TranslateUtils::addSpecialHelpLink ( OutputPage $  out,
to,
overrideBaseUrl = false 
) [static]
static TranslateUtils::assetPath ( path  )  [static]

Construct the web address to given asset.

Parameters:
string $path Path to the resource relative to extensions root directory.
Returns:
string Full or partial web path.

Definition at line 303 of file TranslateUtils.php.

Referenced by PageTranslationHooks::languages().

static TranslateUtils::cacheFile ( filename  )  [static]

Gets the path for cache files.

Parameters:
string $filename
Returns:
string Full path.
Exceptions:
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.

Parameters:
string $msg Plain text string.
Returns:
string Text string that is ready for outputting.

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.

Parameters:
string $legend Raw html.
string $contents Raw html.
array $attributes Html attributes for the fieldset.
Returns:
string Html.

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]
static TranslateUtils::getContents ( titles,
namespace 
) [static]

Fetches contents for pagenames in given namespace without side effects.

Parameters:
string|string[] $titles Database page names.
int $namespace The number of the namespace.
Returns:
array ( string => array ( string, string ) ) Tuples of page text and last author indexed by page name.

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.

Parameters:
MessageGroup $g
int $size Length of the edge of a bounding box to fit the icon.
Returns:
null|array
Since:
2013-04-01

Definition at line 406 of file TranslateUtils.php.

Referenced by ApiQueryMessageGroups::formatGroup(), and SpecialSearchTranslations::makeGroupFacetRows().

Here is the call graph for this function:

static TranslateUtils::getLanguageName ( code,
language = 'en' 
) [static]
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.

Parameters:
string $code
Returns:
array ( language code => language name )

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.

Parameters:
string $language Language code of the language the names should be localised to.
bool $labelOption
Returns:
XmlSelect

Definition at line 176 of file TranslateUtils.php.

Referenced by languageSelector(), SpecialFirstSteps::showPermissions(), SpecialFirstSteps::showSettings(), and SpecialFirstSteps::showUserpage().

Here is the call graph for this function:

static TranslateUtils::getMessageContent ( key,
language,
namespace = NS_MEDIAWIKI 
) [static]

Loads page content *without* side effects.

Parameters:
string $key Message key.
string $language Language code.
int $namespace Namespace number.
Returns:
string|null The contents or null.

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().

Here is the call graph for this function:

static TranslateUtils::getPlaceholder (  )  [static]

Returns a random string that can be used as placeholder in strings.

Returns:
string
Since:
2012-07-31

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.

Parameters:
string $token
Returns:
string
Since:
2012-05-03

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().

Here is the call graph for this function:

static TranslateUtils::languageSelector ( language,
selectedId 
) [static]

Returns a language selector.

Parameters:
string $language Language code of the language the names should be localised to.
string $selectedId The language code that is selected by default.
Returns:
string

Definition at line 161 of file TranslateUtils.php.

Referenced by SpecialMagic::getForm().

Here is the call graph for this function:

static TranslateUtils::messageKeyToGroup ( namespace,
key 
) [static]

Returns the primary group message belongs to.

Parameters:
int $namespace
string $key
Returns:
string|null Group id or null.

Definition at line 229 of file TranslateUtils.php.

Here is the call graph for this function:

static TranslateUtils::messageKeyToGroups ( namespace,
key 
) [static]

Returns the all the groups message belongs to.

Parameters:
int $namespace
string $key
Returns:
string[] Possibly empty list of group ids.

Definition at line 241 of file TranslateUtils.php.

Referenced by ReviewPerLanguageStats::indexOf(), TranslatePerLanguageStats::indexOf(), and messageKeyToGroup().

Here is the call graph for this function:

static TranslateUtils::normaliseKey ( namespace,
key 
) [static]

Converts page name and namespace to message index format.

Parameters:
int $namespace
string $key
Returns:
string

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.

Parameters:
string $codes Comma separated list of language codes. "*" for all.
Returns:
string[] Language codes.

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.

Parameters:
string $message Name of the message
string $code Language code in lower case and with dash as delimiter
int $ns Namespace constant
Returns:
string The normalised title as a string.

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.

Parameters:
int $hours Number of hours.
bool $bots Should bot edits be included.
null|int[] $ns List of namespace IDs.
Returns:
array List of recent changes.

Definition at line 108 of file TranslateUtils.php.

Referenced by LanguageEditStats::execute().


The documentation for this class was generated from the following file:
Generated on Tue Oct 29 00:00:56 2013 for MediaWiki Translate Extension by  doxygen 1.6.3