protected function replace($text, $replacements)
    {
        if (is_array($replacements)) {
            foreach ($replacements as $var => $replacement) {
                $regex = str_replace('key', preg_quote($var, '/'), $this->translateReplaceRegex);
                $text = preg_replace($regex, $replacement, $text);
            }
        }
        return $text;
    }