PHP Класс Neos\Flow\I18n\Cldr\Reader\PluralsReader

There are a few similar words used in plurals.xml file of CLDR used by this class. Following naming convention is used in the code (a name of corresponding tag from xml file is provided in brackets, if any): - ruleset: a set of plural rules for a locale [pluralRules] - rule: a rule for one of the forms: zero, one, two, few, many [pluralRule] - subrule: one of the conditions of rule. One rule can have many conditions joined with "and" or "or" logical operator.
См. также: http://www.unicode.org/reports/tr35/#Language_Plural_Rules
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache Neos\Cache\Frontend\VariableFrontend
$cldrRepository Neos\Flow\I18n\Cldr\CldrRepository
$rulesets array One ruleset contains one or more rules (at most 5, one for every plural form - zero, one, two, few, many - a rule 'other' is implicit). There can also be NULL ruleset, used by languages which don't have plurals. A rule is an array with following elements: 'modulo' => $x | FALSE, 'condition' => array(0 => 'conditionName', 1 => $x, 2 => $y), 'logicalOperator' => 'and' | 'or' | FALSE Legend: - if 'modulo' key has an integer value, tested variable (call it $n) has to be replaced with the remainder of division of $n by $x. Otherwise unchanged $n is used for conditional test. - 'condition' is an indexed array where first element is a name of test condition (one of: is, isnot, in, notin, within, notwithin). Second element is a value to compare $n with. Third element is optional, and is used only for tests where range is needed (last 4 from the list above) - 'logicalOperator' represents a logical operation to be done with next subrule in chain. If current subrule is a last one (or only one), this element is set to FALSE.
$rulesetsIndices array An associative array holding information which ruleset is used by given locale. One or more locales can use the same ruleset.

Открытые методы

Метод Описание
getPluralForm ( mixed $quantity, Locale $locale ) : string Returns matching plural form based on $quantity and $locale provided.
getPluralForms ( Locale $locale ) : array Returns array of plural forms available for particular locale.
initializeObject ( ) : void Constructs the reader, loading parsed data from cache if available.
injectCache ( Neos\Cache\Frontend\VariableFrontend $cache ) : void Injects the Flow_I18n_Cldr_Reader_PluralsReader cache
injectCldrRepository ( CldrRepository $repository ) : void

Защищенные методы

Метод Описание
generateRulesets ( ) : void Generates an internal representation of plural rules which can be found in plurals.xml CLDR file.
parseRule ( string $rule ) : array Parses a plural rule from CLDR.

Описание методов

generateRulesets() защищенный Метод

The properties $rulesets and $rulesetsIndices should be empty before running this method.
См. также: PluralsReader::$rulesets
protected generateRulesets ( ) : void
Результат void

getPluralForm() публичный Метод

Plural form is one of following: zero, one, two, few, many, other. Last one (other) is returned when number provided doesn't match any of the rules, or there is no rules for given locale.
public getPluralForm ( mixed $quantity, Locale $locale ) : string
$quantity mixed A number to find plural form for (float or int)
$locale Neos\Flow\I18n\Locale
Результат string One of plural form constants

getPluralForms() публичный Метод

Returns array of plural forms available for particular locale.
public getPluralForms ( Locale $locale ) : array
$locale Neos\Flow\I18n\Locale Locale to return plural forms for
Результат array Plural forms' names (one, zero, two, few, many, other) available for language set in this model

initializeObject() публичный Метод

Constructs the reader, loading parsed data from cache if available.
public initializeObject ( ) : void
Результат void

injectCache() публичный Метод

Injects the Flow_I18n_Cldr_Reader_PluralsReader cache
public injectCache ( Neos\Cache\Frontend\VariableFrontend $cache ) : void
$cache Neos\Cache\Frontend\VariableFrontend
Результат void

injectCldrRepository() публичный Метод

public injectCldrRepository ( CldrRepository $repository ) : void
$repository Neos\Flow\I18n\Cldr\CldrRepository
Результат void

parseRule() защищенный Метод

A plural rule in CLDR is a string with one or more test conditions, with 'and' or 'or' logical operators between them. Whole expression can look like this: n is 0 OR n is not 1 AND n mod 100 in 1..19 As CLDR documentation says, following test conditions can be used: - is x, is not x: $n is (not) equal $x - in x..y, not in x..y: $n is (not) one of integers from range <$x, $y> - within x..y, not within x..y: $n is (not) any number from range <$x, $y> Where $n can be a number (also float) as is, or a result of $n mod $x. Array returned follows simple internal format (see documentation for $rulesets property for details).
protected parseRule ( string $rule ) : array
$rule string
Результат array Parsed rule

Описание свойств

$cache защищенное свойство

protected VariableFrontend,Neos\Cache\Frontend $cache
Результат Neos\Cache\Frontend\VariableFrontend

$cldrRepository защищенное свойство

protected CldrRepository,Neos\Flow\I18n\Cldr $cldrRepository
Результат Neos\Flow\I18n\Cldr\CldrRepository

$rulesets защищенное свойство

One ruleset contains one or more rules (at most 5, one for every plural form - zero, one, two, few, many - a rule 'other' is implicit). There can also be NULL ruleset, used by languages which don't have plurals. A rule is an array with following elements: 'modulo' => $x | FALSE, 'condition' => array(0 => 'conditionName', 1 => $x, 2 => $y), 'logicalOperator' => 'and' | 'or' | FALSE Legend: - if 'modulo' key has an integer value, tested variable (call it $n) has to be replaced with the remainder of division of $n by $x. Otherwise unchanged $n is used for conditional test. - 'condition' is an indexed array where first element is a name of test condition (one of: is, isnot, in, notin, within, notwithin). Second element is a value to compare $n with. Third element is optional, and is used only for tests where range is needed (last 4 from the list above) - 'logicalOperator' represents a logical operation to be done with next subrule in chain. If current subrule is a last one (or only one), this element is set to FALSE.
protected array $rulesets
Результат array

$rulesetsIndices защищенное свойство

An associative array holding information which ruleset is used by given locale. One or more locales can use the same ruleset.
protected array $rulesetsIndices
Результат array