Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #102 Dropdown to change locale (JulienItard)
This PR was squashed before being merged into the master branch (closes #102). Discussion ---------- Dropdown to change locale see #83 Someone should add comments in routing.yml because my english it not good enough :) ![capture du 2015-07-15 19 52 19](https://cloud.githubusercontent.com/assets/1370893/8705607/0b15ade0-2b2b-11e5-933a-5cafaad4c8ee.png) Commits ------- 307236b Dropdown to change locale
- Loading branch information
Showing
8 changed files
with
88 additions
and
6 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 |
---|---|---|
|
@@ -59,6 +59,10 @@ header { | |
ul.nav li { | ||
margin-bottom: 0; | ||
} | ||
|
||
.locales a { | ||
padding-right: 10px; | ||
} | ||
} | ||
|
||
// Body contents | ||
|
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
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,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AppBundle\Twig; | ||
|
||
use Symfony\Component\Intl\Intl; | ||
|
||
/** | ||
* @author Julien ITARD <julienitard@gmail.com> | ||
*/ | ||
class LocaleExtension extends \Twig_Extension | ||
{ | ||
private $locales; | ||
|
||
public function __construct( $locales) | ||
{ | ||
$this->locales = $locales; | ||
} | ||
|
||
public function getFunctions() | ||
{ | ||
return array( | ||
new \Twig_SimpleFunction('locales', array($this, 'getLocales')), | ||
); | ||
} | ||
|
||
public function getLocales() | ||
{ | ||
$array = explode('|', $this->locales); | ||
|
||
foreach ($array as $locale) { | ||
$locales[] = array('code' => $locale, 'name' => Intl::getLocaleBundle()->getLocaleName($locale, $locale)); | ||
} | ||
|
||
return $locales; | ||
} | ||
|
||
// the name of the Twig extension must be unique in the application | ||
public function getName() | ||
{ | ||
return 'app.locale_extension'; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.