Commit 01adbc00 authored by catch's avatar catch

Issue #2573975 by alexpott, juampynr, Berdir, edurenye: function_exists check...

Issue #2573975 by alexpott, juampynr, Berdir, edurenye: function_exists check in PluralTranslatableString is wrong
parent 3479333a
......@@ -35,13 +35,6 @@ class PluralTranslatableMarkup extends TranslatableMarkup {
*/
protected $translatedString;
/**
* A bool that statically caches whether locale_get_plural() exists.
*
* @var bool
*/
protected static $localeEnabled;
/**
* Constructs a new PluralTranslatableMarkup object.
*
......@@ -157,10 +150,13 @@ public function render() {
* @return int
*/
protected function getPluralIndex() {
if (!isset(static::$localeEnabled)) {
static::$localeEnabled = function_exists('locale_get_plural');
}
if (function_exists('locale_get_plural')) {
// We have to test both if the function and the service exist since in
// certain situations it is possible that locale code might be loaded but
// the service does not exist. For example, where the parent test site has
// locale installed but the child site does not.
// @todo Refactor in https://www.drupal.org/node/2660338 so this code does
// not depend on knowing that the Locale module exists.
if (function_exists('locale_get_plural') && \Drupal::hasService('locale.plural.formula')) {
return locale_get_plural($this->count, $this->getOption('langcode'));
}
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment