pluralRule = $rule; return $this; } /** * Get the plural rule. * * Lazy loads a default rule if none already registered * * @return PluralRule */ public function getPluralRule() { if ($this->pluralRule === null) { $this->setPluralRule(PluralRule::fromString('nplurals=2; plural=n != 1;')); } return $this->pluralRule; } /** * Merge another text domain with the current one. * * The plural rule of both text domains must be compatible for a successful * merge. We are only validating the number of plural forms though, as the * same rule could be made up with different expression. * * @param TextDomain $textDomain * @return TextDomain * @throws Exception\RuntimeException */ public function merge(TextDomain $textDomain) { if ($this->getPluralRule()->getNumPlurals() !== $textDomain->getPluralRule()->getNumPlurals()) { throw new Exception\RuntimeException('Plural rule of merging text domain is not compatible with the current one'); } $this->exchangeArray( array_replace( $this->getArrayCopy(), $textDomain->getArrayCopy() ) ); return $this; } }