namespace Wallabag\CoreBundle\Controller;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\TaggingRule;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
return $this->redirect($request->headers->get('referer'));
}
+ /**
+ * Change the locale for the current user.
+ *
+ * @param Request $request
+ * @param string $language
+ *
+ * @Route("/locale/{language}", name="changeLocale")
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ */
+ public function setLocaleAction(Request $request, $language = null)
+ {
+ $errors = $this->get('validator')->validate($language, (new LocaleConstraint()));
+
+ if (0 === \count($errors)) {
+ $request->getSession()->set('_locale', $language);
+ }
+
+ return $this->redirect($request->headers->get('referer', $this->generateUrl('homepage')));
+ }
+
/**
* Remove all tags for given tags and a given user and cleanup orphan tags.
*