diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-30 20:09:42 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-04-20 16:42:04 +0200 |
commit | 157147cb8eaa1800a8473db547c6964a5205e83d (patch) | |
tree | f75242aaf09d882712a32f6da3eafa585b7ee94c /lib/private/L10N/L10N.php | |
parent | 94322971a5a052becb92d4f81a158fd1cf43c873 (diff) | |
download | nextcloud-server-157147cb8eaa1800a8473db547c6964a5205e83d.tar.gz nextcloud-server-157147cb8eaa1800a8473db547c6964a5205e83d.zip |
"Symfony\Component\Translation\PluralizationRules" is deprecated
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/L10N/L10N.php')
-rw-r--r-- | lib/private/L10N/L10N.php | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/lib/private/L10N/L10N.php b/lib/private/L10N/L10N.php index 3b32ec2827f..72f124f7754 100644 --- a/lib/private/L10N/L10N.php +++ b/lib/private/L10N/L10N.php @@ -32,7 +32,7 @@ namespace OC\L10N; use OCP\IL10N; use OCP\L10N\IFactory; use Punic\Calendar; -use Symfony\Component\Translation\PluralizationRules; +use Symfony\Component\Translation\IdentityTranslator; class L10N implements IL10N { @@ -48,11 +48,8 @@ class L10N implements IL10N { /** @var string Locale of this object */ protected $locale; - /** @var string Plural forms (string) */ - private $pluralFormString = 'nplurals=2; plural=(n != 1);'; - - /** @var string Plural forms (function) */ - private $pluralFormFunction = null; + /** @var IdentityTranslator */ + private $identityTranslator; /** @var string[] */ private $translations = []; @@ -214,20 +211,16 @@ class L10N implements IL10N { } /** - * Returnsed function accepts the argument $n - * - * Called by \OC_L10N_String - * @return \Closure the plural form function + * @internal + * @return IdentityTranslator */ - public function getPluralFormFunction(): \Closure { - if (\is_null($this->pluralFormFunction)) { - $lang = $this->getLanguageCode(); - $this->pluralFormFunction = function ($n) use ($lang) { - return PluralizationRules::get($n, $lang); - }; + public function getIdentityTranslator(): IdentityTranslator { + if (\is_null($this->identityTranslator)) { + $this->identityTranslator = new IdentityTranslator(); + $this->identityTranslator->setLocale($this->getLocaleCode()); } - return $this->pluralFormFunction; + return $this->identityTranslator; } /** @@ -242,9 +235,6 @@ class L10N implements IL10N { return false; } - if (!empty($json['pluralForm'])) { - $this->pluralFormString = $json['pluralForm']; - } $this->translations = array_merge($this->translations, $json['translations']); return true; } |