Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
SimpleFFS Class Reference
Inheritance diagram for SimpleFFS:
FFS AmdFFS AndroidXmlFFS AppleFFS DtdFFS GettextFFS IniFFS JavaFFS JavaScriptFFS JsonFFS XliffFFS YamlFFS

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 ( $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.
 
 readFromVariable ( $data)
 Parse the message data given as a string in the SimpleFFS 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 SimpleFFS formatted string.
 
 filterAuthors (array $authors, $code)
 Remove excluded authors.
 
 isContentEqual ( $a, $b)
 Checks whether two strings are equal.
 
 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.
 

Protected Member Functions

 writeReal (MessageCollection $collection)
 
 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.
 

Protected Attributes

 $group
 
 $writePath
 
 $extra
 Stores the FILES section of the YAML configuration, which can be accessed for extra FFS class specific options.
 

Detailed Description

Definition at line 20 of file SimpleFFS.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleFFS::__construct ( FileBasedMessageGroup $group)

Implements FFS.

Reimplemented in JavaFFS, JsonFFS, and YamlFFS.

Definition at line 41 of file SimpleFFS.php.

Member Function Documentation

◆ exists()

SimpleFFS::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.

Parameters
string | bool$code
Returns
bool

Definition at line 77 of file SimpleFFS.php.

◆ filterAuthors()

SimpleFFS::filterAuthors ( array $authors,
$code )

Remove excluded authors.

Parameters
array$authors
string$code
Returns
array

Definition at line 326 of file SimpleFFS.php.

◆ getFileExtensions()

SimpleFFS::getFileExtensions ( )

Return the commonly used file extensions for these formats.

Include the dot.

Returns
string[]
Since
2013-04

Implements FFS.

Reimplemented in AmdFFS, AndroidXmlFFS, AppleFFS, DtdFFS, GettextFFS, IniFFS, JavaFFS, JavaScriptFFS, JsonFFS, XliffFFS, and YamlFFS.

Definition at line 25 of file SimpleFFS.php.

◆ getGroup()

SimpleFFS::getGroup ( )
Returns
FileBasedMessageGroup

Definition at line 53 of file SimpleFFS.php.

◆ getWritePath()

SimpleFFS::getWritePath ( )
Returns
string

Implements FFS.

Definition at line 63 of file SimpleFFS.php.

◆ isContentEqual()

SimpleFFS::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

Implements FFS.

Reimplemented in AndroidXmlFFS, JsonFFS, and YamlFFS.

Definition at line 339 of file SimpleFFS.php.

◆ isGroupFfsReadable()

SimpleFFS::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 JsonFFS or WikiPageMessage group to a GettextFFS

Returns
bool

Definition at line 353 of file SimpleFFS.php.

◆ read()

SimpleFFS::read ( $code)

Reads messages from the file in a given language and returns an array of AUTHORS, MESSAGES and possibly other properties.

Parameters
string$codeLanguage code.
Returns
array|bool False if the file does not exist
Exceptions
MWExceptionif the file is not readable or has bad encoding

Implements FFS.

Reimplemented in GettextFFS, and XliffFFS.

Definition at line 98 of file SimpleFFS.php.

◆ readFromVariable()

SimpleFFS::readFromVariable ( $data)

Parse the message data given as a string in the SimpleFFS format and return it as an array of AUTHORS and MESSAGES.

Parameters
string$data
Returns
array Parsed data.
Exceptions
MWException

Implements FFS.

Reimplemented in AmdFFS, AndroidXmlFFS, AppleFFS, DtdFFS, GettextFFS, IniFFS, JavaFFS, JavaScriptFFS, JsonFFS, and YamlFFS.

Definition at line 137 of file SimpleFFS.php.

◆ setGroup()

SimpleFFS::setGroup ( FileBasedMessageGroup $group)
Parameters
FileBasedMessageGroup$group

Definition at line 48 of file SimpleFFS.php.

◆ setWritePath()

SimpleFFS::setWritePath ( $writePath)
Parameters
string$writePath

Implements FFS.

Definition at line 58 of file SimpleFFS.php.

◆ shouldOverwrite()

SimpleFFS::shouldOverwrite ( $a,
$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.

Parameters
string$aThe existing content.
string$bThe new export content.
Returns
bool
Since
2017.04

Implements FFS.

Definition at line 343 of file SimpleFFS.php.

◆ supportsFuzzy()

SimpleFFS::supportsFuzzy ( )

Query the capabilities of this FFS.

Allowed values are:

  • yes
  • write (ignored on read)
  • no (stripped on write)
    Returns
    string
    Since
    2013-03-05

Implements FFS.

Reimplemented in AndroidXmlFFS, AppleFFS, GettextFFS, IniFFS, JavaFFS, and XliffFFS.

Definition at line 21 of file SimpleFFS.php.

◆ tryReadFile()

SimpleFFS::tryReadFile ( $filename)
protected

Read the contents of $filename and return it as a string.

Return false if the file doesn't exist. Throw an exception if the file isn't readable or if the reading fails strangely.

Parameters
string$filename
Returns
bool|string
Exceptions
MWException

Definition at line 298 of file SimpleFFS.php.

◆ tryReadSource()

SimpleFFS::tryReadSource ( $filename,
MessageCollection $collection )
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.

Todo
Get rid of this
Parameters
string$filename
MessageCollection$collection

Definition at line 270 of file SimpleFFS.php.

◆ write()

SimpleFFS::write ( MessageCollection $collection)

Write the collection to file.

Parameters
MessageCollection$collection
Exceptions
MWException

Implements FFS.

Definition at line 178 of file SimpleFFS.php.

◆ writeIntoVariable()

SimpleFFS::writeIntoVariable ( MessageCollection $collection)

Read a collection and return it as a SimpleFFS formatted string.

Parameters
MessageCollection$collection
Returns
string

Implements FFS.

Definition at line 229 of file SimpleFFS.php.

◆ writeReal()

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

Reimplemented in AmdFFS, AndroidXmlFFS, AppleFFS, DtdFFS, GettextFFS, IniFFS, JavaFFS, JavaScriptFFS, JsonFFS, XliffFFS, and YamlFFS.

Definition at line 240 of file SimpleFFS.php.

Member Data Documentation

◆ $extra

SimpleFFS::$extra
protected

Stores the FILES section of the YAML configuration, which can be accessed for extra FFS class specific options.

Definition at line 36 of file SimpleFFS.php.

◆ $group

SimpleFFS::$group
protected

Definition at line 30 of file SimpleFFS.php.

◆ $writePath

SimpleFFS::$writePath
protected

Definition at line 31 of file SimpleFFS.php.


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