Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener Class Reference

Flattens message arrays for further processing. More...

Public Member Functions

 __construct (string $sep='.', bool $parseCLDRPlurals=false)
 
 flatten (array $unflat)
 Flattens multidimensional array.
 
 flattenCLDRPlurals (array $messages)
 Flattens arrays that contain CLDR plural keywords into single values using MediaWiki's plural syntax.
 
 unflatten (array $flat)
 Performs the reverse operation of flatten.
 
 unflattenCLDRPlurals (string $key, string $message)
 Converts the plural syntax to array of CLDR style plurals.
 
 compareContent (string $a, string $b)
 Compares two strings for equal content, taking PLURAL expansion into account.
 

Protected Attributes

 $sep
 
 $parseCLDRPlurals
 

Static Protected Attributes

static $pluralWords
 

Detailed Description

Flattens message arrays for further processing.

Supports parsing CLDR plural messages and converting them into MediaWiki's {{PLURAL}} syntax in a single message.

Author
Niklas Laxström
Erik Moeller @license GPL-2.0-or-later
Since
2016.01

Definition at line 19 of file ArrayFlattener.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::__construct ( string $sep = '.',
bool $parseCLDRPlurals = false )

Definition at line 34 of file ArrayFlattener.php.

Member Function Documentation

◆ compareContent()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::compareContent ( string $a,
string $b )

Compares two strings for equal content, taking PLURAL expansion into account.

Definition at line 272 of file ArrayFlattener.php.

◆ flatten()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::flatten ( array $unflat)

Flattens multidimensional array.

Parameters
array$unflatArray of messages

Definition at line 43 of file ArrayFlattener.php.

◆ flattenCLDRPlurals()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::flattenCLDRPlurals ( array $messages)

Flattens arrays that contain CLDR plural keywords into single values using MediaWiki's plural syntax.

Exceptions
MWException
Returns
bool|string

Definition at line 81 of file ArrayFlattener.php.

◆ unflatten()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::unflatten ( array $flat)

Performs the reverse operation of flatten.

Parameters
array$flatArray of messages

Definition at line 134 of file ArrayFlattener.php.

◆ unflattenCLDRPlurals()

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::unflattenCLDRPlurals ( string $key,
string $message )

Converts the plural syntax to array of CLDR style plurals.

Returns
bool|array

Definition at line 189 of file ArrayFlattener.php.

Member Data Documentation

◆ $parseCLDRPlurals

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::$parseCLDRPlurals
protected

Definition at line 23 of file ArrayFlattener.php.

◆ $pluralWords

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::$pluralWords
staticprotected
Initial value:
= [
'zero' => 1,
'one' => 1,
'many' => 1,
'few' => 1,
'other' => 1,
'two' => 1
]

Definition at line 25 of file ArrayFlattener.php.

◆ $sep

MediaWiki\Extension\Translate\MessageProcessing\ArrayFlattener::$sep
protected

Definition at line 21 of file ArrayFlattener.php.


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