Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\MessageLoading\MessageCollection Class Reference

This file contains the class for core message collections implementation. More...

Inheritance diagram for MediaWiki\Extension\Translate\MessageLoading\MessageCollection:

Public Member Functions

 __construct (string $code)
 Constructors.
 
 getLanguage ()
 
 setInFile (array $messages)
 Set translation from file, as opposed to translation which only exists in the wiki because they are not exported and committed yet.
 
 setTags (string $type, array $keys)
 Set message tags.
 
 keys ()
 Returns list of available message keys.
 
 getMessageKeys ()
 Returns list of message keys that are used in this collection after filtering.
 
 getTags (string $type)
 Returns stored message tags.
 
 getAuthors ()
 Lists all translators that have contributed to the latest revisions of each translation.
 
 addCollectionAuthors (array $authors, string $mode='append')
 Add external authors (usually from the file).
 
 loadTranslations ()
 Loads all message data.
 
 resetForNewLanguage (string $code)
 Some statistics scripts for example loop the same collection over every language.
 
 slice ( $offset, $limit)
 For paging messages.
 
 filter (string $filter, bool $condition, ?int $value=null)
 Filters messages based on some condition.
 
 filterUntranslatedOptional ()
 
 initMessages ()
 Constructs all Messages (ThinMessage) from the data accumulated so far.
 
 offsetExists ( $offset)
 ArrayAccess methods.
 
 offsetGet ( $offset)
 
 offsetSet ( $offset, $value)
 
 offsetUnset ( $offset)
 
 __get (string $name)
 Fail fast if trying to access unknown properties.
 
 __set (string $name, $value)
 Fail fast if trying to access unknown properties.
 
 rewind ()
 Iterator method.
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 count ()
 

Static Public Member Functions

static newFromDefinitions (MessageDefinitions $definitions, string $code)
 Construct a new message collection from definitions.
 

Public Attributes

const FILTER_FUZZY = 'fuzzy'
 
const FILTER_OPTIONAL = 'optional'
 
const FILTER_IGNORED = 'ignored'
 
const FILTER_HAS_TRANSLATION = 'hastranslation'
 
const FILTER_CHANGED = 'changed'
 
const FILTER_TRANSLATED = 'translated'
 
const FILTER_REVIEWER = 'reviewer'
 
const FILTER_LAST_TRANSLATOR = 'last-translator'
 
const INCLUDE_MATCHING = false
 
const EXCLUDE_MATCHING = true
 
string $code
 Language code.
 

Protected Attributes

array $keys = []
 
array $messages = []
 array( Message String => Message, ... )
 
array $tags = []
 

Detailed Description

This file contains the class for core message collections implementation.

Message collection is collection of messages of one message group in one language. It handles loading of the messages in one huge batch, and also stores information that can be used to filter the collection in different ways.

Author
Niklas Laxström

Definition at line 38 of file MessageCollection.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__construct ( string $code)

Constructors.

Use newFromDefinitions() instead.

Parameters
string$codeLanguage code.

Definition at line 100 of file MessageCollection.php.

Member Function Documentation

◆ __get()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__get ( string $name)

Fail fast if trying to access unknown properties.

Returns
never

Definition at line 916 of file MessageCollection.php.

◆ __set()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__set ( string $name,
$value )

Fail fast if trying to access unknown properties.

Parameters
mixed$value
Returns
never

Definition at line 925 of file MessageCollection.php.

◆ addCollectionAuthors()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::addCollectionAuthors ( array $authors,
string $mode = 'append' )

Add external authors (usually from the file).

Parameters
string[]$authorsList of authors.
string$modeEither append or set authors.

Definition at line 219 of file MessageCollection.php.

◆ count()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::count ( )

Definition at line 961 of file MessageCollection.php.

◆ current()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::current ( )
Returns
Message|false

Definition at line 940 of file MessageCollection.php.

◆ filter()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::filter ( string $filter,
bool $condition,
?int $value = null )

Filters messages based on some condition.

Some filters cause data to be loaded from the database:

  • PAGEINFO: existence and fuzzy tags.
  • TRANSLATIONS: translations for every message. It is recommended to first filter with messages that do not need those. It is recommended to add translations from file with addInfile, and it is needed for changed filter to work.
Parameters
string$filter
  • FILTER_FUZZY: messages with fuzzy tag (PAGEINFO)
  • FILTER_OPTIONAL: messages marked for optional.
  • FILTER_IGNORED: messages which are not for translation.
  • FILTER_HAS_TRANSLATION: messages which have translation (be if fuzzy or not) (PAGEINFO, *INFILE).
  • FILTER_TRANSLATED: messages which have translation which is not fuzzy (PAGEINFO, *INFILE).
  • FILTER_CHANGED: translation in database differs from infile. (INFILE, TRANSLATIONS)
  • FILTER_REVIEWER: messages which are reviewed by a particular user
  • FILTER_LAST_TRANSLATOR: messages which are last translated by a particular user
bool$conditionWhether to return messages which do not satisfy the given filter condition (true), or only which do (false).
int | null$valueValue for properties filtering.
Exceptions
InvalidFilterExceptionIf given invalid filter name.

Definition at line 351 of file MessageCollection.php.

◆ filterUntranslatedOptional()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::filterUntranslatedOptional ( )

Definition at line 389 of file MessageCollection.php.

◆ getAuthors()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getAuthors ( )

Lists all translators that have contributed to the latest revisions of each translation.

Causes translations to be loaded from the database. Is not affected by filters.

Returns
string[] List of usernames.

Definition at line 180 of file MessageCollection.php.

