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

@license GPL-2.0-or-later More...

Static Public Member Functions

static getPluralKeywords (string $code)
 Returns CLDR plural rule for given language.
 
static hasPlural (string $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 (string $text, array $expectedKeywords)
 Format translation with plural forms as array of forms.
 
static parsePluralForms (string $text)
 Parses plural markup into a structure form.
 
static expandTemplate (string $template, array $instanceMap, array $expectedKeywords)
 Gives fully expanded forms given a template and parsed plural markup instances.
 
static convertFormListToFormMap (array $formList, array $expectedKeywords)
 

Public Attributes

const KEYWORDS = [ 'zero', 'one', 'two', 'few', 'many', 'other' ]
 

Detailed Description

@license GPL-2.0-or-later

Since
2019.09

Definition at line 12 of file UnicodePlural.php.

Member Function Documentation

◆ convertFormListToFormMap()

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

Definition at line 171 of file UnicodePlural.php.

◆ expandTemplate()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::expandTemplate ( string $template,
array $instanceMap,
array $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 145 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.

Definition at line 67 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

Definition at line 52 of file UnicodePlural.php.

◆ getPluralKeywords()

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

Returns CLDR plural rule for given language.

Parameters
string$codeLanguage tag in MediaWiki internal format.
Returns
?string[] Null, if no plural rule found

Definition at line 24 of file UnicodePlural.php.

◆ hasPlural()

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

Quick way to check if the text contains plural syntax.

Definition at line 42 of file UnicodePlural.php.

◆ parsePluralForms()

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

Parses plural markup into a structure form.

Returns
array [ string $template, array $instanceMap ]

Definition at line 102 of file UnicodePlural.php.

◆ unflatten()

static MediaWiki\Extension\Translate\Utilities\UnicodePlural::unflatten ( string $text,
array $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 92 of file UnicodePlural.php.

Member Data Documentation

◆ KEYWORDS

const MediaWiki\Extension\Translate\Utilities\UnicodePlural::KEYWORDS = [ 'zero', 'one', 'two', 'few', 'many', 'other' ]

Definition at line 14 of file UnicodePlural.php.


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