{@inheritdoc}

@throws \Titon\G11n\Exception\MissingMessageException
347997
public function getMessage($key) {
        return $this->cache([__METHOD__, $key], function(GettextTranslator $translator) use ($key) {
            list($domain, $catalog, $id) = $translator->parseKey($key);

            $translator->bindDomains($domain, $catalog);

            textdomain($catalog);

            $message = gettext($id);

            if ($message !== $id) {
                return $message;
            }

            throw new MissingMessageException(sprintf('Message key %s does not exist in %s', $key, Locale::DEFAULT_LOCALE));
        });
    }
1032166
protected function addMessage( $instance )
	{
		$message 			= \Sifo\FilterPost::getInstance()->getString( 'msgid' );
		$translator_model 	= new I18nTranslatorModel();

		// Check if this message exists in the instances parents.
		// Get selected instance inheritance.
		$instance_domains 		= $this->getConfig( 'domains', $instance );

		$instance_inheritance = array();
		if ( isset( $instance_domains['instance_inheritance'] ) )
		{
			$instance_inheritance 	=  $instance_domains['instance_inheritance'];
		}

		if ( $translator_model->getMessageInInhertitance( $message, $instance_inheritance ) > 0 )
		{
			return array( 'status' => 'KO', 'msg' => 'This message already exists in parent instance. Please, customize it.' );
		}
		elseif ( $translator_model->addMessage( $message, $instance ) )
		{
			return array( 'status' => 'OK', 'msg' => 'Message successfully saved.' );
		}

		return array( 'status' => 'KO', 'msg' => 'Failed adding message.' );
	}
550131
protected function ensureMessages() {
        $this->messages = array_merge([
            'controlDigitError' => Yii::t('yii', 'The letter don\'t correspond to the number.')
            , 'patternError' => Yii::t('yii', 'The valid format for NIF is 8 digits followed by a valid letter and for NIE a letter followed by 7 digits and an ending letter.')
                ], $this->messages);
        $this->message = $this->messages['patternError'];
    }
614439
public function setTraceMessage($traceMessage)
    {
        if (gettype($traceMessage) === 'string') {
            $this->traceMessage = $traceMessage;
        } else {
            $msg = "The traceMessage argument must be a string, '" . gettype($traceMessage) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
1197732
public function getCauseMessage(&$causes)
    {
        $trace = $this->getTraceSafe();
        $cause = array('class'   => get_class($this),
                       'message' => $this->message,
                       'file' => 'unknown',
                       'line' => 'unknown');
        if (isset($trace[0])) {
            if (isset($trace[0]['file'])) {
                $cause['file'] = $trace[0]['file'];
                $cause['line'] = $trace[0]['line'];
            }
        }
        $causes[] = $cause;
        if ($this->cause instanceof PEAR_Exception) {
            $this->cause->getCauseMessage($causes);
        } elseif ($this->cause instanceof Exception) {
            $causes[] = array('class'   => get_class($this->cause),
                              'message' => $this->cause->getMessage(),
                              'file' => $this->cause->getFile(),
                              'line' => $this->cause->getLine());
        } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
            $causes[] = array('class' => get_class($this->cause),
                              'message' => $this->cause->getMessage(),
                              'file' => 'unknown',
                              'line' => 'unknown');
        } elseif (is_array($this->cause)) {
            foreach ($this->cause as $cause) {
                if ($cause instanceof PEAR_Exception) {
                    $cause->getCauseMessage($causes);
                } elseif ($cause instanceof Exception) {
                    $causes[] = array('class'   => get_class($cause),
                                   'message' => $cause->getMessage(),
                                   'file' => $cause->getFile(),
                                   'line' => $cause->getLine());
                } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) {
                    $causes[] = array('class' => get_class($cause),
                                      'message' => $cause->getMessage(),
                                      'file' => 'unknown',
                                      'line' => 'unknown');
                } elseif (is_array($cause) && isset($cause['message'])) {
                    // PEAR_ErrorStack warning
                    $causes[] = array(
                        'class' => $cause['package'],
                        'message' => $cause['message'],
                        'file' => isset($cause['context']['file']) ?
                                            $cause['context']['file'] :
                                            'unknown',
                        'line' => isset($cause['context']['line']) ?
                                            $cause['context']['line'] :
                                            'unknown',
                    );
                }
            }
        }
    }
