Browse Source

Merge remote-tracking branch 'sonata/master'

Stanislav Petrov 12 years ago
parent
commit
5497368ff9

+ 2 - 15
Form/Type/TranslatableChoiceType.php

@@ -47,21 +47,8 @@ class TranslatableChoiceType extends AbstractType
      * {@inheritDoc}
      */
     public function buildView(FormView $view, FormInterface $form, array $options)
-    {
-        // translate options before building form
-        foreach ($view->vars['choices'] as $choiceView) {
-            $choiceView->label = $this->translator->trans($choiceView->label, array(), $options['catalogue']);
-        }
-
-        // translate preferred options
-        foreach ($view->vars['preferred_choices'] as $choiceView) {
-            $choiceView->label = $this->translator->trans($choiceView->label, array(), $options['catalogue']);
-        }
-
-        // translate empty value
-        if (!empty($view->vars['empty_value'])) {
-            $view->vars['empty_value'] = $this->translator->trans($view->vars['empty_value'], array(), $options['catalogue']);
-        }
+    {       
+        $view->vars['translation_domain'] = $options['catalogue'];
     }
 
     /**

+ 2 - 0
Resources/doc/reference/form_types.rst

@@ -112,6 +112,8 @@ locked to 'yes' and 'no'.
 sonata_type_translatable_choice
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Deprecated: use ChoiceType with the translation_domain option instead.
+
 The translatable type is a specialized ``ChoiceType`` where the choices values 
 are translated with the Symfony Translator component.
 

+ 1 - 1
Resources/translations/SonataAdminBundle.hr.xliff

@@ -192,7 +192,7 @@
             </trans-unit>
             <trans-unit id="message_batch_confirmation">
                 <source>message_batch_confirmation</source>
-                <target>Jeste li sigurni da želite izvršiti ovu naredbu nad odabranim unosima?</target>
+                <target>Jeste li sigurni da želite izvršiti ovu naredbu nad odabranim unosom?|Jeste li sigurni da želite izvršiti ovu naredbu na %count% odabranih unosa?|Jeste li sigurni da želite izvršiti ovu naredbu na %count% odabrana unosa?</target>
             </trans-unit>
             <trans-unit id="btn_execute_batch_action">
                 <source>btn_execute_batch_action</source>

+ 1 - 1
Resources/translations/SonataAdminBundle.zh_CN.xliff

@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
-    <file source-language="zh_CN" datatype="plaintext" original="" >
+    <file source-language="en" datatype="plaintext" original="" >
         <body>
             <trans-unit id="action_delete">
                 <source>action_delete</source>

+ 3 - 3
Resources/views/Form/form_admin_fields.html.twig

@@ -29,7 +29,7 @@ file that was distributed with this source code.
         <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
             {{ widget|raw }}
             <span>
-                {% if not sonata_admin.admin%}
+                {% if not sonata_admin.admin %}
                     {{- label|trans({}, translation_domain) -}}
                 {% else %}
                     {{- label|trans({}, sonata_admin.admin.translationDomain) -}}
@@ -41,8 +41,8 @@ file that was distributed with this source code.
             {% if not sonata_admin.admin%}
                 {{- label|trans({}, translation_domain) -}}
             {% else %}
-                {{- label|trans({}, sonata_admin.admin.translationDomain) -}}
-            {% endif%}
+                {{ sonata_admin.admin.trans(label) }}
+            {% endif %}
             {{ required ? '*' : '' }}
         </label>
     {% endif %}

+ 8 - 5
Tests/Admin/PoolTest.php

@@ -49,10 +49,13 @@ class PoolTest extends \PHPUnit_Framework_TestCase
         $admin_group2 = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
         $admin_group2->expects($this->once())->method('showIn')->will($this->returnValue(false));
 
+        $admin_group3 = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
+        $admin_group3->expects($this->once())->method('showIn')->will($this->returnValue(false));
+
         $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
 
         $container->expects($this->any())->method('get')->will($this->onConsecutiveCalls(
-            $admin_group1, $admin_group2
+            $admin_group1, $admin_group2, $admin_group3
         ));
 
         $pool = new Pool($container, 'Sonata Admin', '/path/to/pic.png');
@@ -62,10 +65,10 @@ class PoolTest extends \PHPUnit_Framework_TestCase
                 'items' => array('itemKey' => 'sonata.user.admin.group1')
             ),
             'adminGroup2' => array(
-                'items' => array('itemKey' => 'sonata.user.admin.group1')
+                'items' => array('itemKey' => 'sonata.user.admin.group2')
             ),
             'adminGroup3' => array(
-                'items' => array('itemKey' => 'sonata.user.admin.group2')
+                'items' => array('itemKey' => 'sonata.user.admin.group3')
             ),
         ));
 
@@ -130,8 +133,8 @@ class PoolTest extends \PHPUnit_Framework_TestCase
 
     public function testGetAdminServiceIds()
     {
-        $this->pool->setAdminServiceIds(array('sonata.user.admin.group1', 'sonata.user.admin.group2'));
-        $this->assertEquals(array('sonata.user.admin.group1', 'sonata.user.admin.group2'), $this->pool->getAdminServiceIds());
+        $this->pool->setAdminServiceIds(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'));
+        $this->assertEquals(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'), $this->pool->getAdminServiceIds());
     }
 
     public function testGetContainer()