Same name and namespace in other branches
  1. 10 core/modules/locale/locale.module \locale_get_plural()
  2. 4.6.x modules/locale.module \locale_get_plural()
  3. 4.7.x modules/locale.module \locale_get_plural()
  4. 6.x modules/locale/locale.module \locale_get_plural()
  5. 7.x modules/locale/locale.module \locale_get_plural()
  6. 8.9.x core/modules/locale/locale.module \locale_get_plural()
  7. 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];
}