749493
public function add(array $entry)
    {
        if (!isset($entry['msgid'])) {
            throw new Exception("Invalid entry: missing msgid");
        }
        $id = $entry['msgid'];
        $plural_id = isset($entry['msgid_plural']) ? $entry['msgid_plural'] : null;
        $context = isset($entry['msgctxt']) ? $entry['msgctxt'] : null;
        $flags = isset($entry['flags']) ? $entry['flags'] : array();

        $strings = array();
        foreach ($entry as $key => $value) {
            if (substr($key, 0, 6) === 'msgstr') {
                if (is_array($value)) {
                    $strings = array_merge($strings, $value);
                } else {
                    $strings[] = $value;
                }
            }
        }
        if (count($strings) === 0) {
            throw new Exception("Invalid entry: missing msgstr");
        }
        $this->set[] = array(
            'id' => $id,
            'plural' => $plural_id,
            'context' => $context,
            'flags' => $flags,
            'strings' => $strings
        );
    }
9125
public function ensure($key, $errorMessage = null, $scalarType = null) {
        if ( ! $this->has($key)) {
            if ($errorMessage === null) {
                $errorMessage = sprintf('Missing config at key "%s".', $key);
            } else {
                $errorMessage = s('%s: %s', $key, $errorMessage);
            }

            throw new MissingConfigException($errorMessage);
        }

        if ($scalarType !== null) {
            if ( ! str_starts_with(gettype($this->get($key)), $scalarType)) {
                $errorMessage = sprintf('%s: Config value at key "%s" should be of type "%s".', $key, $key, $scalarType);

                throw new InvalidConfigValueException($errorMessage);
            }
        }

        return $this;
    }
511131
public function getMessage()
    {
        return isset($this->data['ErrorMsg']) && !empty($this->data['ErrorMsg']) ? $this->data['ErrorMsg'] : null;
    }
544542
protected function assertMessageExists(int $messageNumber): void
    {
        if (true === $this->messageNumberVerified) {
            return;
        }
        $this->messageNumberVerified = true;

        $msgno = \imap_msgno($this->resource->getStream(), $messageNumber);
        if (\is_numeric($msgno) && $msgno > 0) {
            $this->imapMsgNo = $msgno;

            return;
        }

        throw new MessageDoesNotExistException(\sprintf(
            'Message "%s" does not exist',
            $messageNumber
        ));
    }
917170
public function addMissingTranslations($locales)
    {
        foreach ($locales as $localeCode) {
            if (!$this->hasTranslation($localeCode)) {
                $this->addTranslations(new MessageTranslation($localeCode, $this->getMessage()));
            }
        }

        foreach ($this->translations as $translation) {
            $translation->setMessage($this);
        }
    }
