[FIX] Moment.JS Localisation

Load the right JS when our language code has 2 parts
- fr_FR
- it_IT
- pl_PL
And so on
This commit is contained in:
Peter Pfeufer 2025-01-08 23:04:29 +01:00
parent 7033406ba6
commit d99f5858d8
No known key found for this signature in database

View File

@ -1,7 +1,19 @@
{% load i18n %}
<!-- Start Moment.js from cdnjs --> <!-- Start Moment.js from cdnjs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js" integrity="sha512-+H4iLjY3JsKiF2V6N366in5IQHj2uEsGV7Pp/GRcm0fn76aPAk5V8xB6n8fQhhSonTqTXs/klFz4D0GIn6Br9g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js" integrity="sha512-+H4iLjY3JsKiF2V6N366in5IQHj2uEsGV7Pp/GRcm0fn76aPAk5V8xB6n8fQhhSonTqTXs/klFz4D0GIn6Br9g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% if locale and LANGUAGE_CODE != 'en' %} {% if locale and LANGUAGE_CODE != 'en' %}
<!-- Moment.JS Not EN-en --> <!-- Moment.JS Not EN-en -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/{{ LANGUAGE_CODE }}.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> {% get_current_language as LANGUAGE_CODE %}
{% get_language_info for LANGUAGE_CODE as lang %}
{% if lang.code == 'zh-hans' %}
<!-- Moment.JS Localisation ({{ lang.code }}) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/zh-cn.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% else %}
<!-- Moment.JS Localisation ({{ lang.code }}) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/{{ lang.code }}.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% endif %}
{% endif %} {% endif %}
<!-- End Moment JS from cdnjs --> <!-- End Moment JS from cdnjs -->