function locale_get_plural
7.x locale.module | locale_get_plural($count, $langcode = NULL) |
6.x locale.module | locale_get_plural($count, $langcode = NULL) |
Returns plural form index for a specific number.
The index is computed from the formula of this language.
Parameters
$count: Number to return plural for.
$langcode: Optional language code to translate to a language other than what is used to display the page.
1 call to locale_get_plural()
- format_plural in drupal-6.x/
includes/ common.inc - Format a string containing a count of items.
1 string reference to 'locale_get_plural'
- format_plural in drupal-6.x/
includes/ common.inc - Format a string containing a count of items.
File
- drupal-6.x/
modules/ locale/ locale.module, line 411 - Add language handling functionality and enables the translation of the user interface to languages other than English.
Code
function locale_get_plural($count, $langcode = NULL) {
global $language;
static $locale_formula, $plurals = array();
$langcode = $langcode ? $langcode : $language->language;
if (!isset($plurals[$langcode][$count])) {
if (!isset($locale_formula)) {
$language_list = language_list();
$locale_formula[$langcode] = $language_list[$langcode]->formula;
}
if ($locale_formula[$langcode]) {
$n = $count;
$plurals[$langcode][$count] = @eval('return intval(' . $locale_formula[$langcode] . ');');
return $plurals[$langcode][$count];
}
else {
$plurals[$langcode][$count] = -1;
return -1;
}
}
return $plurals[$langcode][$count];
}