public function translateActivityFormat(ComActivitiesActivityInterface $activity)
    {
        $tokens = $this->getActivityTokens($activity);
        $format = $activity->getActivityFormat();

        $parameters = array();

        foreach ($tokens as $key => $value)
        {
            if ($value instanceof ComActivitiesActivityObjectInterface && $value->getObjectName()) {
                $value = $value->getObjectName();
            }

            if (is_scalar($value)) {
                $parameters[$key] = $value;
            }
        }

        $formats = array();

        for ($i = 0; $i < 2; $i++)
        {
            $catalogue = $this->getCatalogue();

            if ($length = $catalogue->getConfig()->key_length) {
                $catalogue->getConfig()->key_length = false;
            }

            $formats[] = $this->translate($this->_getOverride($format, $parameters), array());

            if ($length) {
                $catalogue->getConfig()->key_length = $length;
            }

            if ($i == 0 && isset($this->_locales[$formats[0]])) {
                break; // Format already localized, no need to compare
            } else {
                $this->_switchCatalogues();
            }
        }

        if (count($formats) > 1)
        {
            list($format, $decorator_format) = $formats;
            $this->_locales[$format] = ($format == $decorator_format) ? $this->getLocaleFallback() : $this->getLocale();
        }
        else $format = $formats[0];

        // Set the activity locale.
        $activity->setLocale($this->_locales[$format]);

        return $format;
    }