Browse Source

Include appropriate moment.js locale file

Add locale js of moment.js according to the current symfony locale in order to translate the datetimepicker
I used the same way than the one for select2.
Loïc colas 10 years ago
parent
commit
a63fcb0340
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Resources/views/standard_layout.html.twig

+ 7 - 2
Resources/views/standard_layout.html.twig

@@ -55,9 +55,14 @@ file that was distributed with this source code.
                 {% endfor %}
             {% endif %}
 
+            {% set locale = app.request.locale %}
+            {# localize moment #}
+            {% if locale[:2] != 'en' %}
+                <script src="{{ asset('bundles/sonatacore/vendor/moment/locale/' ~ locale|replace({'_':'-'}) ~ '.js') }}"></script>
+            {% endif %}
+
             {# localize select2 #}
-            {% if admin_pool is defined and admin_pool.getOption('use_select2') %}
-                {% set locale = app.request.locale %}
+            {% if admin_pool is defined and admin_pool.getOption('use_select2') %}             
                 {% if locale == 'pt' %}{% set locale = 'pt_PT' %}{% endif %}
 
                 {# omit default EN locale #}