src/I18n/Gettext/Translator.php
protected function addTranslations(array $translations)
    {
        $domain = $translations['domain'] ?? '';

        //Set the first domain loaded as default domain
        if ($this->domain === null) {
            $this->domain = $domain;
        }

        if (isset($this->dictionary[$domain])) {
            $this->dictionary[$domain] = \array_replace_recursive($this->dictionary[$domain], $translations['messages']);

            return;
        }

        if (!empty($translations['plural-forms'])) {
            [$count, $code] = \array_map('trim', \explode(';', $translations['plural-forms'], 2));

            // extract just the expression turn 'n' into a php variable '$n'.
            // Slap on a return keyword and semicolon at the end.
            $this->plurals[$domain] = [
                'count' => (int) \str_replace('nplurals=', '', $count),
                'code' => \str_replace('plural=', 'return ', \str_replace('n', '$n', $code)).';',
            ];
        }

        $this->dictionary[$domain] = $translations['messages'];
    }
protected function addTranslations(array $translations)
    {
        $domain = $translations['domain'] ?? '';

        //Set the first domain loaded as default domain
        if ($this->domain === null) {
            $this->domain = $domain;
        }

        if (isset($this->dictionary[$domain])) {
            $this->dictionary[$domain] = \array_replace_recursive($this->dictionary[$domain], $translations['messages']);

            return;
        }

        if (!empty($translations['plural-forms'])) {
            [$count, $code] = \array_map('trim', \explode(';', $translations['plural-forms'], 2));

            // extract just the expression turn 'n' into a php variable '$n'.
            // Slap on a return keyword and semicolon at the end.
            $this->plurals[$domain] = [
                'count' => (int) \str_replace('nplurals=', '', $count),
                'code' => \str_replace('plural=', 'return ', \str_replace('n', '$n', $code)).';',
            ];
        }

        $this->dictionary[$domain] = $translations['messages'];
    }
protected function addTranslations ( array $ translations ) { $ domain = $ translations [ 'domain' ] ?? '' ; //Set the first domain loaded as default domain if ( $ this -> domain === null ) { $ this -> domain = $ domain ; } if ( isset ( $ this -> dictionary [ $ domain ] ) ) { $ this -> dictionary [ $ domain ] = \ array_replace_recursive ( $ this -> dictionary [ $ domain ] , $ translations [ 'messages' ] ) ; return ; } if ( ! empty ( $ translations [ 'plural-forms' ] ) ) { [ $ count , $ code ] = \ array_map ( 'trim' , \ explode ( ';' , $ translations [ 'plural-forms' ] , 2 ) ) ; // extract just the expression turn 'n' into a php variable '$n'. // Slap on a return keyword and semicolon at the end. $ this -> plurals [ $ domain ] = [ 'count' => ( int ) \ str_replace ( 'nplurals=' , '' , $ count ) , 'code' => \ str_replace ( 'plural=' , 'return ' , \ str_replace ( 'n' , '$n' , $ code ) ) . ';' , ] ; } $ this -> dictionary [ $ domain ] = $ translations [ 'messages' ] ; }
Set new translations to the dictionary.

@param array $translations
Set new translations to the dictionary .