/** * Invokes the command * @param \ride\library\i18n\I18n $i18n * @return null */ public function invoke(I18n $i18n) { $translations = array(); // get all locales $locales = $i18n->getLocales(); // gather all translation keys foreach ($locales as $locale) { $translator = $i18n->getTranslator($locale); $localeTranslations = $translator->getTranslations(); foreach ($localeTranslations as $key => $translation) { $translations[$key] = '[' . $key . ']'; } } // add missing translation keys to all locales foreach ($locales as $locale) { $this->output->writeLine($locale); $translator = $i18n->getTranslator($locale); foreach ($translations as $key => $value) { $translation = $translator->getTranslation($key); if ($translation === null) { $translator->setTranslation($key, $value); $this->output->writeLine('- ' . $key); } } } }
/** * Invokes the command * @param \ride\library\i18n\I18n $i18n * @return null */ public function invoke(I18n $i18n) { $locales = $i18n->getLocales(); foreach ($locales as $locale) { $this->output->writeLine('- ' . $locale->getName() . ' [' . $locale->getCode() . ']'); $properties = $locale->getProperties(); foreach ($properties as $key => $value) { $this->output->writeLine(' #' . $key . ' = ' . $value); } } }
/** * Sets a title view to the response * @return null */ public function indexAction(I18n $i18n) { $urls = array(); $locales = $i18n->getLocales(); $node = $this->properties->getNode(); $site = $node->getRootNodeId(); $content = $this->getContext('content'); if (isset($content->type)) { $contentMapper = $this->getContentFacade()->getContentMapper($content->type); } else { $content = null; } foreach ($locales as $localeCode => $locale) { if (!$node->isAvailableInLocale($localeCode)) { continue; } if ($content) { $urls[$localeCode] = array('url' => $contentMapper->getUrl($site, $localeCode, $content->data), 'locale' => $locale); } else { $urls[$localeCode] = array('url' => $this->getUrl('cms.front.' . $site . '.' . $node->getId() . '.' . $localeCode), 'locale' => $locale); } } $this->setTemplateView($this->getTemplate(static::TEMPLATE_NAMESPACE . '/default'), array('locales' => $urls)); }