summaryrefslogtreecommitdiff
path: root/assets/static/vendor/leaflet-i18n/leaflet-i18n.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--assets/static/vendor/leaflet-i18n/leaflet-i18n.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/assets/static/vendor/leaflet-i18n/leaflet-i18n.js b/assets/static/vendor/leaflet-i18n/leaflet-i18n.js
new file mode 100644
index 0000000..9456214
--- /dev/null
+++ b/assets/static/vendor/leaflet-i18n/leaflet-i18n.js
@@ -0,0 +1,41 @@
+// Following https://github.com/Leaflet/Leaflet/blob/master/PLUGIN-GUIDE.md
+(function (factory, window) {
+
+ // define an AMD module that relies on 'leaflet'
+ if (typeof define === 'function' && define.amd) {
+ define(['leaflet'], factory);
+
+ // define a Common JS module that relies on 'leaflet'
+ } else if (typeof exports === 'object') {
+ module.exports = factory(require('leaflet'));
+ }
+
+ // attach your plugin to the global 'L' variable
+ if (typeof window !== 'undefined' && window.L) {
+ factory(window.L);
+
+ }
+}(function (L) {
+ L.locales = {};
+ L.locale = null;
+ L.registerLocale = function registerLocale(code, locale) {
+ L.locales[code] = L.Util.extend({}, L.locales[code], locale);
+ };
+ L.setLocale = function setLocale(code) {
+ L.locale = code;
+ };
+ return L.i18n = L._ = function translate(string, data) {
+ if (L.locale && L.locales[L.locale] && typeof L.locales[L.locale][string] !== "undefined") {
+ string = L.locales[L.locale][string];
+ }
+ try {
+ // Do not fail if some data is missing
+ // a bad translation should not break the app
+ string = L.Util.template(string, data);
+ }
+ catch (err) {/*pass*/
+ }
+
+ return string;
+ };
+}, window));