Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
YamlFFS Class Reference

Implements support for message storage in YAML format. More...

Inheritance diagram for YamlFFS:
SimpleFFS MetaYamlSchemaExtender FFS

Public Member Functions

 __construct (FileBasedMessageGroup $group)
 
 getFileExtensions ()
 Return the commonly used file extensions for these formats.
 
 readFromVariable ( $data)
 
 isContentEqual ( $a, $b)
 Checks whether two strings are equal.
 
- Public Member Functions inherited from SimpleFFS
 supportsFuzzy ()
 Query the capabilities of this FFS.
 
 setGroup (FileBasedMessageGroup $group)
 
 getGroup ()
 
 setWritePath ( $writePath)
 
 getWritePath ()
 
 exists ( $code=false)
 Returns true if the file for this message group in a given language exists.
 
 read ( $code)
 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 SimpleFFS formatted string.
 
 filterAuthors (array $authors, $code)
 Remove excluded authors.
 
 shouldOverwrite ( $a, $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 getExtraSchema ()
 Return a data structure that will be merged with the base schema.
 
- Static Public Member Functions inherited from SimpleFFS
static fixNewLines ( $data)
 Replaces all Windows and Mac line endings with Unix line endings.
 

Protected Member Functions

 writeReal (MessageCollection $collection)
 
 doHeader (MessageCollection $collection)
 
 doAuthors (MessageCollection $collection)
 
 getFlattener ()
 Obtains object used to flatten and unflatten arrays.
 
 flatten ( $messages)
 Flattens multidimensional array by using the path to the value as key with each individual key separated by a dot.
 
 unflatten ( $messages)
 Performs the reverse operation of flatten.
 
- Protected Member Functions inherited from SimpleFFS
 tryReadSource ( $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 ( $filename)
 Read the contents of $filename and return it as a string.
 

Additional Inherited Members

- Protected Attributes inherited from SimpleFFS
 $group
 
 $writePath
 
 $extra
 Stores the FILES section of the YAML configuration, which can be accessed for extra FFS class specific options.
 

Detailed Description

Implements support for message storage in YAML format.

This class adds new key into FILES section: codeAsRoot. If it is set to true, all messages will under language code.

Definition at line 12 of file YamlFFS.php.

Constructor & Destructor Documentation

◆ __construct()

YamlFFS::__construct ( FileBasedMessageGroup $group)
Parameters
FileBasedMessageGroup$group

Reimplemented from SimpleFFS.

Definition at line 17 of file YamlFFS.php.

Member Function Documentation

◆ doAuthors()

YamlFFS::doAuthors ( MessageCollection $collection)
protected
Parameters
MessageCollection$collection
Returns
string

Definition at line 124 of file YamlFFS.php.

◆ doHeader()

YamlFFS::doHeader ( MessageCollection $collection)
protected
Parameters
MessageCollection$collection
Returns
string

Definition at line 102 of file YamlFFS.php.

◆ flatten()

YamlFFS::flatten ( $messages)
protected

Flattens multidimensional array by using the path to the value as key with each individual key separated by a dot.

Parameters
array$messages
Returns
array

Definition at line 158 of file YamlFFS.php.

◆ getExtraSchema()

static YamlFFS::getExtraSchema ( )
static

Return a data structure that will be merged with the base schema.

It is not possible to remove things.

Returns
array

Implements MetaYamlSchemaExtender.

Definition at line 178 of file YamlFFS.php.

◆ getFileExtensions()

YamlFFS::getFileExtensions ( )

Return the commonly used file extensions for these formats.

Include the dot.

Returns
string[]
Since
2013-04

Reimplemented from SimpleFFS.

Definition at line 22 of file YamlFFS.php.

◆ getFlattener()

YamlFFS::getFlattener ( )
protected

Obtains object used to flatten and unflatten arrays.

In this implementation we use the ArrayFlattener class which also supports CLDR pluralization rules.

Returns
ArrayFlattener with flatten, unflatten methods

Definition at line 142 of file YamlFFS.php.

◆ isContentEqual()

YamlFFS::isContentEqual ( $a,
$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.

Parameters
string$a
string$b
Returns
bool
Since
2016.11

Reimplemented from SimpleFFS.

Definition at line 174 of file YamlFFS.php.

◆ readFromVariable()

YamlFFS::readFromVariable ( $data)
Parameters
string$data
Returns
array Parsed data.

Reimplemented from SimpleFFS.

Definition at line 30 of file YamlFFS.php.

◆ unflatten()

YamlFFS::unflatten ( $messages)
protected

Performs the reverse operation of flatten.

Each dot (or custom separator) in the key starts a new subarray in the final array.

Parameters
array$messages
Returns
array

Definition at line 170 of file YamlFFS.php.

◆ writeReal()

YamlFFS::writeReal ( MessageCollection $collection)
protected
Parameters
MessageCollection$collection
Returns
string

Reimplemented from SimpleFFS.

Definition at line 60 of file YamlFFS.php.


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