TranslationHelpers Class Reference

Provides the nice boxes that aid the translators to do their job. More...

List of all members.

Public Member Functions

 __construct (Title $title, $groupId)
 getTextareaId ()
 Gets the HTML id of the text area that contains the translation.
 setTextareaId ($id)
 Sets the HTML id of the text area that contains the translation.
 setEditMode ($mode=true)
 Enable or disable extra help for editing.
 getDefinition ()
 Gets the message definition.
 getTranslation ()
 Gets the current message translation.
 setTranslation ($translation)
 Manual override for the translation.
 getTargetLanguage ()
 Gets the linguistically correct language code for translation.
 getBoxes ($suggestions= 'sync')
 Returns block element HTML snippet that contains the translation aids.
 callBox ($type, $cb, $params=array())
 Public since 2012-06-26.
 getBoxNames ()
 getSuggestionBox ()
 getDefinitionBox ()
 getTranslationDisplayBox ()
 getCheckBox ()
 getOtherLanguagesBox ()
 getSeparatorBox ()
 getDocumentationBox ()
 getLazySuggestionBox ()
 dialogID ()
 adder ($source, $lang)
 wrapInsert ($id, $text)
 suggestionField ($text)

Static Public Member Functions

static ajaxEditLink ($target, $text)
 Ajax-enabled message editing link.
static jQueryPathId ($id)
 Escapes $id such that it can be used in jQuery selector.
static checkTranslationServiceFailure ($service)
 Checks whether the given service has exceeded failure count.
static reportTranslationServiceFailure ($service)
 Increases the failure count for a given service.
static addModules (OutputPage $out)

Protected Member Functions

 getMessageGroup (MessageHandle $handle, $groupId)
 Tries to determine to which group this message belongs.
 getTTMServerBox ($serviceName, $config)
 Returns suggestions from a translation memory.
 getRemoteTTMServerBox ($serviceName, $config)
 Returns suggestions from a translation memory.
 formatTTMServerSuggestions ($data)
 Since 2012-03-05.
 getMicrosoftSuggestion ($serviceName, $config)
 getApertiumSuggestion ($serviceName, $config)
 getYandexSuggestion ($serviceName, $config)
 formatGettextComments ()
 getPageDiff ()
 getLastDiff ()
 mustBeKnownMessage ()
 mustBeTranslation ()
 mustHaveDefinition ()

Static Protected Member Functions

static makeGoogleQueryParams ($definition, $pair, $config)
static wrapUntranslatable ($text)
static unwrapUntranslatable ($text)
static legend ($label)
static clear ()
static getFallbacks ($code)

Protected Attributes

 $handle
 $group
 $translation
 The current translation as a string.
 $definition
 The message definition as a string.
 $textareaId = 'wpTextbox1'
 HTML id to the text area that contains the translation.
 $editMode = 'true'
 Whether to include extra tools to aid translating.

Static Protected Attributes

static $serviceFailureCount = 5
 How many failures during failure period need to happen to consider the service being temporarily off-line.
static $serviceFailurePeriod = 900
 How long after the last detected failure we clear the status and try again.

Detailed Description

Provides the nice boxes that aid the translators to do their job.

Boxes contain definition, documentation, other languages, translation memory suggestions, highlighted changes etc.

Definition at line 17 of file TranslationHelpers.php.


Constructor & Destructor Documentation

TranslationHelpers::__construct ( Title $  title,
groupId 
)
Parameters:
Title $title Title of a page that holds a translation.
string $groupId Group id that should be used, otherwise autodetected from title.

Definition at line 51 of file TranslationHelpers.php.

Here is the call graph for this function:


Member Function Documentation

TranslationHelpers::adder ( source,
lang 
)
Parameters:
string $source jQuery selector for element containing the source
string|Language $lang Language code or object
Returns:
string

Definition at line 1272 of file TranslationHelpers.php.

Referenced by getDefinitionBox(), getOtherLanguagesBox(), and suggestionField().

Here is the call graph for this function:

static TranslationHelpers::addModules ( OutputPage $  out  )  [static]
static TranslationHelpers::ajaxEditLink ( target,
text 
) [static]

Ajax-enabled message editing link.

Parameters:
$target Title: Title of the target message.
$text String: Link text for Linker::link()
Returns:
string HTML link

Definition at line 1324 of file TranslationHelpers.php.

Referenced by formatTTMServerSuggestions(), getDocumentationBox(), getOtherLanguagesBox(), and SpecialTranslations::showTranslations().

Here is the call graph for this function:

TranslationHelpers::callBox ( type,
cb,
params = array() 
)

Public since 2012-06-26.

Since:
2012-01-04

Definition at line 225 of file TranslationHelpers.php.

Referenced by getBoxes().

static TranslationHelpers::checkTranslationServiceFailure ( service  )  [static]

Checks whether the given service has exceeded failure count.

Parameters:
$service string
Exceptions:
TranslationHelperException 

Definition at line 1363 of file TranslationHelpers.php.

