This file contains the class for core message collections implementation. More...
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 = [] |
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.
Definition at line 39 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__construct | ( | string | $code | ) |
Constructors.
Use newFromDefinitions() instead.
string | $code | Language code. |
Definition at line 101 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__get | ( | string | $name | ) |
Fail fast if trying to access unknown properties.
Definition at line 922 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::__set | ( | string | $name, |
$value ) |
Fail fast if trying to access unknown properties.
mixed | $value |
Definition at line 931 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::addCollectionAuthors | ( | array | $authors, |
string | $mode = 'append' ) |
Add external authors (usually from the file).
string[] | $authors | List of authors. |
string | $mode | Either append or set authors. |
Definition at line 220 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::count | ( | ) |
Definition at line 967 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::current | ( | ) |
Definition at line 946 of file MessageCollection.php.
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:
string | $filter |
|
bool | $condition | Whether to return messages which do not satisfy the given filter condition (true), or only which do (false). |
int | null | $value | Value for properties filtering. |
InvalidFilterException | If given invalid filter name. |
Definition at line 352 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::filterUntranslatedOptional | ( | ) |
Definition at line 390 of file MessageCollection.php.
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.
Definition at line 181 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getLanguage | ( | ) |
Definition at line 118 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getMessageKeys | ( | ) |
Returns list of message keys that are used in this collection after filtering.
Definition at line 162 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::getTags | ( | string | $type | ) |
Returns stored message tags.
string | $type | Tag type, usually optional or ignored. |
Definition at line 171 of file MessageCollection.php.
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 806 of file MessageCollection.php.
array< string, TitleValue > Key is message display MediaWiki\Extension\Translate\MessageLoading\MessageCollection::key | ( | ) |
Definition at line 955 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::keys | ( | ) |
Returns list of available message keys.
This is affected by filtering.
Definition at line 146 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::loadTranslations | ( | ) |
Loads all message data.
Must be called before accessing the messages with ArrayAccess or iteration.
Definition at line 240 of file MessageCollection.php.
|
static |
Construct a new message collection from definitions.
MessageDefinitions | $definitions | |
string | $code | Language code. |
Definition at line 110 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::next | ( | ) |
Definition at line 959 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetExists | ( | $offset | ) |
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetGet | ( | $offset | ) |
mixed | $offset |
Definition at line 899 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetSet | ( | $offset, | |
$value ) |
mixed | $offset | |
mixed | $value |
Definition at line 907 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::offsetUnset | ( | $offset | ) |
mixed | $offset |
Definition at line 912 of file MessageCollection.php.
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 256 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::rewind | ( | ) |
Iterator method.
Definition at line 940 of file MessageCollection.php.
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.
string[] | $messages | Array of translations indexed by display key. |
Definition at line 129 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::setTags | ( | string | $type, |
array | $keys ) |
Set message tags.
string | $type | Tag type, usually ignored or optional. |
string[] | $keys | List of display keys. |
Definition at line 138 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::slice | ( | $offset, | |
$limit ) |
For paging messages.
One can count messages before and after slice.
string | $offset | |
int | $limit |
Definition at line 277 of file MessageCollection.php.
MediaWiki\Extension\Translate\MessageLoading\MessageCollection::valid | ( | ) |
Definition at line 963 of file MessageCollection.php.
string MediaWiki\Extension\Translate\MessageLoading\MessageCollection::$code |
Language code.
Definition at line 69 of file MessageCollection.php.
|
protected |
Definition at line 76 of file MessageCollection.php.
|
protected |
array( Message String => Message, ... )
Definition at line 78 of file MessageCollection.php.
|
protected |
Definition at line 93 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::EXCLUDE_MATCHING = true |
Definition at line 66 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_CHANGED = 'changed' |
Definition at line 51 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_FUZZY = 'fuzzy' |
Definition at line 47 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_HAS_TRANSLATION = 'hastranslation' |
Definition at line 50 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_IGNORED = 'ignored' |
Definition at line 49 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_LAST_TRANSLATOR = 'last-translator' |
Definition at line 54 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_OPTIONAL = 'optional' |
Definition at line 48 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_REVIEWER = 'reviewer' |
Definition at line 53 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::FILTER_TRANSLATED = 'translated' |
Definition at line 52 of file MessageCollection.php.
const MediaWiki\Extension\Translate\MessageLoading\MessageCollection::INCLUDE_MATCHING = false |
Definition at line 65 of file MessageCollection.php.