This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-26828: Trigger crowdin in-context translation based on a cookie
If an ez_in_context_translation cookie is set with any value, the request's accept-language is set, using an event subscriber, to ach-UG, the pseudo-locale used by crowdin. When the locale is ach-UG, the javascript that adds the in-context overlay is loaded.
- Loading branch information
Bertrand Dunogier
committed
Jan 4, 2017
1 parent
a38ab4a
commit e02560e
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\PlatformUIBundle\EventListener; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
class CrowdinRequestLocaleSubcriber implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
KernelEvents::REQUEST => [ | ||
['setInContextAcceptLanguage', 100], | ||
], | ||
]; | ||
} | ||
|
||
public function setInContextAcceptLanguage(GetResponseEvent $e) | ||
{ | ||
if (!$e->getRequest()->cookies->has('ez_in_context_translation')) { | ||
return; | ||
} | ||
|
||
$e->getRequest()->headers->set('accept-language', 'ach-UG'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters