A very basic FileFormatSupport module that implements some basic functionality and a simple binary based file format. More...
Public Member Functions | |
supportsFuzzy () | |
Query the capabilities of this FFS. | |
getFileExtensions () | |
Return the commonly used file extensions for these formats. | |
__construct (FileBasedMessageGroup $group) | |
setGroup (FileBasedMessageGroup $group) | |
getGroup () | |
setWritePath (string $target) | |
Set the file's location in the system. | |
getWritePath () | |
Get the file's location in the system. | |
exists ( $code=false) | |
Returns true if the file for this message group in a given language exists. | |
read (string $languageCode) | |
Reads messages from the file in a given language and returns an array of AUTHORS, MESSAGES and possibly other properties. | |
readFromVariable (string $data) | |
Parse the message data given as a string in the SimpleFormat format and return it as an array of AUTHORS and MESSAGES. | |
write (MessageCollection $collection) | |
Write the collection to file. | |
writeIntoVariable (MessageCollection $collection) | |
Read a collection and return it as a SimpleFormat formatted string. | |
filterAuthors (array $authors, string $code) | |
Remove excluded authors. | |
isContentEqual (?string $a, ?string $b) | |
Checks whether two strings are equal. | |
shouldOverwrite (string $a, string $b) | |
Allows to skip writing the export output into a file. | |
isGroupFfsReadable () | |
Check if the file format of the current group is readable by the file format system. | |
Protected Member Functions | |
writeReal (MessageCollection $collection) | |
tryReadSource (string $filename, MessageCollection $collection) | |
This tries to pick up external authors in the source files so that they are not lost if those authors are not among those who have translated in the wiki. | |
tryReadFile (string $filename) | |
Read the contents of $filename and return it as a string. | |
Protected Attributes | |
FileBasedMessageGroup | $group |
string | $writePath = null |
$extra | |
A very basic FileFormatSupport module that implements some basic functionality and a simple binary based file format.
Other FFS classes can extend SimpleFormat and override suitable methods.
Definition at line 24 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::__construct | ( | FileBasedMessageGroup | $group | ) |
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 46 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::exists | ( | $code = false | ) |
Returns true if the file for this message group in a given language exists.
If no $code is given, the groups source language is assumed. NB: Some formats store all languages in the same file, and then this function will return true even if there are no translations to that language.
string | bool | $code |
Definition at line 77 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::filterAuthors | ( | array | $authors, |
string | $code ) |
Remove excluded authors.
Definition at line 294 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::getFileExtensions | ( | ) |
Return the commonly used file extensions for these formats.
Include the dot.
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Reimplemented in MediaWiki\Extension\Translate\FileFormatSupport\AmdFormat, MediaWiki\Extension\Translate\FileFormatSupport\AndroidXmlFormat, MediaWiki\Extension\Translate\FileFormatSupport\AppleFormat, MediaWiki\Extension\Translate\FileFormatSupport\DtdFormat, MediaWiki\Extension\Translate\FileFormatSupport\GettextFormat, MediaWiki\Extension\Translate\FileFormatSupport\IniFormat, MediaWiki\Extension\Translate\FileFormatSupport\JavaFormat, MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat, and MediaWiki\Extension\Translate\FileFormatSupport\YamlFormat.
Definition at line 30 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::getGroup | ( | ) |
Definition at line 56 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::getWritePath | ( | ) |
Get the file's location in the system.
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 64 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::isContentEqual | ( | ?string | $a, |
?string | $b ) |
Checks whether two strings are equal.
Sometimes same content might have multiple representations. The main case are inline plurals, which in some formats require expansion at export time.
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Reimplemented in MediaWiki\Extension\Translate\FileFormatSupport\AndroidXmlFormat, MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat, and MediaWiki\Extension\Translate\FileFormatSupport\YamlFormat.
Definition at line 306 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::isGroupFfsReadable | ( | ) |
Check if the file format of the current group is readable by the file format system.
This might happen if we are trying to export a JsonFormat or WikiPageMessage group to a GettextFormat.
Definition at line 319 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::read | ( | string | $languageCode | ) |
Reads messages from the file in a given language and returns an array of AUTHORS, MESSAGES and possibly other properties.
RuntimeException | if the file is not readable or has bad encoding |
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 97 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::readFromVariable | ( | string | $data | ) |
Parse the message data given as a string in the SimpleFormat format and return it as an array of AUTHORS and MESSAGES.
InvalidArgumentException |
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Reimplemented in MediaWiki\Extension\Translate\FileFormatSupport\AmdFormat, MediaWiki\Extension\Translate\FileFormatSupport\AndroidXmlFormat, MediaWiki\Extension\Translate\FileFormatSupport\AppleFormat, MediaWiki\Extension\Translate\FileFormatSupport\DtdFormat, MediaWiki\Extension\Translate\FileFormatSupport\GettextFormat, MediaWiki\Extension\Translate\FileFormatSupport\IniFormat, MediaWiki\Extension\Translate\FileFormatSupport\JavaFormat, MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat, and MediaWiki\Extension\Translate\FileFormatSupport\YamlFormat.
Definition at line 134 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::setGroup | ( | FileBasedMessageGroup | $group | ) |
Definition at line 52 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::setWritePath | ( | string | $target | ) |
Set the file's location in the system.
string | $target | Filesystem path for exported files. |
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 60 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::shouldOverwrite | ( | string | $a, |
string | $b ) |
Allows to skip writing the export output into a file.
This is useful to skip updates that would only update irrelevant parts, such as the timestamp of the export.
string | $a | The existing content. |
string | $b | The new export content. |
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 310 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::supportsFuzzy | ( | ) |
Query the capabilities of this FFS.
Allowed values are:
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Reimplemented in MediaWiki\Extension\Translate\FileFormatSupport\AndroidXmlFormat, MediaWiki\Extension\Translate\FileFormatSupport\AppleFormat, MediaWiki\Extension\Translate\FileFormatSupport\GettextFormat, MediaWiki\Extension\Translate\FileFormatSupport\IniFormat, and MediaWiki\Extension\Translate\FileFormatSupport\JavaFormat.
Definition at line 26 of file SimpleFormat.php.
|
protected |
Read the contents of $filename and return it as a string.
Return null if the file doesn't exist. Throw an exception if the file isn't readable or if the reading fails strangely.
InvalidArgumentException |
Definition at line 276 of file SimpleFormat.php.
|
protected |
This tries to pick up external authors in the source files so that they are not lost if those authors are not among those who have translated in the wiki.
Definition at line 251 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::write | ( | MessageCollection | $collection | ) |
Write the collection to file.
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 170 of file SimpleFormat.php.
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat::writeIntoVariable | ( | MessageCollection | $collection | ) |
Read a collection and return it as a SimpleFormat formatted string.
Implements MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport.
Definition at line 216 of file SimpleFormat.php.
|
protected |
Definition at line 223 of file SimpleFormat.php.
|
protected |
Definition at line 41 of file SimpleFormat.php.
|
protected |
Definition at line 34 of file SimpleFormat.php.
|
protected |
Definition at line 35 of file SimpleFormat.php.