blob: 9456214fa49b4c61b7308ed74452cb186cad5a39 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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));
|