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

New-style FFS class that implements support for gettext file format. More...

Inheritance diagram for GettextFFS:
SimpleFFS MetaYamlSchemaExtender FFS

Public Member Functions

 supportsFuzzy ()
 Query the capabilities of this FFS.
 
 getFileExtensions ()
 Return the commonly used file extensions for these formats.
 
 setOfflineMode ( $value)
 
 read ( $code)
 @inheritDoc
 
 readFromVariable ( $data)
 
 parseGettext ( $data)
 
 shouldOverwrite ( $a, $b)
 Allows to skip writing the export output into a file.
 
 isContentEqual ( $a, $b)
 Checks whether two strings are equal.
 
- Public Member Functions inherited from SimpleFFS
 __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.
 
 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.
 
 isGroupFfsReadable ()
 Check if the file format of the current group is readable by the file format system.
 

Static Public Member Functions

static parseGettextData ( $data, $useCtxtAsKey, StringMangler $mangler, $keyAlgorithm, bool $allowPotMode)
 Parses gettext file as string into internal representation.
 
static parseGettextSection ( $section, $pluralCount)
 
static processGettextPluralMessage ( $pluralCount, $section)
 
static parseFlags ( $section)
 
static expectKeyword ( $name, $section)
 
static generateKeyFromItem (array $item, $algorithm='simple')
 Generates unique key for each message.
 
static formatForWiki ( $data, $whitespace='mark')
 This parses the Gettext text block format.
 
static parseHeaderTags ( $headers)
 
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)
 
 doGettextHeader (MessageCollection $collection, $template)
 
 doAuthors (MessageCollection $collection)
 
 formatMessageBlock ( $key, $m, $trans, $pot, $pluralCount)
 
 getPotTime ()
 
 getGenerator ()
 
 formatDocumentation ( $key)
 
- 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.
 

Static Protected Member Functions

static chainGetter ( $key, $a, $b, $default)
 
static formatTime ( $time)
 
static escape ( $line)
 

Protected Attributes

 $offlineMode = false
 
- 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

New-style FFS class that implements support for gettext file format.

Definition at line 20 of file GettextFFS.php.

Member Function Documentation

◆ chainGetter()

static GettextFFS::chainGetter ( $key,
$a,
$b,
$default )
staticprotected
Parameters
string$key
array$a
array$b
mixed$default
Returns
mixed

Definition at line 567 of file GettextFFS.php.

◆ doAuthors()

GettextFFS::doAuthors ( MessageCollection $collection)
protected

Definition at line 477 of file GettextFFS.php.

◆ doGettextHeader()

GettextFFS::doGettextHeader ( MessageCollection $collection,
$template )
protected

Definition at line 418 of file GettextFFS.php.

◆ escape()

static GettextFFS::escape ( $line)
staticprotected

Definition at line 614 of file GettextFFS.php.

◆ expectKeyword()

static GettextFFS::expectKeyword ( $name,
$section )
static

Definition at line 298 of file GettextFFS.php.

◆ formatDocumentation()

GettextFFS::formatDocumentation ( $key)
protected

Definition at line 588 of file GettextFFS.php.

◆ formatForWiki()

static GettextFFS::formatForWiki ( $data,
$whitespace = 'mark' )
static

This parses the Gettext text block format.

Since trailing whitespace is not allowed in MediaWiki pages, the default action is to append -character at the end of the message. You can also choose to ignore it and use the trim action instead.

Parameters
string$data
string$whitespace
Exceptions
MWException
Returns
string

Definition at line 358 of file GettextFFS.php.

◆ formatMessageBlock()

GettextFFS::formatMessageBlock ( $key,
$m,
$trans,
$pot,
$pluralCount )
protected
Parameters
string$key
TMessage$m
array$trans
array$pot
int$pluralCount
Returns
string

Definition at line 497 of file GettextFFS.php.

◆ formatTime()

static GettextFFS::formatTime ( $time)
staticprotected

Definition at line 571 of file GettextFFS.php.

◆ generateKeyFromItem()

static GettextFFS::generateKeyFromItem ( array $item,
$algorithm = 'simple' )
static

Generates unique key for each message.

Changing this WILL BREAK ALL existing pages!

Parameters
array$itemAs returned by parseGettextSection
string$algorithmAlgorithm used to generate message keys: simple or legacy
Returns
string

Definition at line 319 of file GettextFFS.php.

◆ getExtraSchema()

static GettextFFS::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 633 of file GettextFFS.php.

◆ getFileExtensions()

GettextFFS::getFileExtensions ( )

Return the commonly used file extensions for these formats.

Include the dot.

Returns
string[]
Since
2013-04

Reimplemented from SimpleFFS.

Definition at line 28 of file GettextFFS.php.

◆ getGenerator()

GettextFFS::getGenerator ( )
protected

Definition at line 583 of file GettextFFS.php.

◆ getPotTime()

GettextFFS::getPotTime ( )
protected

Definition at line 577 of file GettextFFS.php.

◆ isContentEqual()

GettextFFS::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 660 of file GettextFFS.php.

◆ parseFlags()

static GettextFFS::parseFlags ( $section)
static

Definition at line 289 of file GettextFFS.php.

◆ parseGettext()

GettextFFS::parseGettext ( $data)

Definition at line 73 of file GettextFFS.php.

◆ parseGettextData()

static GettextFFS::parseGettextData ( $data,
$useCtxtAsKey,
StringMangler $mangler,
$keyAlgorithm,
bool $allowPotMode )
static

Parses gettext file as string into internal representation.

Parameters
string$data
bool$useCtxtAsKeyWhether to create message keys from the context or use msgctxt (non-standard po-files)
StringMangler$mangler
string$keyAlgorithmKey generation algorithm, see generateKeyFromItem
bool$allowPotMode
Exceptions
MWException
Returns
array

Definition at line 95 of file GettextFFS.php.

◆ parseGettextSection()

static GettextFFS::parseGettextSection ( $section,
$pluralCount )
static

Definition at line 188 of file GettextFFS.php.

◆ parseHeaderTags()

static GettextFFS::parseHeaderTags ( $headers)
static

Definition at line 377 of file GettextFFS.php.

◆ processGettextPluralMessage()

static GettextFFS::processGettextPluralMessage ( $pluralCount,
$section )
static

Definition at line 268 of file GettextFFS.php.

◆ read()

GettextFFS::read ( $code)

@inheritDoc

Reimplemented from SimpleFFS.

Definition at line 38 of file GettextFFS.php.

◆ readFromVariable()

GettextFFS::readFromVariable ( $data)
Parameters
string$data
Returns
array

Reimplemented from SimpleFFS.

Definition at line 54 of file GettextFFS.php.

◆ setOfflineMode()

GettextFFS::setOfflineMode ( $value)
Parameters
bool$value

Definition at line 33 of file GettextFFS.php.

◆ shouldOverwrite()

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

Reimplemented from SimpleFFS.

Definition at line 624 of file GettextFFS.php.

◆ supportsFuzzy()

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

Reimplemented from SimpleFFS.

Definition at line 24 of file GettextFFS.php.

◆ writeReal()

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

Reimplemented from SimpleFFS.

Definition at line 390 of file GettextFFS.php.

Member Data Documentation

◆ $offlineMode

GettextFFS::$offlineMode = false
protected

Definition at line 22 of file GettextFFS.php.


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