mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 10:16:36 +02:00
[ticket/10345] Fix documentation on the new function and the switch
Also do not min/max the value, but throw an error on an invalid Plural rule. PHPBB3-10345
This commit is contained in:
committed by
Oleg Pudeyev
parent
757fcd3e63
commit
f16d72fcfb
@@ -1901,6 +1901,10 @@ class user extends session
|
||||
/**
|
||||
* Determine which plural form we should use.
|
||||
* For some languages this is not as simple as for English.
|
||||
*
|
||||
* @param $number int The number we want to get the plural case for
|
||||
* @param $force_rule mixed False to use the plural rule of the language package
|
||||
* or an integer to force a certain plural rule
|
||||
*/
|
||||
function get_plural_form($number, $force_rule = false)
|
||||
{
|
||||
@@ -1910,10 +1914,17 @@ class user extends session
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Default to english system
|
||||
// Default to English system
|
||||
$plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1);
|
||||
$plural_rule = max(0, min($plural_rule, 15));
|
||||
if ($plural_rule > 15 || $plural_rule < 0)
|
||||
{
|
||||
trigger_error('INVALID_PLURAL_RULE');
|
||||
}
|
||||
|
||||
/**
|
||||
* The following plural rules are based on a list published by the Mozilla Developer Network
|
||||
* https://developer.mozilla.org/en/Localization_and_Plurals
|
||||
*/
|
||||
switch ($plural_rule)
|
||||
{
|
||||
case 0:
|
||||
|
Reference in New Issue
Block a user