-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1794 from cmfcmf/multilingual-extraction
Activate multilingual route extraction and translation
- Loading branch information
Showing
11 changed files
with
161 additions
and
7 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
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
15 changes: 15 additions & 0 deletions
15
src/lib/Zikula/Bundle/CoreBundle/DependencyInjection/Compiler/DoctrinePass.php
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,15 @@ | ||
<?php | ||
|
||
namespace Zikula\Bundle\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class DoctrinePass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$container->setAlias('doctrine.entitymanager', 'doctrine.orm.default_entity_manager'); | ||
} | ||
} |
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
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
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
57 changes: 57 additions & 0 deletions
57
src/system/ZikulaRoutesModule/Translation/ConsoleCommandListener.php
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,57 @@ | ||
<?php | ||
/** | ||
* Copyright Zikula Foundation 2014 - Zikula Application Framework | ||
* | ||
* This work is contributed to the Zikula Foundation under one or more | ||
* Contributor Agreements and licensed to You under the following license: | ||
* | ||
* @license GNU/LGPv3 (or at your option any later version). | ||
* @package Zikula | ||
* | ||
* Please see the NOTICE file distributed with this source code for further | ||
* information regarding copyright and licensing. | ||
*/ | ||
|
||
namespace Zikula\RoutesModule\Translation; | ||
|
||
use Symfony\Component\Console\ConsoleEvents; | ||
use Symfony\Component\Console\Event\ConsoleCommandEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
|
||
/** | ||
* Class ConsoleCommandListener. | ||
*/ | ||
class ConsoleCommandListener implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return array ( | ||
ConsoleEvents::COMMAND => array('checkBundleForTranslatingRoutes') | ||
); | ||
} | ||
|
||
/** | ||
* This function saves the bundle whose routes shall be translated in a global variable to be used in | ||
* Zikula\RoutesModule\Translation\DefaultRouteExclusionStrategy later on. | ||
* | ||
* @param ConsoleCommandEvent $event | ||
*/ | ||
public function checkBundleForTranslatingRoutes(ConsoleCommandEvent $event) | ||
{ | ||
if ($event->getCommand()->getName() !== 'translation:extract') { | ||
return; | ||
} | ||
|
||
$GLOBALS['translation_extract_routes'] = true; | ||
|
||
if ($event->getInput()->hasParameterOption('--bundle')) { | ||
$bundle = $event->getInput()->getParameterOption('--bundle'); | ||
if ('@' === $bundle[0]) { | ||
$bundle = substr($bundle, 1); | ||
} | ||
|
||
$GLOBALS['translation_extract_routes_bundle'] = $bundle; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/system/ZikulaRoutesModule/Translation/DefaultRouteExclusionStrategy.php
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,36 @@ | ||
<?php | ||
/** | ||
* Copyright Zikula Foundation 2014 - Zikula Application Framework | ||
* | ||
* This work is contributed to the Zikula Foundation under one or more | ||
* Contributor Agreements and licensed to You under the following license: | ||
* | ||
* @license GNU/LGPv3 (or at your option any later version). | ||
* @package Zikula | ||
* | ||
* Please see the NOTICE file distributed with this source code for further | ||
* information regarding copyright and licensing. | ||
*/ | ||
|
||
namespace Zikula\RoutesModule\Translation; | ||
|
||
use JMS\I18nRoutingBundle\Router\DefaultRouteExclusionStrategy as BaseDefaultRouteExclusionStrategy; | ||
use Symfony\Component\Routing\Route; | ||
|
||
|
||
/** | ||
* Class DefaultRouteExclusionStrategy. | ||
*/ | ||
class DefaultRouteExclusionStrategy extends BaseDefaultRouteExclusionStrategy | ||
{ | ||
public function shouldExcludeRoute($routeName, Route $route) | ||
{ | ||
$exclude = parent::shouldExcludeRoute($routeName, $route); | ||
|
||
if (!$exclude && isset($GLOBALS['translation_extract_routes_bundle'])) { | ||
return $route->getDefault('_zkModule') !== $GLOBALS['translation_extract_routes_bundle']; | ||
} | ||
|
||
return $exclude; | ||
} | ||
} |