Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\Utilities\UnicodePlural Class Reference

Static Public Member Functions

static getPluralKeywords ( $code)
 Returns CLDR plural rule for given language.
 
static hasPlural ( $text)
 Quick way to check if the text contains plural syntax.
 
static flattenMap (array $forms)
 Format plural forms map as single string suitable for translation.
 
static flattenList (array $formList)
 Format plural forms list as single string.
 
static unflatten ( $text, $expectedKeywords)
 Format translation with plural forms as array of forms.
 
static parsePluralForms ( $text)
 Parses plural markup into a structure form.
 
static expandTemplate ( $template, array $instanceMap, $expectedKeywords)
 Gives fully expanded forms given a template and parsed plural markup instances.
 
static convertFormListToFormMap (array $formList, array $expectedKeywords)
 

Detailed Description

Since
2019.09

Definition at line 13 of file UnicodePlural.php.

Member Function Documentation

◆ convertFormListToFormMap()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::convertFormListToFormMap ( array $formList,
array $expectedKeywords )
static

Definition at line 178 of file UnicodePlural.php.

◆ expandTemplate()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::expandTemplate ( $template,
array $instanceMap,
$expectedKeywords )
static

Gives fully expanded forms given a template and parsed plural markup instances.

Parameters
string$template
array$instanceMap
string[]$expectedKeywords
Returns
string[]

Definition at line 152 of file UnicodePlural.php.

◆ flattenList()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::flattenList ( array $formList)
static

Format plural forms list as single string.

This does not check validity of forms.

Parameters
array[]$formList[ keyword, form ] pairs.
Returns
string

Definition at line 73 of file UnicodePlural.php.

◆ flattenMap()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::flattenMap ( array $forms)
static

Format plural forms map as single string suitable for translation.

This does not check validity of forms. Use ::convertFormListToFormMap for that.

Parameters
string[]$forms
Returns
string

Definition at line 57 of file UnicodePlural.php.

◆ getPluralKeywords()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::getPluralKeywords ( $code)
static

Returns CLDR plural rule for given language.

Parameters
string$codeLanguage tag in MediaWiki internal format.
Returns
array|null Empty string if no plural rule found

Definition at line 23 of file UnicodePlural.php.

◆ hasPlural()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::hasPlural ( $text)
static

Quick way to check if the text contains plural syntax.

Parameters
string$text
Returns
bool

Definition at line 46 of file UnicodePlural.php.

◆ parsePluralForms()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::parsePluralForms ( $text)
static

Parses plural markup into a structure form.

Parameters
string$text
Returns
array [ string $template, array $instanceMap ]

Definition at line 109 of file UnicodePlural.php.

◆ unflatten()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::unflatten ( $text,
$expectedKeywords )
static

Format translation with plural forms as array of forms.

Reverse of flatten. Do note that A may be != flatten( unflatten( A ) ) because translators can place part of the text outside the plural markup or use multiple instances of the markup.

Parameters
string$text
string[]$expectedKeywords
Returns
string[]

Definition at line 98 of file UnicodePlural.php.


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