◆ getLanguage()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getLanguage ( )

Definition at line 117 of file MessageCollection.php.

◆ getMessageKeys()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getMessageKeys ( )

Returns list of message keys that are used in this collection after filtering.

Returns
string[]

Definition at line 161 of file MessageCollection.php.

◆ getTags()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getTags ( string $type)

Returns stored message tags.

Parameters
string$typeTag type, usually optional or ignored.
Returns
string[] List of keys with given tag.

Definition at line 170 of file MessageCollection.php.

◆ initMessages()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::initMessages ( )

Constructs all Messages (ThinMessage) from the data accumulated so far.

Usually there is no need to call this method directly.

Definition at line 800 of file MessageCollection.php.

◆ key()

array< string, TitleValue > Key is message display MediaWiki\Extension\Translate\MessageLoading\MessageCollection::key ( )

Definition at line 949 of file MessageCollection.php.

◆ keys()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::keys ( )

Returns list of available message keys.

This is affected by filtering.

Returns
array<string, TitleValue> List of database keys indexed by display keys.

Definition at line 145 of file MessageCollection.php.

◆ loadTranslations()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::loadTranslations ( )

Loads all message data.

Must be called before accessing the messages with ArrayAccess or iteration.

Definition at line 239 of file MessageCollection.php.

◆ newFromDefinitions()

static MediaWiki\Extension\Translate\MessageLoading\MessageCollection::newFromDefinitions ( MessageDefinitions $definitions,
string $code )
static

Construct a new message collection from definitions.

Parameters
MessageDefinitions$definitions
string$codeLanguage code.

Definition at line 109 of file MessageCollection.php.

◆ next()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::next ( )

Definition at line 953 of file MessageCollection.php.

◆ offsetExists()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetExists ( $offset)

ArrayAccess methods.

Parameters
mixed$offset

Definition at line 888 of file MessageCollection.php.

◆ offsetGet()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetGet ( $offset)
Parameters
mixed$offset

Definition at line 893 of file MessageCollection.php.

◆ offsetSet()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetSet ( $offset,
$value )
Parameters
mixed$offset
mixed$value

Definition at line 901 of file MessageCollection.php.

◆ offsetUnset()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetUnset ( $offset)
Parameters
mixed$offset

Definition at line 906 of file MessageCollection.php.

◆ resetForNewLanguage()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::resetForNewLanguage ( string $code)

Some statistics scripts for example loop the same collection over every language.

This is a shortcut which keeps tags and definitions.

Definition at line 255 of file MessageCollection.php.

◆ rewind()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::rewind ( )

Iterator method.

Definition at line 934 of file MessageCollection.php.

◆ setInFile()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::setInFile ( array $messages)

Set translation from file, as opposed to translation which only exists in the wiki because they are not exported and committed yet.

Parameters
string[]$messagesArray of translations indexed by display key.

Definition at line 128 of file MessageCollection.php.

◆ setTags()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::setTags ( string $type,
array $keys )

Set message tags.

Parameters
string$typeTag type, usually ignored or optional.
string[]$keysList of display keys.

Definition at line 137 of file MessageCollection.php.

◆ slice()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::slice ( $offset,
$limit )

For paging messages.

One can count messages before and after slice.

Parameters
string$offset
int$limit
Returns
array Offsets that can be used for paging backwards and forwards
Since
String offests and return value since 2013-01-10

Definition at line 276 of file MessageCollection.php.

◆ valid()

MediaWiki\Extension\Translate\MessageLoading\MessageCollection::valid ( )

Definition at line 957 of file MessageCollection.php.

Member Data Documentation

◆ $code

string MediaWiki\Extension\Translate\MessageLoading\MessageCollection::$code

Language code.

Definition at line 68 of file MessageCollection.php.

◆ $keys

array MediaWiki\Extension\Translate\MessageLoading\MessageCollection::$keys = []
protected

Definition at line 75 of file MessageCollection.php.

◆ $messages

array MediaWiki\Extension\Translate\MessageLoading\MessageCollection::$messages = []
protected

array( Message String => Message, ... )

Definition at line 77 of file MessageCollection.php.

◆ $tags

array MediaWiki\Extension\Translate\MessageLoading\MessageCollection::$tags = []
protected

Definition at line 92 of file MessageCollection.php.

◆ EXCLUDE_MATCHING

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::EXCLUDE_MATCHING = true

Definition at line 65 of file MessageCollection.php.

◆ FILTER_CHANGED

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_CHANGED = 'changed'

Definition at line 50 of file MessageCollection.php.

◆ FILTER_FUZZY

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_FUZZY = 'fuzzy'

Definition at line 46 of file MessageCollection.php.

◆ FILTER_HAS_TRANSLATION

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_HAS_TRANSLATION = 'hastranslation'

Definition at line 49 of file MessageCollection.php.

◆ FILTER_IGNORED

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_IGNORED = 'ignored'

Definition at line 48 of file MessageCollection.php.

◆ FILTER_LAST_TRANSLATOR

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_LAST_TRANSLATOR = 'last-translator'

Definition at line 53 of file MessageCollection.php.

◆ FILTER_OPTIONAL

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_OPTIONAL = 'optional'

Definition at line 47 of file MessageCollection.php.

◆ FILTER_REVIEWER

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_REVIEWER = 'reviewer'

Definition at line 52 of file MessageCollection.php.

◆ FILTER_TRANSLATED

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_TRANSLATED = 'translated'

Definition at line 51 of file MessageCollection.php.

◆ INCLUDE_MATCHING

const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::INCLUDE_MATCHING = false

Definition at line 64 of file MessageCollection.php.


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