mirror of
https://github.com/openstreetmap/openstreetmap-website.git
synced 2025-07-29 12:51:32 +00:00
Replace use of I18n in javascript with OSM.i18n
This commit is contained in:
@ -21,13 +21,13 @@
|
||||
|
||||
OSM.i18n = I18n;
|
||||
|
||||
I18n.default_locale = OSM.DEFAULT_LOCALE;
|
||||
I18n.locale = locale;
|
||||
OSM.i18n.default_locale = OSM.DEFAULT_LOCALE;
|
||||
OSM.i18n.locale = locale;
|
||||
|
||||
// '-' are replaced with '_' in https://github.com/eemeli/make-plural/tree/main/packages/plurals
|
||||
const pluralizer = plurals[locale.replace(/\W+/g, "_")] || plurals[locale.split("-")[0]];
|
||||
if (pluralizer) {
|
||||
I18n.pluralization[locale] = (count) => [pluralizer(count), "other"];
|
||||
OSM.i18n.pluralization[locale] = (count) => [pluralizer(count), "other"];
|
||||
}
|
||||
|
||||
OSM.preferred_editor = application_data.preferredEditor;
|
||||
@ -199,5 +199,5 @@ $(function () {
|
||||
});
|
||||
|
||||
$("#edit_tab")
|
||||
.attr("title", I18n.t("javascripts.site.edit_disabled_tooltip"));
|
||||
.attr("title", OSM.i18n.t("javascripts.site.edit_disabled_tooltip"));
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ $(function () {
|
||||
}
|
||||
|
||||
marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map)
|
||||
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
|
||||
.bindPopup(OSM.i18n.t("diary_entries.edit.marker_text"));
|
||||
}
|
||||
|
||||
$("#usemap").click(function (e) {
|
||||
@ -37,7 +37,7 @@ $(function () {
|
||||
|
||||
if ($("#latitude").val() && $("#longitude").val()) {
|
||||
marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map)
|
||||
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
|
||||
.bindPopup(OSM.i18n.t("diary_entries.edit.marker_text"));
|
||||
}
|
||||
|
||||
map.on("click", setLocation);
|
||||
|
@ -4,7 +4,7 @@ $(function () {
|
||||
|
||||
if (!idData.configured) {
|
||||
// eslint-disable-next-line no-alert
|
||||
alert(I18n.t("site.edit.id_not_configured"));
|
||||
alert(OSM.i18n.t("site.edit.id_not_configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
const OSM = { i18n: I18n };
|
||||
|
||||
if (navigator.languages) {
|
||||
I18n.locale = navigator.languages[0];
|
||||
OSM.i18n.locale = navigator.languages[0];
|
||||
} else if (navigator.language) {
|
||||
I18n.locale = navigator.language;
|
||||
OSM.i18n.locale = navigator.language;
|
||||
}
|
||||
|
||||
I18n.default_locale = <%= I18n.default_locale.to_json %>;
|
||||
I18n.fallbacks = true;
|
||||
OSM.i18n.default_locale = <%= I18n.default_locale.to_json %>;
|
||||
OSM.i18n.fallbacks = true;
|
||||
|
||||
window.onload = function () {
|
||||
const args = Object.fromEntries(new URLSearchParams(location.search));
|
||||
@ -58,7 +58,7 @@ window.onload = function () {
|
||||
L.Control.OSMReportAProblem = L.Control.Attribution.extend({
|
||||
options: {
|
||||
position: "bottomright",
|
||||
prefix: `<a href="https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}" target="_blank">${I18n.t("javascripts.embed.report_problem")}</a>`
|
||||
prefix: `<a href="https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}" target="_blank">${OSM.i18n.t("javascripts.embed.report_problem")}</a>`
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
|
@ -16,7 +16,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const colorScheme = document.documentElement.getAttribute("data-bs-theme") ?? "auto";
|
||||
const rangeColors = ["#14432a", "#166b34", "#37a446", "#4dd05a"];
|
||||
const startDate = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000));
|
||||
const monthNames = I18n.t("date.abbr_month_names");
|
||||
const monthNames = OSM.i18n.t("date.abbr_month_names");
|
||||
|
||||
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
|
||||
@ -86,13 +86,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
|
||||
function getTooltipText(date, value) {
|
||||
const localizedDate = I18n.l("date.formats.long", date);
|
||||
const localizedDate = OSM.i18n.l("date.formats.long", date);
|
||||
|
||||
if (value > 0) {
|
||||
return I18n.t("javascripts.heatmap.tooltip.contributions", { count: value, date: localizedDate });
|
||||
return OSM.i18n.t("javascripts.heatmap.tooltip.contributions", { count: value, date: localizedDate });
|
||||
}
|
||||
|
||||
return I18n.t("javascripts.heatmap.tooltip.no_contributions", { date: localizedDate });
|
||||
return OSM.i18n.t("javascripts.heatmap.tooltip.no_contributions", { date: localizedDate });
|
||||
}
|
||||
|
||||
function getTheme() {
|
||||
|
@ -245,7 +245,7 @@ $(function () {
|
||||
})
|
||||
.catch(() => {
|
||||
// eslint-disable-next-line no-alert
|
||||
alert(I18n.t("site.index.remote_failed"));
|
||||
alert(OSM.i18n.t("site.index.remote_failed"));
|
||||
});
|
||||
|
||||
function sendRemoteEditCommand(url) {
|
||||
@ -266,7 +266,7 @@ $(function () {
|
||||
.removeAttr("title")
|
||||
.tooltip({
|
||||
placement: "bottom",
|
||||
title: I18n.t("javascripts.edit_help")
|
||||
title: OSM.i18n.t("javascripts.edit_help")
|
||||
})
|
||||
.tooltip("show");
|
||||
|
||||
@ -280,7 +280,7 @@ $(function () {
|
||||
|
||||
page.pushstate = page.popstate = function () {
|
||||
map.setSidebarOverlaid(true);
|
||||
document.title = I18n.t("layouts.project_name.title");
|
||||
document.title = OSM.i18n.t("layouts.project_name.title");
|
||||
};
|
||||
|
||||
page.load = function () {
|
||||
|
@ -1,6 +1,6 @@
|
||||
OSM.initializeContextMenu = function (map) {
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.directions_from"),
|
||||
text: OSM.i18n.t("javascripts.context.directions_from"),
|
||||
callback: function directionsFromHere(e) {
|
||||
const latlng = OSM.cropLocation(e.latlng, map.getZoom());
|
||||
|
||||
@ -12,7 +12,7 @@ OSM.initializeContextMenu = function (map) {
|
||||
});
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.directions_to"),
|
||||
text: OSM.i18n.t("javascripts.context.directions_to"),
|
||||
callback: function directionsToHere(e) {
|
||||
const latlng = OSM.cropLocation(e.latlng, map.getZoom());
|
||||
|
||||
@ -24,7 +24,7 @@ OSM.initializeContextMenu = function (map) {
|
||||
});
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.add_note"),
|
||||
text: OSM.i18n.t("javascripts.context.add_note"),
|
||||
callback: function addNoteHere(e) {
|
||||
const [lat, lon] = OSM.cropLocation(e.latlng, map.getZoom());
|
||||
|
||||
@ -33,7 +33,7 @@ OSM.initializeContextMenu = function (map) {
|
||||
});
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.show_address"),
|
||||
text: OSM.i18n.t("javascripts.context.show_address"),
|
||||
callback: function describeLocation(e) {
|
||||
const [lat, lon] = OSM.cropLocation(e.latlng, map.getZoom());
|
||||
|
||||
@ -42,7 +42,7 @@ OSM.initializeContextMenu = function (map) {
|
||||
});
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.query_features"),
|
||||
text: OSM.i18n.t("javascripts.context.query_features"),
|
||||
callback: function queryFeatures(e) {
|
||||
const [lat, lon] = OSM.cropLocation(e.latlng, map.getZoom());
|
||||
|
||||
@ -51,7 +51,7 @@ OSM.initializeContextMenu = function (map) {
|
||||
});
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: I18n.t("javascripts.context.centre_map"),
|
||||
text: OSM.i18n.t("javascripts.context.centre_map"),
|
||||
callback: function centreMap(e) {
|
||||
map.panTo(e.latlng);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
|
||||
if (json.length === 0) {
|
||||
input.addClass("is-invalid");
|
||||
// eslint-disable-next-line no-alert
|
||||
alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
|
||||
alert(OSM.i18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,11 @@ OSM.Directions = function (map) {
|
||||
|
||||
function formatTotalDistance(m) {
|
||||
if (m < 1000) {
|
||||
return I18n.t("javascripts.directions.distance_m", { distance: Math.round(m) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) });
|
||||
} else if (m < 10000) {
|
||||
return I18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) });
|
||||
} else {
|
||||
return I18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) });
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,18 +84,18 @@ OSM.Directions = function (map) {
|
||||
if (m < 5) {
|
||||
return "";
|
||||
} else if (m < 200) {
|
||||
return I18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 10) * 10) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 10) * 10) });
|
||||
} else if (m < 1500) {
|
||||
return I18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 100) * 100) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 100) * 100) });
|
||||
} else if (m < 5000) {
|
||||
return I18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 100) / 10) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 100) / 10) });
|
||||
} else {
|
||||
return I18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 1000)) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 1000)) });
|
||||
}
|
||||
}
|
||||
|
||||
function formatHeight(m) {
|
||||
return I18n.t("javascripts.directions.distance_m", { distance: Math.round(m) });
|
||||
return OSM.i18n.t("javascripts.directions.distance_m", { distance: Math.round(m) });
|
||||
}
|
||||
|
||||
function formatTime(s) {
|
||||
@ -164,13 +164,13 @@ OSM.Directions = function (map) {
|
||||
}
|
||||
|
||||
const distanceText = $("<p>").append(
|
||||
I18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " +
|
||||
I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".");
|
||||
OSM.i18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " +
|
||||
OSM.i18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".");
|
||||
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
|
||||
distanceText.append(
|
||||
$("<br>"),
|
||||
I18n.t("javascripts.directions.ascend") + ": " + formatHeight(route.ascend) + ". " +
|
||||
I18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + ".");
|
||||
OSM.i18n.t("javascripts.directions.ascend") + ": " + formatHeight(route.ascend) + ". " +
|
||||
OSM.i18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + ".");
|
||||
}
|
||||
|
||||
const turnByTurnTable = $("<table class='table table-hover table-sm mb-3'>")
|
||||
@ -219,18 +219,18 @@ OSM.Directions = function (map) {
|
||||
downloadURL = URL.createObjectURL(blob);
|
||||
|
||||
$("#directions_content").append(`<p class="text-center"><a href="${downloadURL}" download="${
|
||||
I18n.t("javascripts.directions.filename")
|
||||
OSM.i18n.t("javascripts.directions.filename")
|
||||
}">${
|
||||
I18n.t("javascripts.directions.download")
|
||||
OSM.i18n.t("javascripts.directions.download")
|
||||
}</a></p>`);
|
||||
|
||||
$("#directions_content").append("<p class=\"text-center\">" +
|
||||
I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) +
|
||||
OSM.i18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) +
|
||||
"</p>");
|
||||
}).catch(function () {
|
||||
map.removeLayer(polyline);
|
||||
if (reportErrors) {
|
||||
$("#directions_content").html("<div class=\"alert alert-danger\">" + I18n.t("javascripts.directions.errors.no_route") + "</div>");
|
||||
$("#directions_content").html("<div class=\"alert alert-danger\">" + OSM.i18n.t("javascripts.directions.errors.no_route") + "</div>");
|
||||
}
|
||||
}).finally(function () {
|
||||
controller = null;
|
||||
|
@ -109,21 +109,21 @@
|
||||
} else if (step.ref) {
|
||||
name = "<b>" + step.ref + "</b>";
|
||||
} else {
|
||||
name = I18n.t(instrPrefix + "unnamed");
|
||||
name = OSM.i18n.t(instrPrefix + "unnamed");
|
||||
namedRoad = false;
|
||||
}
|
||||
|
||||
if (step.maneuver.type.match(/^exit (rotary|roundabout)$/)) {
|
||||
instText += I18n.t(template, { name: name });
|
||||
instText += OSM.i18n.t(template, { name: name });
|
||||
} else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) {
|
||||
if (step.maneuver.exit) {
|
||||
if (step.maneuver.exit <= 10) {
|
||||
instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t(instrPrefix + "exit_counts." + numToWord(step.maneuver.exit)), name: name });
|
||||
instText += OSM.i18n.t(template + "_with_exit_ordinal", { exit: OSM.i18n.t(instrPrefix + "exit_counts." + numToWord(step.maneuver.exit)), name: name });
|
||||
} else {
|
||||
instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name });
|
||||
instText += OSM.i18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name });
|
||||
}
|
||||
} else {
|
||||
instText += I18n.t(template + "_without_exit", { name: name });
|
||||
instText += OSM.i18n.t(template + "_without_exit", { name: name });
|
||||
}
|
||||
} else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) {
|
||||
const params = {};
|
||||
@ -133,9 +133,9 @@
|
||||
if (Object.keys(params).length > 0) {
|
||||
template = template + "_with_" + Object.keys(params).join("_");
|
||||
}
|
||||
instText += I18n.t(template, params);
|
||||
instText += OSM.i18n.t(template, params);
|
||||
} else {
|
||||
instText += I18n.t(template + "_without_exit", { name: name });
|
||||
instText += OSM.i18n.t(template + "_without_exit", { name: name });
|
||||
}
|
||||
return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry];
|
||||
})
|
||||
|
@ -97,7 +97,7 @@
|
||||
costing: costing,
|
||||
directions_options: {
|
||||
units: "km",
|
||||
language: I18n.currentLocale()
|
||||
language: OSM.i18n.currentLocale()
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -57,7 +57,7 @@
|
||||
// https://graphhopper.com/api/1/docs/routing/
|
||||
const query = new URLSearchParams({
|
||||
vehicle: vehicleType,
|
||||
locale: I18n.currentLocale(),
|
||||
locale: OSM.i18n.currentLocale(),
|
||||
key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
|
||||
elevation: false,
|
||||
instructions: true,
|
||||
|
@ -18,12 +18,12 @@ OSM.Home = function (map) {
|
||||
});
|
||||
marker = L.marker(OSM.home, {
|
||||
icon: OSM.getUserIcon(),
|
||||
title: I18n.t("javascripts.home.marker_title")
|
||||
title: OSM.i18n.t("javascripts.home.marker_title")
|
||||
}).addTo(map);
|
||||
} else {
|
||||
$("#browse_status").html(
|
||||
$("<div class='m-2 alert alert-warning'>").text(
|
||||
I18n.t("javascripts.home.not_set")
|
||||
OSM.i18n.t("javascripts.home.not_set")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -51,15 +51,15 @@ OSM.initializeDataLayer = function (map) {
|
||||
$("<div class='p-3'>").append(
|
||||
$("<div class='d-flex'>").append(
|
||||
$("<h2 class='flex-grow-1 text-break'>")
|
||||
.text(I18n.t("browse.start_rjs.load_data")),
|
||||
.text(OSM.i18n.t("browse.start_rjs.load_data")),
|
||||
$("<div>").append(
|
||||
$("<button type='button' class='btn-close'>")
|
||||
.attr("aria-label", I18n.t("javascripts.close"))
|
||||
.attr("aria-label", OSM.i18n.t("javascripts.close"))
|
||||
.click(cancel))),
|
||||
$("<p class='alert alert-warning'>")
|
||||
.text(I18n.t("browse.start_rjs.feature_warning", { num_features })),
|
||||
.text(OSM.i18n.t("browse.start_rjs.feature_warning", { num_features })),
|
||||
$("<input type='submit' class='btn btn-primary d-block mx-auto'>")
|
||||
.val(I18n.t("browse.start_rjs.load_data"))
|
||||
.val(OSM.i18n.t("browse.start_rjs.load_data"))
|
||||
.click(add)));
|
||||
}
|
||||
|
||||
@ -68,13 +68,13 @@ OSM.initializeDataLayer = function (map) {
|
||||
$("<div class='p-3'>").append(
|
||||
$("<div class='d-flex'>").append(
|
||||
$("<h2 class='flex-grow-1 text-break'>")
|
||||
.text(I18n.t("browse.start_rjs.load_data")),
|
||||
.text(OSM.i18n.t("browse.start_rjs.load_data")),
|
||||
$("<div>").append(
|
||||
$("<button type='button' class='btn-close'>")
|
||||
.attr("aria-label", I18n.t("javascripts.close"))
|
||||
.attr("aria-label", OSM.i18n.t("javascripts.close"))
|
||||
.click(close))),
|
||||
$("<p class='alert alert-warning'>")
|
||||
.text(I18n.t("browse.start_rjs.feature_error", { message: message }))));
|
||||
.text(OSM.i18n.t("browse.start_rjs.feature_error", { message: message }))));
|
||||
}
|
||||
|
||||
function getData() {
|
||||
@ -95,7 +95,7 @@ OSM.initializeDataLayer = function (map) {
|
||||
.attr("id", "layers-data-loading")
|
||||
.attr("class", "spinner-border spinner-border-sm ms-1")
|
||||
.attr("role", "status")
|
||||
.html("<span class='visually-hidden'>" + I18n.t("browse.start_rjs.loading") + "</span>")
|
||||
.html("<span class='visually-hidden'>" + OSM.i18n.t("browse.start_rjs.loading") + "</span>")
|
||||
.appendTo($("#label-layers-data"));
|
||||
|
||||
dataLoader = new AbortController();
|
||||
|
@ -69,13 +69,13 @@ OSM.Query = function (map) {
|
||||
let prefix = "";
|
||||
|
||||
if (tags.boundary === "administrative" && (tags.border_type || tags.admin_level)) {
|
||||
prefix = I18n.t("geocoder.search_osm_nominatim.border_types." + tags.border_type, {
|
||||
defaultValue: I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
|
||||
defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
|
||||
prefix = OSM.i18n.t("geocoder.search_osm_nominatim.border_types." + tags.border_type, {
|
||||
defaultValue: OSM.i18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
|
||||
defaultValue: OSM.i18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
|
||||
})
|
||||
});
|
||||
} else {
|
||||
const prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");
|
||||
const prefixes = OSM.i18n.t("geocoder.search_osm_nominatim.prefix");
|
||||
|
||||
for (const key in tags) {
|
||||
const value = tags[key];
|
||||
@ -100,7 +100,7 @@ OSM.Query = function (map) {
|
||||
}
|
||||
|
||||
if (!prefix) {
|
||||
prefix = I18n.t("javascripts.query." + feature.type);
|
||||
prefix = OSM.i18n.t("javascripts.query." + feature.type);
|
||||
}
|
||||
|
||||
return prefix;
|
||||
@ -213,14 +213,14 @@ OSM.Query = function (map) {
|
||||
if (results.remark) {
|
||||
$("<li>")
|
||||
.addClass("list-group-item")
|
||||
.text(I18n.t("javascripts.query.error", { server: url, error: results.remark }))
|
||||
.text(OSM.i18n.t("javascripts.query.error", { server: url, error: results.remark }))
|
||||
.appendTo($ul);
|
||||
}
|
||||
|
||||
if ($ul.find("li").length === 0) {
|
||||
$("<li>")
|
||||
.addClass("list-group-item")
|
||||
.text(I18n.t("javascripts.query.nothing_found"))
|
||||
.text(OSM.i18n.t("javascripts.query.nothing_found"))
|
||||
.appendTo($ul);
|
||||
}
|
||||
})
|
||||
@ -231,7 +231,7 @@ OSM.Query = function (map) {
|
||||
|
||||
$("<li>")
|
||||
.addClass("list-group-item")
|
||||
.text(I18n.t("javascripts.query.error", { server: url, error: error.message }))
|
||||
.text(OSM.i18n.t("javascripts.query.error", { server: url, error: error.message }))
|
||||
.appendTo($ul);
|
||||
});
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ L.OSM.key = function (options) {
|
||||
button
|
||||
.toggleClass("disabled", disabled)
|
||||
.attr("data-bs-original-title",
|
||||
I18n.t(disabled ?
|
||||
OSM.i18n.t(disabled ?
|
||||
"javascripts.key.tooltip_disabled" :
|
||||
"javascripts.key.tooltip"));
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ L.OSM.layers = function (options) {
|
||||
.appendTo($ui);
|
||||
|
||||
$("<p>")
|
||||
.text(I18n.t("javascripts.map.layers.overlays"))
|
||||
.text(OSM.i18n.t("javascripts.map.layers.overlays"))
|
||||
.attr("class", "text-body-secondary small mb-2")
|
||||
.appendTo(overlaySection);
|
||||
|
||||
@ -94,7 +94,7 @@ L.OSM.layers = function (options) {
|
||||
|
||||
if (name === "notes" || name === "data") {
|
||||
item
|
||||
.attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip"))
|
||||
.attr("title", OSM.i18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip"))
|
||||
.tooltip("disable");
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ L.OSM.layers = function (options) {
|
||||
.prop("checked", checked)
|
||||
.appendTo(label);
|
||||
|
||||
label.append(I18n.t("javascripts.map.layers." + name));
|
||||
label.append(OSM.i18n.t("javascripts.map.layers." + name));
|
||||
|
||||
input.on("change", function () {
|
||||
checked = input.is(":checked");
|
||||
|
@ -3,9 +3,9 @@ L.OSM.locate = function (options) {
|
||||
icon: "icon geolocate",
|
||||
iconLoading: "icon geolocate",
|
||||
strings: {
|
||||
title: I18n.t("javascripts.map.locate.title"),
|
||||
title: OSM.i18n.t("javascripts.map.locate.title"),
|
||||
popup: function (options) {
|
||||
return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
|
||||
return OSM.i18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
|
||||
}
|
||||
},
|
||||
...options
|
||||
|
@ -23,7 +23,7 @@ L.OSM.Map = L.Map.extend({
|
||||
if (property === "credit") {
|
||||
layerOptions.attribution = makeAttribution(value);
|
||||
} else if (property === "nameId") {
|
||||
layerOptions.name = I18n.t(`javascripts.map.base.${value}`);
|
||||
layerOptions.name = OSM.i18n.t(`javascripts.map.base.${value}`);
|
||||
} else if (property === "leafletOsmId") {
|
||||
layerConstructor = L.OSM[value];
|
||||
} else if (property === "leafletOsmDarkId" && OSM.isDarkMap() && L.OSM[value]) {
|
||||
@ -66,10 +66,10 @@ L.OSM.Map = L.Map.extend({
|
||||
function makeAttribution(credit) {
|
||||
let attribution = "";
|
||||
|
||||
attribution += I18n.t("javascripts.map.copyright_text", {
|
||||
attribution += OSM.i18n.t("javascripts.map.copyright_text", {
|
||||
copyright_link: $("<a>", {
|
||||
href: "/copyright",
|
||||
text: I18n.t("javascripts.map.openstreetmap_contributors")
|
||||
text: OSM.i18n.t("javascripts.map.openstreetmap_contributors")
|
||||
}).prop("outerHTML")
|
||||
});
|
||||
|
||||
@ -79,7 +79,7 @@ L.OSM.Map = L.Map.extend({
|
||||
|
||||
attribution += $("<a>", {
|
||||
href: "https://wiki.osmfoundation.org/wiki/Terms_of_Use",
|
||||
text: I18n.t("javascripts.map.website_and_api_terms")
|
||||
text: OSM.i18n.t("javascripts.map.website_and_api_terms")
|
||||
}).prop("outerHTML");
|
||||
|
||||
return attribution;
|
||||
@ -90,7 +90,7 @@ L.OSM.Map = L.Map.extend({
|
||||
for (const childId in credit.children) {
|
||||
children[childId] = makeCredit(credit.children[childId]);
|
||||
}
|
||||
const text = I18n.t(`javascripts.map.${credit.id}`, children);
|
||||
const text = OSM.i18n.t(`javascripts.map.${credit.id}`, children);
|
||||
if (credit.href) {
|
||||
const link = $("<a>", {
|
||||
href: credit.href,
|
||||
|
@ -18,7 +18,7 @@ L.OSM.note = function (options) {
|
||||
isDisabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
|
||||
link
|
||||
.toggleClass("disabled", isDisabled)
|
||||
.attr("data-bs-original-title", I18n.t(isDisabled ?
|
||||
.attr("data-bs-original-title", OSM.i18n.t(isDisabled ?
|
||||
"javascripts.site.createnote_disabled_tooltip" :
|
||||
"javascripts.site.createnote_tooltip"));
|
||||
if (isDisabled === wasDisabled) return;
|
||||
|
@ -18,7 +18,7 @@ L.OSM.query = function (options) {
|
||||
isDisabled = map.getZoom() < 14;
|
||||
link
|
||||
.toggleClass("disabled", isDisabled)
|
||||
.attr("data-bs-original-title", I18n.t(isDisabled ?
|
||||
.attr("data-bs-original-title", OSM.i18n.t(isDisabled ?
|
||||
"javascripts.site.queryfeature_disabled_tooltip" :
|
||||
"javascripts.site.queryfeature_tooltip"));
|
||||
if (isDisabled === wasDisabled) return;
|
||||
|
@ -15,7 +15,7 @@ L.OSM.share = function (options) {
|
||||
.appendTo($ui);
|
||||
|
||||
$("<h4>")
|
||||
.text(I18n.t("javascripts.share.link"))
|
||||
.text(OSM.i18n.t("javascripts.share.link"))
|
||||
.appendTo($linkSection);
|
||||
|
||||
let $form = $("<form>")
|
||||
@ -27,7 +27,7 @@ L.OSM.share = function (options) {
|
||||
.append($("<label>")
|
||||
.attr("for", "link_marker")
|
||||
.attr("class", "form-check-label")
|
||||
.text(I18n.t("javascripts.share.include_marker")))
|
||||
.text(OSM.i18n.t("javascripts.share.include_marker")))
|
||||
.append($("<input>")
|
||||
.attr("id", "link_marker")
|
||||
.attr("type", "checkbox")
|
||||
@ -40,17 +40,17 @@ L.OSM.share = function (options) {
|
||||
.addClass("active")
|
||||
.attr("for", "long_input")
|
||||
.attr("id", "long_link")
|
||||
.text(I18n.t("javascripts.share.long_link")))
|
||||
.text(OSM.i18n.t("javascripts.share.long_link")))
|
||||
.append($("<a class='btn btn-primary'>")
|
||||
.attr("for", "short_input")
|
||||
.attr("id", "short_link")
|
||||
.text(I18n.t("javascripts.share.short_link")))
|
||||
.text(OSM.i18n.t("javascripts.share.short_link")))
|
||||
.append($("<a class='btn btn-primary'>")
|
||||
.attr("for", "embed_html")
|
||||
.attr("id", "embed_link")
|
||||
.attr("data-bs-title", I18n.t("javascripts.site.embed_html_disabled"))
|
||||
.attr("data-bs-title", OSM.i18n.t("javascripts.site.embed_html_disabled"))
|
||||
.attr("href", "#")
|
||||
.text(I18n.t("javascripts.share.embed")))
|
||||
.text(OSM.i18n.t("javascripts.share.embed")))
|
||||
.on("click", "a", function (e) {
|
||||
e.preventDefault();
|
||||
if (!$(this).hasClass("btn-primary")) return;
|
||||
@ -100,7 +100,7 @@ L.OSM.share = function (options) {
|
||||
.append(
|
||||
$("<p>")
|
||||
.attr("class", "text-body-secondary")
|
||||
.text(I18n.t("javascripts.share.paste_html")));
|
||||
.text(OSM.i18n.t("javascripts.share.paste_html")));
|
||||
|
||||
// Geo URI
|
||||
|
||||
@ -109,7 +109,7 @@ L.OSM.share = function (options) {
|
||||
.appendTo($ui);
|
||||
|
||||
$("<h4>")
|
||||
.text(I18n.t("javascripts.share.geo_uri"))
|
||||
.text(OSM.i18n.t("javascripts.share.geo_uri"))
|
||||
.appendTo($geoUriSection);
|
||||
|
||||
$("<div>")
|
||||
@ -124,13 +124,13 @@ L.OSM.share = function (options) {
|
||||
.appendTo($ui);
|
||||
|
||||
$("<h4>")
|
||||
.text(I18n.t("javascripts.share.image"))
|
||||
.text(OSM.i18n.t("javascripts.share.image"))
|
||||
.appendTo($imageSection);
|
||||
|
||||
$("<div>")
|
||||
.attr("id", "export-warning")
|
||||
.attr("class", "text-body-secondary")
|
||||
.text(I18n.t("javascripts.share.only_layers_exported_as_image"))
|
||||
.text(OSM.i18n.t("javascripts.share.only_layers_exported_as_image"))
|
||||
.append(
|
||||
$("<ul>").append(
|
||||
map.baseLayers
|
||||
@ -150,7 +150,7 @@ L.OSM.share = function (options) {
|
||||
.append($("<label>")
|
||||
.attr("for", "mapnik_format")
|
||||
.attr("class", "col-auto col-form-label")
|
||||
.text(I18n.t("javascripts.share.format")))
|
||||
.text(OSM.i18n.t("javascripts.share.format")))
|
||||
.append($("<div>")
|
||||
.attr("class", "col-auto")
|
||||
.append($("<select>")
|
||||
@ -170,7 +170,7 @@ L.OSM.share = function (options) {
|
||||
.append($("<label>")
|
||||
.attr("for", "mapnik_scale")
|
||||
.attr("class", "col-auto col-form-label")
|
||||
.text(I18n.t("javascripts.share.scale")))
|
||||
.text(OSM.i18n.t("javascripts.share.scale")))
|
||||
.append($("<div>")
|
||||
.attr("class", "col-auto")
|
||||
.append($("<div>")
|
||||
@ -195,7 +195,7 @@ L.OSM.share = function (options) {
|
||||
.append($("<label>")
|
||||
.attr("for", "image_filter")
|
||||
.attr("class", "form-check-label")
|
||||
.text(I18n.t("javascripts.share.custom_dimensions")))
|
||||
.text(OSM.i18n.t("javascripts.share.custom_dimensions")))
|
||||
.append($("<input>")
|
||||
.attr("id", "image_filter")
|
||||
.attr("type", "checkbox")
|
||||
@ -243,13 +243,13 @@ L.OSM.share = function (options) {
|
||||
|
||||
$("<p>")
|
||||
.attr("class", "text-body-secondary")
|
||||
.html(I18n.t("javascripts.share.image_dimensions", args))
|
||||
.html(OSM.i18n.t("javascripts.share.image_dimensions", args))
|
||||
.appendTo($form);
|
||||
|
||||
$("<input>")
|
||||
.attr("type", "submit")
|
||||
.attr("class", "btn btn-primary")
|
||||
.attr("value", I18n.t("javascripts.share.download"))
|
||||
.attr("value", OSM.i18n.t("javascripts.share.download"))
|
||||
.appendTo($form);
|
||||
|
||||
locationFilter
|
||||
@ -371,7 +371,7 @@ L.OSM.share = function (options) {
|
||||
escapeHTML(OSM.SERVER_PROTOCOL + "://" + OSM.SERVER_URL + "/export/embed.html?" + params) +
|
||||
"\" style=\"border: 1px solid black\"></iframe><br/>" +
|
||||
"<small><a href=\"" + escapeHTML(map.getUrl(marker)) + "\">" +
|
||||
escapeHTML(I18n.t("javascripts.share.view_larger_map")) + "</a></small>");
|
||||
escapeHTML(OSM.i18n.t("javascripts.share.view_larger_map")) + "</a></small>");
|
||||
|
||||
// Geo URI
|
||||
|
||||
|
@ -12,7 +12,7 @@ L.OSM.sidebarPane = function (options, uiClass, buttonTitle, paneTitle) {
|
||||
.on("click", toggle);
|
||||
|
||||
if (buttonTitle) {
|
||||
button.attr("title", I18n.t(buttonTitle));
|
||||
button.attr("title", OSM.i18n.t(buttonTitle));
|
||||
}
|
||||
|
||||
button.appendTo($container);
|
||||
@ -21,7 +21,7 @@ L.OSM.sidebarPane = function (options, uiClass, buttonTitle, paneTitle) {
|
||||
.attr("class", `${uiClass}-ui position-relative z-n1`);
|
||||
|
||||
$("<h2 class='p-3 pb-0 pe-5 text-break'>")
|
||||
.text(I18n.t(paneTitle))
|
||||
.text(OSM.i18n.t(paneTitle))
|
||||
.appendTo($ui);
|
||||
|
||||
options.sidebar.addPane($ui);
|
||||
|
@ -10,9 +10,9 @@ L.OSM.Zoom = L.Control.extend({
|
||||
this._map = map;
|
||||
|
||||
this._zoomInButton = this._createButton(
|
||||
"", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
|
||||
"", OSM.i18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
|
||||
this._zoomOutButton = this._createButton(
|
||||
"", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
|
||||
"", OSM.i18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
|
||||
|
||||
map.on("zoomend zoomlevelschange", this._updateDisabled, this);
|
||||
|
||||
|
@ -26,9 +26,9 @@ $(function () {
|
||||
icon: "icon geolocate",
|
||||
iconLoading: "icon geolocate",
|
||||
strings: {
|
||||
title: I18n.t("javascripts.map.locate.title"),
|
||||
title: OSM.i18n.t("javascripts.map.locate.title"),
|
||||
popup: function (options) {
|
||||
return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
|
||||
return OSM.i18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
|
||||
}
|
||||
}
|
||||
}).addTo(map);
|
||||
@ -210,7 +210,7 @@ $(function () {
|
||||
});
|
||||
|
||||
$("input[name=legale]").change(function () {
|
||||
$("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + I18n.t("browse.start_rjs.loading") + "</span></div>");
|
||||
$("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + OSM.i18n.t("browse.start_rjs.loading") + "</span></div>");
|
||||
fetch($(this).data("url"))
|
||||
.then(r => r.text())
|
||||
.then(html => { $("#contributorTerms").html(html); });
|
||||
|
Reference in New Issue
Block a user