Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat Class Reference

JsonFormat implements a message format where messages are encoded as key-value pairs in JSON objects. More...

Inheritance diagram for MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat:
MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat MediaWiki\Extension\Translate\FileFormatSupport\FileFormatSupport

Public Member Functions

 __construct (FileBasedMessageGroup $group)
 
 getFileExtensions ()
 Return the commonly used file extensions for these formats.
 
 readFromVariable (string $data)
 
 generateFile (array $template)
 
 isContentEqual (?string $a, ?string $b)
 Checks whether two strings are equal.
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat
 supportsFuzzy ()
 Query the capabilities of this FFS.
 
 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.
 
 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.
 
 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.
 

Static Public Member Functions

static isValid (string $data)
 
static getExtraSchema ()
 

Protected Member Functions

 writeReal (MessageCollection $collection)
 
- Protected Member Functions inherited from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat
 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.
 

Additional Inherited Members

- Protected Attributes inherited from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat
FileBasedMessageGroup $group
 
string $writePath = null
 
 $extra
 

Detailed Description

JsonFormat implements a message format where messages are encoded as key-value pairs in JSON objects.

The format is extended to support author information under the special @metadata key.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 21 of file JsonFormat.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::__construct ( FileBasedMessageGroup $group)

Reimplemented from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat.

Definition at line 28 of file JsonFormat.php.

Member Function Documentation

◆ generateFile()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::generateFile ( array $template)

Definition at line 97 of file JsonFormat.php.

◆ getExtraSchema()

static MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::getExtraSchema ( )
static

Definition at line 136 of file JsonFormat.php.

◆ getFileExtensions()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::getFileExtensions ( )

Return the commonly used file extensions for these formats.

Include the dot.

Returns
string[]

Reimplemented from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat.

Definition at line 33 of file JsonFormat.php.

◆ isContentEqual()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::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.

Reimplemented from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat.

Definition at line 128 of file JsonFormat.php.

◆ isValid()

static MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::isValid ( string $data)
static

Definition at line 24 of file JsonFormat.php.

◆ readFromVariable()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::readFromVariable ( string $data)
Returns
array Parsed data.

Reimplemented from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat.

Definition at line 38 of file JsonFormat.php.

◆ writeReal()

MediaWiki\Extension\Translate\FileFormatSupport\JsonFormat::writeReal ( MessageCollection $collection)
protected

Reimplemented from MediaWiki\Extension\Translate\FileFormatSupport\SimpleFormat.

Definition at line 67 of file JsonFormat.php.


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