Referenced by getApertiumSuggestion(), getMicrosoftSuggestion(), getRemoteTTMServerBox(), and getYandexSuggestion().

static TranslationHelpers::clear (  )  [static, protected]
Returns:
string

Definition at line 1195 of file TranslationHelpers.php.

Referenced by getOtherLanguagesBox().

TranslationHelpers::dialogID (  ) 
Returns:
string

Definition at line 1261 of file TranslationHelpers.php.

Referenced by getDefinitionBox(), getLazySuggestionBox(), getOtherLanguagesBox(), and suggestionField().

TranslationHelpers::formatGettextComments (  )  [protected]

Definition at line 1022 of file TranslationHelpers.php.

Referenced by getDocumentationBox().

TranslationHelpers::formatTTMServerSuggestions ( data  )  [protected]

Since 2012-03-05.

Definition at line 325 of file TranslationHelpers.php.

Referenced by getSuggestionBox().

Here is the call graph for this function:

TranslationHelpers::getApertiumSuggestion ( serviceName,
config 
) [protected]

Definition at line 584 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getBoxes ( suggestions = 'sync'  ) 

Returns block element HTML snippet that contains the translation aids.

Not all boxes are shown all the time depending on whether they have any information to show and on configuration variables.

Parameters:
$suggestions string
Returns:
String. Block level HTML snippet or empty string.

Definition at line 177 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getBoxNames (  ) 
Returns:
array

Definition at line 236 of file TranslationHelpers.php.

Referenced by getBoxes().

TranslationHelpers::getCheckBox (  ) 

Definition at line 843 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getDefinition (  ) 

Gets the message definition.

Returns:
String

Definition at line 105 of file TranslationHelpers.php.

Referenced by getCheckBox(), getDefinitionBox(), getMicrosoftSuggestion(), getRemoteTTMServerBox(), getTTMServerBox(), and mustHaveDefinition().

Here is the call graph for this function:

TranslationHelpers::getDefinitionBox (  ) 

Definition at line 788 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getDocumentationBox (  ) 

Definition at line 974 of file TranslationHelpers.php.

Here is the call graph for this function:

static TranslationHelpers::getFallbacks ( code  )  [static, protected]
Parameters:
$code string
Returns:
array

Definition at line 1203 of file TranslationHelpers.php.

TranslationHelpers::getLastDiff (  )  [protected]

Definition at line 1128 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getLazySuggestionBox (  ) 
Returns:
null|string

Definition at line 1236 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getMessageGroup ( MessageHandle handle,
groupId 
) [protected]

Tries to determine to which group this message belongs.

It tries to get group id from loadgroup GET-paramater, but fallbacks to messageIndex file if no valid group was provided.

Parameters:
MessageHandle $handle
string $groupId
Returns:
MessageGroup which the key belongs to, or null.

Definition at line 65 of file TranslationHelpers.php.

Referenced by __construct().

Here is the call graph for this function:

TranslationHelpers::getMicrosoftSuggestion ( serviceName,
config 
) [protected]

Definition at line 502 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getOtherLanguagesBox (  ) 

Definition at line 913 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getPageDiff (  )  [protected]

Definition at line 1070 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getRemoteTTMServerBox ( serviceName,
config 
) [protected]

Returns suggestions from a translation memory.

Parameters:
$serviceName 
$config 
Exceptions:
TranslationHelperException 
Returns:
string Html snippet which contains the suggestions.

Definition at line 278 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getSeparatorBox (  ) 

Definition at line 970 of file TranslationHelpers.php.

TranslationHelpers::getSuggestionBox (  ) 
Returns:
string
Exceptions:
MWException 

Definition at line 405 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getTargetLanguage (  ) 

Gets the linguistically correct language code for translation.

Definition at line 155 of file TranslationHelpers.php.

Referenced by getLastDiff(), and suggestionField().

Here is the call graph for this function:

TranslationHelpers::getTextareaId (  ) 

Gets the HTML id of the text area that contains the translation.

Returns:
String

Definition at line 81 of file TranslationHelpers.php.

Referenced by adder().

TranslationHelpers::getTranslation (  ) 

Gets the current message translation.

Fuzzy messages will be marked as such unless translation is provided manually.

Returns:
string

Definition at line 129 of file TranslationHelpers.php.

Referenced by getCheckBox(), and getTranslationDisplayBox().

TranslationHelpers::getTranslationDisplayBox (  ) 

Definition at line 828 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getTTMServerBox ( serviceName,
config 
) [protected]

Returns suggestions from a translation memory.

Parameters:
$serviceName 
$config 
Exceptions:
TranslationHelperException 
Returns:
string Html snippet which contains the suggestions.

Definition at line 255 of file TranslationHelpers.php.

Here is the call graph for this function:

TranslationHelpers::getYandexSuggestion ( serviceName,
config 
) [protected]

Definition at line 684 of file TranslationHelpers.php.

Here is the call graph for this function:

static TranslationHelpers::jQueryPathId ( id  )  [static]

Escapes $id such that it can be used in jQuery selector.

Parameters:
$id string
Returns:
string

Definition at line 1342 of file TranslationHelpers.php.

Referenced by adder(), and getLazySuggestionBox().

static TranslationHelpers::legend ( label  )  [static, protected]
Parameters:
$label string
Returns:
string

Definition at line 1187 of file TranslationHelpers.php.

Referenced by getOtherLanguagesBox().

static TranslationHelpers::makeGoogleQueryParams ( definition,
pair,
config 
) [static, protected]

Definition at line 478 of file TranslationHelpers.php.

Referenced by getApertiumSuggestion().

TranslationHelpers::mustBeKnownMessage (  )  [protected]
Since:
2012-01-04

Definition at line 1430 of file TranslationHelpers.php.

Referenced by getCheckBox(), getDefinition(), getLazySuggestionBox(), getPageDiff(), and getTargetLanguage().

TranslationHelpers::mustBeTranslation (  )  [protected]
Since:
2012-01-04

Definition at line 1437 of file TranslationHelpers.php.

Referenced by getRemoteTTMServerBox(), and getTTMServerBox().

TranslationHelpers::mustHaveDefinition (  )  [protected]
Since:
2012-01-04

Definition at line 1444 of file TranslationHelpers.php.

Referenced by getDefinitionBox(), getMicrosoftSuggestion(), getRemoteTTMServerBox(), and getTTMServerBox().

Here is the call graph for this function:

static TranslationHelpers::reportTranslationServiceFailure ( service  )  [static]

Increases the failure count for a given service.

Parameters:
$service 
Exceptions:
TranslationHelperException 

Definition at line 1396 of file TranslationHelpers.php.

Referenced by getApertiumSuggestion(), getMicrosoftSuggestion(), getRemoteTTMServerBox(), and getYandexSuggestion().

TranslationHelpers::setEditMode ( mode = true  ) 

Enable or disable extra help for editing.

Parameters:
$mode Boolean

Definition at line 97 of file TranslationHelpers.php.

TranslationHelpers::setTextareaId ( id  ) 

Sets the HTML id of the text area that contains the translation.

Parameters:
$id String

Definition at line 89 of file TranslationHelpers.php.

TranslationHelpers::setTranslation ( translation  ) 

Manual override for the translation.

If not given or it is null, the code will try to fetch it automatically.

Parameters:
string|null $translation

Definition at line 148 of file TranslationHelpers.php.

TranslationHelpers::suggestionField ( text  ) 
Parameters:
$text string
Returns:
string

Definition at line 1302 of file TranslationHelpers.php.

Referenced by formatTTMServerSuggestions(), getApertiumSuggestion(), getMicrosoftSuggestion(), and getYandexSuggestion().

Here is the call graph for this function:

static TranslationHelpers::unwrapUntranslatable ( text  )  [static, protected]

Definition at line 577 of file TranslationHelpers.php.

Referenced by getMicrosoftSuggestion().

TranslationHelpers::wrapInsert ( id,
text 
)
Parameters:
$id string|int
$text string
Returns:
string

Definition at line 1294 of file TranslationHelpers.php.

Referenced by getDefinitionBox(), getOtherLanguagesBox(), and suggestionField().

static TranslationHelpers::wrapUntranslatable ( text  )  [static, protected]

Definition at line 568 of file TranslationHelpers.php.

Referenced by getMicrosoftSuggestion().


Member Data Documentation

TranslationHelpers::$definition [protected]

The message definition as a string.

Definition at line 36 of file TranslationHelpers.php.

Referenced by getMicrosoftSuggestion(), getRemoteTTMServerBox(), getTTMServerBox(), and makeGoogleQueryParams().

TranslationHelpers::$editMode = 'true' [protected]

Whether to include extra tools to aid translating.

Definition at line 45 of file TranslationHelpers.php.

TranslationHelpers::$group [protected]

Definition at line 27 of file TranslationHelpers.php.

Referenced by formatGettextComments().

TranslationHelpers::$handle [protected]

Definition at line 22 of file TranslationHelpers.php.

Referenced by ajaxEditLink().

TranslationHelpers::$serviceFailureCount = 5 [static, protected]

How many failures during failure period need to happen to consider the service being temporarily off-line.

Definition at line 1351 of file TranslationHelpers.php.

TranslationHelpers::$serviceFailurePeriod = 900 [static, protected]

How long after the last detected failure we clear the status and try again.

Definition at line 1356 of file TranslationHelpers.php.

TranslationHelpers::$textareaId = 'wpTextbox1' [protected]

HTML id to the text area that contains the translation.

Used to insert suggestion directly into the text area, for example.

Definition at line 41 of file TranslationHelpers.php.

TranslationHelpers::$translation [protected]

The current translation as a string.

Definition at line 32 of file TranslationHelpers.php.

Referenced by getCheckBox(), and setTranslation().


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