1220801
protected function formatExceptionMsg($exceptionMessage)
    {
        $exceptionMessage = str_replace("+++ Actual\n", '', $exceptionMessage);
        $exceptionMessage = str_replace("--- Expected\n", '', $exceptionMessage);
        $exceptionMessage = str_replace("@@ @@\n", '', $exceptionMessage);
        $exceptionMessage = preg_replace("/(Failed.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
        $exceptionMessage = preg_replace("/\-+(.*)$/m", "\n \033[01;32m$1\033[0m", $exceptionMessage);
        return preg_replace("/\++(.*)$/m", " \033[01;31m$1\033[0m", $exceptionMessage);
    }
1332243
public function msgIfExists(string $message = '', array $vars = [])
    {
        $exists = $this->msgExists($message, $vars);
        if ($exists) {
            return $this->msg($message, $vars);
        }
        return $message;
    }
1317197
public function getInvocationMessage()
    {
        if ($this->invocationMessage === null) {
            // try to create one
            if ($this->registration === null) {
                throw new \Exception('You must set the registration prior to calling getInvocationMessage');
            }

            if ($this->callMessage === null) {
                throw new \Exception('You must set the CallMessage prior to calling getInvocationMessage');
            }

            $invocationMessage = InvocationMessage::createMessageFrom($this->getCallMessage(), $this->getRegistration());

            $invocationMessage->setRequestId($this->getInvocationRequestId());

            $details = [];

            if ($this->getRegistration()->getDiscloseCaller() === true && $this->getCallerSession()->getAuthenticationDetails()) {
                $authenticationDetails = $this->getCallerSession()->getAuthenticationDetails();
                $details               = [
                    'caller'     => $this->getCallerSession()->getSessionId(),
                    'authid'     => $authenticationDetails->getAuthId(),
                    'authrole'   => $authenticationDetails->getAuthRole(),
                    'authroles'  => $authenticationDetails->getAuthRoles(),
                    'authmethod' => $authenticationDetails->getAuthMethod(),
                ];

                if ($authenticationDetails->getAuthExtra() !== null) {
                    $details['_thruway_authextra'] = $authenticationDetails->getAuthExtra();
                }
            }

            // TODO: check to see if callee supports progressive call
            $callOptions   = $this->getCallMessage()->getOptions();
            $isProgressive = false;
            if (is_object($callOptions) && isset($callOptions->receive_progress) && $callOptions->receive_progress) {
                $details       = array_merge($details, ['receive_progress' => true]);
                $isProgressive = true;
            }

            // if nothing was added to details - change ot stdClass so it will serialize correctly
            if (count($details) === 0) {
                $details = new \stdClass();
            }
            $invocationMessage->setDetails($details);

            $this->setIsProgressive($isProgressive);

            $this->setInvocationMessage($invocationMessage);
        }

        return $this->invocationMessage;
    }
332220
public function message($ruleOrMessage, $message = null)
    {
        if (1 === func_num_args()) {
            $rule = $this->lastRule;
            $message = $ruleOrMessage;
        } else {
            $rule = $ruleOrMessage;
        }

        $this->options['messages'][$this->lastKey][$rule] = $message;

        return $this;
    }
1240721
public function onMessageSendingToUsers(SendMessageEvent $event)
    {
        $message = $this->messageManager->create(
            $event->getContent(),
            $event->getObject(),
            $event->getUsers(),
            $event->getSender()
        );

        $this->messageManager->send($message);
    }
952776
public function showError($msg = null)
    {
        $errorMessage = null;
        $code = null;
        if ((null === $code) && (null === $msg)) {
            $errorCode = $this->connection->errorCode();
            $errorInfo = $this->connection->errorInfo();
        } else {
            $errorCode = $code;
            $errorInfo = $msg;
        }
    
        if (is_array($errorInfo)) {
            $errorMessage = null;
            if (isset($errorInfo[1])) {
                $errorMessage .= $errorInfo[1];
            }
            if (isset($errorInfo[2])) {
                $errorMessage .= ' : ' . $errorInfo[2];
            }
        } else {
            $errorMessage = $errorInfo;
        }
        throw new Exception('Error: ' . $errorCode . ' => ' . $errorMessage  . '.');
    }
1015239
public function setMessage($message)
    {
        $messageVariables = null;

        if (is_array($message)) {
            if (array_key_exists('messageVariables', $message)) {
                $messageVariables = $message['messageVariables'];
            }

            if (array_key_exists('message', $message)) {
                $message = $message['message'];
            } else {
                $messageVariables = $message;
                $message          = $this->messageTemplate;
            }
        }

        if (!is_string($message)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Wrong parameters for %s([array|string $message]); %s given.',
                    __METHOD__,
                    is_object($message) ? get_class($message) : gettype($message)
                ),
                E_ERROR
            );
        }

        $this->message = $this->createMessage($message, $messageVariables);

        return $this;
    }