diff --git a/src/Resources/views/standard_layout.html.twig b/src/Resources/views/standard_layout.html.twig index 89847c4bb6d..0f832ca9528 100644 --- a/src/Resources/views/standard_layout.html.twig +++ b/src/Resources/views/standard_layout.html.twig @@ -66,22 +66,36 @@ file that was distributed with this source code. {% endblock %} {% set locale = app.request.locale %} - {# localize moment #} + + {# omit default "en" locale #} {% if locale[:2] != 'en' %} + {# localize moment #} + {% set localeForMoment = locale|lower|replace({'_':'-'}) %} + {# `moment: ^2.8` only ships "es" and "es-do" locales for "es" language #} + {% if localeForMoment[:2] == 'es' and localeForMoment not in ['es', 'es-do'] %}{% set localeForMoment = 'es' %}{% endif %} + {# @todo: there are more locales which are not supported by moment and they need to be translated/normalized/canonicalized here #} - {% endif %} - - {# localize select2 #} - {% if sonata_admin.adminPool.getOption('use_select2') %} - {% if locale == 'pt' %}{% set locale = 'pt_PT' %}{% endif %} - {# omit default EN locale #} - {% if locale[:2] != 'en' %} - + {# localize select2 #} + {% if sonata_admin.adminPool.getOption('use_select2') %} + {% set localeForSelect2 = locale %} + {% if locale == 'pt' %} + {# `select2: ^3.5` only ships "pt" locale as "pt-PT" #} + {% set localeForSelect2 = 'pt-PT' %} + {% elseif locale == 'ug' %} + {# `select2: ^3.5` only ships "ug" locale as "ug-CN" #} + {% set localeForSelect2 = 'ug-CN' %} + {% elseif locale == 'zh' %} + {# `select2: ^3.5` only ships "zh" locale as "zh-CN" and "zh-TW" #} + {% set localeForSelect2 = 'zh-CN' %} + {% elseif locale != 'zh-TW' %} + {% set localeForSelect2 = locale[:2] %} + {% endif %} + {% endif %} {% endif %} {% endblock %}