You are here

function locale_get_plural in Drupal 5

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.module \locale_get_plural()
  2. 4 modules/locale.module \locale_get_plural()
  3. 6 modules/locale/locale.module \locale_get_plural()
  4. 7 modules/locale/locale.module \locale_get_plural()
  5. 9 core/modules/locale/locale.module \locale_get_plural()

Returns plural form index for a specific number.

The index is computed from the formula of this language.

1 call to locale_get_plural()
format_plural in includes/common.inc
Format a string containing a count of items.
1 string reference to 'locale_get_plural'
format_plural in includes/common.inc
Format a string containing a count of items.

File

modules/locale/locale.module, line 274
Enables administrators to manage the site interface languages.

Code

function locale_get_plural($count) {
  global $locale;
  static $locale_formula, $plurals = array();
  if (!isset($plurals[$count])) {
    if (!isset($locale_formula)) {
      $languages = locale_supported_languages();
      $locale_formula = $languages['formula'][$locale];
    }
    if ($locale_formula) {
      $n = $count;
      $plurals[$count] = @eval("return intval({$locale_formula});");
      return $plurals[$count];
    }
    else {
      $plurals[$count] = -1;
      return -1;
    }
  }
  return $plurals[$count];
}