Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\Statistics\MessageGroupStats Class Reference

This class aims to provide efficient mechanism for fetching translation completion stats. More...

Static Public Member Functions

static getEmptyStats ()
 Returns empty stats array.
 
static forItem (string $groupId, string $languageCode, int $flags=0)
 Returns stats for given group in given language.
 
static forLanguage (string $languageCode, int $flags=0)
 Returns stats for all groups in given language.
 
static forGroup (string $groupId, int $flags=0)
 Returns stats for all languages in given group.
 
static clear (MessageHandle $handle)
 Recalculate stats for all groups associated with the message.
 
static clearGroup ( $id, int $flags=0)
 Recalculate stats for given group(s).
 
static getApproximateLanguageStats ()
 Fetch aggregated statistics for all languages across groups.
 
static getLanguages ()
 Get list of supported languages for statistics.
 
static multiAdd (array $a, array $b)
 
static getDatabaseIdForGroupId (string $id)
 
static getStatsForCollection (MessageCollection $collection)
 

Public Attributes

const TOTAL = 0
 Array index.
 
const TRANSLATED = 1
 Array index.
 
const FUZZY = 2
 Array index.
 
const PROOFREAD = 3
 Array index.
 
const FLAG_CACHE_ONLY = 1
 If stats are not cached, do not attempt to calculate them on the fly.
 
const FLAG_NO_CACHE = 2
 Ignore cached values.
 
const FLAG_IMMEDIATE_WRITES = 4
 Do not defer updates.
 

Detailed Description

This class aims to provide efficient mechanism for fetching translation completion stats.

It abstracts MessageGroup statistics calculation and storing. You can access stats easily per language or per group. Stat array for each item is of format array( total, translate, fuzzy ).

Author
Wikia (trac.wikia-code.com/browser/wikia/trunk/extensions/wikia/TranslationStatistics)
Niklas Laxström @license GPL-2.0-or-later

Definition at line 33 of file MessageGroupStats.php.

Member Function Documentation

◆ clear()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::clear ( MessageHandle $handle)
static

Recalculate stats for all groups associated with the message.

Hook: TranslateEventTranslationReview

Parameters
MessageHandle$handle

Definition at line 170 of file MessageGroupStats.php.

◆ clearGroup()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::clearGroup ( $id,
int $flags = 0 )
static

Recalculate stats for given group(s).

Parameters
string | string[]$idMessage group ids.
int$flagsCombination of FLAG_* constants.

Definition at line 185 of file MessageGroupStats.php.

◆ forGroup()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::forGroup ( string $groupId,
int $flags = 0 )
static

Returns stats for all languages in given group.

Parameters
string$groupId
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 145 of file MessageGroupStats.php.

◆ forItem()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::forItem ( string $groupId,
string $languageCode,
int $flags = 0 )
static

Returns stats for given group in given language.

Parameters
string$groupId
string$languageCode
int$flagsCombination of FLAG_* constants.
Returns
null[]|int[]

Definition at line 92 of file MessageGroupStats.php.

◆ forLanguage()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::forLanguage ( string $languageCode,
int $flags = 0 )
static

Returns stats for all groups in given language.

Parameters
string$languageCode
int$flagsCombination of FLAG_* constants.
Returns
array[]

Definition at line 116 of file MessageGroupStats.php.

◆ getApproximateLanguageStats()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::getApproximateLanguageStats ( )
static

Fetch aggregated statistics for all languages across groups.

The stats are cached in the WANObjectCache, and recalculated on the fly if the values are stale. The statistics may lag behind the actuals due to extra and missing values

Returns
array[] ( Language Code => Language Stats )

Definition at line 201 of file MessageGroupStats.php.

◆ getDatabaseIdForGroupId()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::getDatabaseIdForGroupId ( string $id)
static

Definition at line 649 of file MessageGroupStats.php.

◆ getEmptyStats()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::getEmptyStats ( )
static

Returns empty stats array.

Useful because the number of elements may change.

Returns
int[]

Definition at line 60 of file MessageGroupStats.php.

◆ getLanguages()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::getLanguages ( )
static

Get list of supported languages for statistics.

Returns
string[]

Definition at line 298 of file MessageGroupStats.php.

◆ getStatsForCollection()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::getStatsForCollection ( MessageCollection $collection)
static
Returns
int[]

Definition at line 660 of file MessageGroupStats.php.

◆ multiAdd()

static MediaWiki\Extension\Translate\Statistics\MessageGroupStats::multiAdd ( array $a,
array $b )
static

Definition at line 553 of file MessageGroupStats.php.

Member Data Documentation

◆ FLAG_CACHE_ONLY

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::FLAG_CACHE_ONLY = 1

If stats are not cached, do not attempt to calculate them on the fly.

Definition at line 45 of file MessageGroupStats.php.

◆ FLAG_IMMEDIATE_WRITES

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::FLAG_IMMEDIATE_WRITES = 4

Do not defer updates.

Meant for jobs like RebuildMessageGroupStatsJob.

Definition at line 49 of file MessageGroupStats.php.

◆ FLAG_NO_CACHE

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::FLAG_NO_CACHE = 2

Ignore cached values.

Useful for updating stale values.

Definition at line 47 of file MessageGroupStats.php.

◆ FUZZY

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::FUZZY = 2

Array index.

Definition at line 41 of file MessageGroupStats.php.

◆ PROOFREAD

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::PROOFREAD = 3

Array index.

Definition at line 42 of file MessageGroupStats.php.

◆ TOTAL

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::TOTAL = 0

Array index.

Definition at line 39 of file MessageGroupStats.php.

◆ TRANSLATED

const MediaWiki\Extension\Translate\Statistics\MessageGroupStats::TRANSLATED = 1

Array index.

Definition at line 40 of file MessageGroupStats.php.


The documentation for this class was generated from the following file: