Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jan 10, 2017
1 parent a9a935d commit 7117a01
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Configuration/ConfigManager.php
Expand Up @@ -183,7 +183,7 @@ private function doProcessConfig($backendConfig)
{
$configPasses = array(
new NormalizerConfigPass($this->container),
new DesignConfigPass($this->container->get('twig'), $this->container->getParameter('kernel.debug')),
new DesignConfigPass($this->container->get('twig'), $this->container->getParameter('kernel.debug'), $this->container->getParameter('locale')),
new MenuConfigPass(),
new ActionConfigPass(),
new MetadataConfigPass($this->container->get('doctrine')),
Expand Down
19 changes: 17 additions & 2 deletions Configuration/DesignConfigPass.php
Expand Up @@ -21,20 +21,35 @@ class DesignConfigPass implements ConfigPassInterface
{
private $twig;
private $kernelDebug;
private $locale;

public function __construct(\Twig_Environment $twig, $kernelDebug)
public function __construct(\Twig_Environment $twig, $kernelDebug, $locale)
{
$this->kernelDebug = $kernelDebug;
$this->twig = $twig;
$this->kernelDebug = $kernelDebug;
$this->locale = $locale;
}

public function process(array $backendConfig)
{
$backendConfig = $this->processRtlLanguages($backendConfig);
$backendConfig = $this->processCustomCss($backendConfig);

return $backendConfig;
}

private function processRtlLanguages(array $backendConfig)
{
if (!isset($backendConfig['design']['rtl'])) {
// ar = Arabic, fa = Persian, he = Hebrew
if (in_array(substr($this->locale, 0, 2), array('ar', 'fa', 'he'))) {
$backendConfig['design']['rtl'] = true;
}
}

return $backendConfig;
}

private function processCustomCss(array $backendConfig)
{
$customCssContent = $this->twig->render('@EasyAdmin/css/easyadmin.css.twig', array(
Expand Down
7 changes: 3 additions & 4 deletions DependencyInjection/Configuration.php
Expand Up @@ -242,10 +242,9 @@ private function addDesignSection(ArrayNodeDefinition $rootNode)
->treatNullLike('dark')
->end()

->enumNode('rtl')
->values(array(true, false))
->info('Enable RTL direction (values: "true" or "false").')
->defaultValue(false)
->booleanNode('rtl')
->info('If true, the interface uses RTL (right-to-left) writing (needed for Arabic, Hebrew and Persian).')
->defaultFalse()
->treatNullLike(false)
->end()

Expand Down
2 changes: 1 addition & 1 deletion Resources/translations/EasyAdminBundle.ar.xlf
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
<file source-language="en" target-language="ar" datatype="plaintext" original="file.ext">
<body>
<!-- page titles -->
<trans-unit id="new.page_title">
Expand Down
2 changes: 1 addition & 1 deletion Resources/translations/messages.ar.xlf
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
<file source-language="en" target-language="ar" datatype="plaintext" original="file.ext">
<body>
<!-- generic actions displayed on buttons and links -->
<trans-unit id="action.new">
Expand Down
1 change: 0 additions & 1 deletion Resources/views/default/layout.html.twig
Expand Up @@ -43,7 +43,6 @@
{% endblock head_javascript %}

{% if easyadmin_config('design.rtl') %}
<!-- Load RTL stylesheet -->
<link rel="stylesheet" href="{{ asset('bundles/easyadmin/stylesheet/bootstrap-rtl.min.css') }}">
<link rel="stylesheet" href="{{ asset('bundles/easyadmin/stylesheet/adminlte-rtl.min.css') }}">
{% endif %}
Expand Down

0 comments on commit 7117a01

Please sign in to comment.