Render locale switcher widget.

@param \Twig_Environment $env
@param array             $locales    The locales
@param string            $route      The route
@param array             $parameters The route parameters

@return string
495979
public function renderWidget(\Twig_Environment $env, $locales, $route, array $parameters = array())
    {
        $template = $env->loadTemplate(
            'KunstmaanAdminBundle:LocaleSwitcherTwigExtension:widget.html.twig'
        );

        return $template->render(
            array_merge(
                $parameters,
                array(
                    'locales' => $locales,
                    'route' => $route,
                )
            )
        );
    }
757057
public function renderMenuItemTemplate(\Twig_Environment $environment, $node, $options = array())
    {
        $template = isset($options['template']) ? $options['template'] : false;
        if ($template === false) {
            $template = 'KunstmaanMenuBundle::menu-item.html.twig';
        }

        $active = false;
        if ($node['type'] == MenuItem::TYPE_PAGE_LINK) {
            $url = $this->router->generate('_slug', array('url' => $node['nodeTranslation']['url']));

            if ($this->router->getContext()->getPathInfo() == $url) {
                $active = true;
            }
        } else {
            $url = $node['url'];
        }

        if ($node['type'] == MenuItem::TYPE_PAGE_LINK) {
            if ($node['title']) {
                $title = $node['title'];
            } else {
                $title = $node['nodeTranslation']['title'];
            }
        } else {
            $title = $node['title'];
        }

        return $environment->render($template, array(
            'menuItem' => $node,
            'url' => $url,
            'options' => $options,
            'title' => $title,
            'active' => $active,
        ));
    }
600506
function renderRoutes() {
  return (
    <Switch>
      {
        routes.map(route => (
          <Route key={route.path || ''} {...route} />
        ))
      }
    </Switch>
  );
}
56366
protected function lookupLocale(array $locales, string $locale, string $defaultLocale): string
    {
        // for some odd reason locale_lookup returns empty string but not default locale if input locales are empty
        return empty($locales) === true ? $defaultLocale : locale_lookup($locales, $locale, false, $defaultLocale);
    }
535975
protected function renderView(string $view, array $parameters = array()): string
    {
        if ($this->templating instanceof EngineInterface) {
            return $this->templating->render($view, $parameters);
        }

        throw new \LogicException(
            'You can not use the "renderView" method if the Templating Component or the '
            .'Twig Bundle are not available.'
        );
    }
588205
public function getUri( $locales = null )
    {
        if ( empty( $locales ) )
        {
            $locales = $this->getMapper()
                            ->getLocale();
        }

        $locales = (array) $locales;
        $uri     = $this->getUriStructure( $locales );

        if ( empty( $uri ) )
        {
            $locale = null;
            $maxQ   = -1;

            foreach ( (array) $locales as $l => $q )
            {
                if ( is_numeric( $l ) )
                {
                    $l = $q;
                    $q = 1;
                }

                if ( $q > $maxQ )
                {
                    $maxQ   = $q;
                    $locale = $l;
                }
            }

            return '/app/' . $locale . '/paragraph/render/' . $this->id;
        }

        return '/' . $uri->safeUri;
    }
871459
protected function render($template, array $params = array(), array $options = array())
    {
        $renderer = $this->serviceLocator->get('templating');

        // Helpers
        if (isset($options['helpers'])) {
            foreach ($options['helpers'] as $helper) {
                $renderer->addHelper($helper);
            }
        }

        return $renderer->render($template, $params);
    }
937471
public function renderStripeScripts(Twig_Environment $environment)
    {
        $environment->display($this->scriptsTemplate, [
            'public_key' => $this->publicKey,
            'currency' => $this->paymentBridgeInterface->getCurrency(),
        ]);
    }
52522
public function link(string $route, $options, string $text = null): self
    {
        $this->render(function ($datum) use ($route, $options, $text) {
            $attributes = [];
            $options = Arr::wrap($options);

            foreach ($options as $option) {
                if (method_exists($datum, 'getContent')) {
                    $attributes[] = $datum->getContent($option);
                    continue;
                }

                $attributes[] = $datum->getAttribute($option);
            }

            if (! is_null($text)) {
                $text = $datum->getContent($text);
                $text = $text ?? '—';
            }

            return view('platform::partials.td.link', [
                'route'      => $route,
                'attributes' => $attributes,
                'text'       => $text,
            ]);
        });

        return $this;
    }
