Aimeos\ShopBundle\Service\View::addTranslate PHP Method

addTranslate() protected method

Adds the "translate" helper to the view object
protected addTranslate ( Aimeos\MW\View\Iface $view, string | null $locale ) : Aimeos\MW\View\Iface
$view Aimeos\MW\View\Iface View object
$locale string | null ISO language code, e.g. "de" or "de_CH"
return Aimeos\MW\View\Iface Modified view object
    protected function addTranslate(\Aimeos\MW\View\Iface $view, $locale)
    {
        if ($locale !== null) {
            $i18n = $this->container->get('aimeos_i18n')->get(array($locale));
            $translation = $i18n[$locale];
        } else {
            $translation = new \Aimeos\MW\Translation\None('en');
        }
        $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
        $view->addHelper('translate', $helper);
        return $view;
    }