Commits

Yohan Boniface committed 87e1a07

setLocale before loading any storage js file

Comments (0)

Files changed (4)

leaflet_storage/templates/leaflet_storage/js.html

 <script src="{{ STATIC_URL }}markercluster/dist/leaflet.markercluster-src.js"></script>
 <script src="{{ STATIC_URL }}measure/leaflet.measurecontrol.js"></script>
 <script src="{{ STATIC_URL }}contextmenu/dist/leaflet.contextmenu-src.js"></script>
+{% if locale %}
+    <script src="{{ STATIC_URL }}storage/src/locale/{{ locale }}.js"></script>
+{% endif %}
 <script src="{{ STATIC_URL }}storage/src/js/leaflet.storage.core.js"></script>
 <script src="{{ STATIC_URL }}storage/src/js/leaflet.storage.xhr.js"></script>
 <script src="{{ STATIC_URL }}storage/src/js/leaflet.storage.forms.js"></script>

leaflet_storage/templates/leaflet_storage/locale.js

 var locale = {{ locale|safe }};
-L.registerLocale("{{ locale_code }}", locale);
+L.registerLocale("{{ locale_code }}", locale);
+L.setLocale("{{ locale_code }}");

leaflet_storage/templates/leaflet_storage/map_detail.html

 {% block extra_head %}
     {{ block.super }}
     {% leaflet_storage_css %}
-    {% leaflet_storage_js %}
+    {% leaflet_storage_js locale=locale %}
 {% endblock %}
 
 {% block content %}

leaflet_storage/templatetags/leaflet_storage_tags.py

 
 
 @register.inclusion_tag('leaflet_storage/js.html')
-def leaflet_storage_js():
+def leaflet_storage_js(locale=None):
     return {
-        "STATIC_URL": settings.STATIC_URL
+        "STATIC_URL": settings.STATIC_URL,
+        "locale": locale
     }