868373
public function render(array $parameters = []): string
    {
        return $this->twig->render('@ezdesign/component/script.html.twig', [
            'src' => $this->src,
            'type' => $this->type,
            'async' => $this->async,
            'defer' => $this->defer,
            'crossorigin' => $this->crossorigin,
            'integrity' => $this->integrity,
        ] + $parameters);
    }
612205
public function renderGrid(\Twig_Environment $environment, $context, $id, array $options = [])
    {
        $options = $this->resolver->resolve($options);

        $page = isset($context['page']) ? $context['page'] : null;

        if ($page instanceof AbstractPage) {
            $grid = $page->getGrid($id);

            if (!$grid instanceof Grid) {
                $grid = new Grid($id);
            }

            return $environment->render($options['template'], [
                'grid' => $grid,
            ]);
        }

        return '';
    }
1019980
protected function renderTranslatedFields(array $locales, $value, $originalValue, array $errors)
    {
        // Render the inputs for all relevant locales
        $rendered = [];

        foreach ($locales as $locale) {

            $rendered[ $locale ] = $this->renderField(
                $this->getValueForLocale($locale, $value),
                $this->getValueForLocale($locale, $originalValue),
                $this->getErrorsForLocale($locale, $errors),
                $locale
            );
        }

        return view(static::FORM_FIELD_TRANSLATED_VIEW, [
            'field'          => $this->field,
            'locales'        => $locales,
            'value'          => $value,
            'errors'         => $errors,
            'localeRendered' => $rendered,
        ]);
    }
36705
protected function generateLoc($hostWithScheme, $route, $parameters = [])
    {
        if (null === $this->router) {
            throw new \RuntimeException('UrlGenerator interface is missing');
        }

        list($scheme, $host) = explode('://', $hostWithScheme);

        $this->router
            ->getContext()
            ->setHost($host)
            ->setScheme($scheme);

        return $this->router->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
    }
780820
public void switchView(String locale, Controller c) {
		Render render = c.getRender();
		if (render != null) {
			String view = render.getView();
			if (view != null) {
				if (view.startsWith("/")) {
					view = "/" + locale + view;
				} else {
					view = locale + "/" + view;
				}
				
				render.setView(view);
			}
		}
	}
1281779
void switchLocale(final String locale) {

        if (locale.equals(m_locale)) {
            return;
        }
        m_locale = locale;
        m_basePanel.clear();
        destroyForm(false);
        final CmsEntity entity = m_entityBackend.getEntity(m_entityId);
        m_entityId = getIdForLocale(locale);
        // if the content does not contain the requested locale yet, a new node will be created
        final boolean addedNewLocale = !m_contentLocales.contains(locale);
        if (m_registeredEntities.contains(m_entityId)) {
            unregistereEntity(m_entityId);
        }
        if (addedNewLocale) {
            loadNewDefinition(m_entityId, entity, new I_CmsSimpleCallback<CmsContentDefinition>() {

                public void execute(final CmsContentDefinition contentDefinition) {

                    setContentDefinition(contentDefinition);
                    renderFormContent();
                    setChanged();

                }
            });
        } else {
            loadDefinition(m_entityId, entity, new I_CmsSimpleCallback<CmsContentDefinition>() {

                public void execute(CmsContentDefinition contentDefinition) {

                    setContentDefinition(contentDefinition);
                    renderFormContent();
                }
            });
        }
    }
460519
protected function renderEntityWidget($entities, array $options = [])
    {
        if (!array_key_exists('field', $options)) {
            // throw new \InvalidArgumentException('Missing "field" option for entity widget.');
            $options['field'] = null;
        }
        if (!array_key_exists('route', $options)) {
            $options['route'] = null;
        }
        if (!array_key_exists('route_params', $options)) {
            $options['route_params'] = [];
        }
        if (!array_key_exists('route_params_map', $options)) {
            $options['route_params_map'] = ['id' => 'id'];
        }

        if (null !== $entities && !($entities instanceof Collection)) {
            $entities = new ArrayCollection([$entities]);
        }

        $vars = [
            'route' => $options['route'],
            'field' => $options['field'],
            'route_params'     => $options['route_params'],
            'route_params_map' => $options['route_params_map'],
            'entities' => $entities
        ];

        return $this->renderBlock('show_widget_entity', $vars);
    }
1277682
public function t($key, array $options = [], $locale = null)
    {
        return $this->translate($key, $options, $locale);
    }