added translations

This commit is contained in:
Joren de Graaf
2026-10-01 22:43:45 +02:00
parent b676f35f0a
commit 13258e76c3
76 changed files with 1787 additions and 291 deletions
+2 -1
View File
@@ -1 +1,2 @@
document.querySelectorAll('.audio-preview').forEach(function(box){var button=box.querySelector('.audio-play'),audio=box.querySelector('audio'),label=box.querySelector('.audio-play__label'),status=box.querySelector('.audio-status');button.addEventListener('click',function(){if(!audio.src){audio.src=button.dataset.audioUrl;button.classList.add('is-loading');status.textContent='Loading recording…';}if(audio.paused){audio.play().catch(function(){button.classList.remove('is-loading');status.textContent='Could not play this recording.';});}else{audio.pause();}});audio.addEventListener('playing',function(){button.classList.remove('is-loading');label.textContent='Pause recording';status.textContent='Playing now';});audio.addEventListener('pause',function(){if(!audio.ended){label.textContent='Resume recording';status.textContent='Paused';}});audio.addEventListener('ended',function(){label.textContent='Replay recording';status.textContent='Finished';});audio.addEventListener('waiting',function(){button.classList.add('is-loading');status.textContent='Buffering…';});audio.addEventListener('canplay',function(){button.classList.remove('is-loading');});audio.addEventListener('error',function(){button.classList.remove('is-loading');status.textContent='Could not load this recording.';});});
const t = window.BOOMCAST_I18N || {};
document.querySelectorAll('.audio-preview').forEach(function(box){var button=box.querySelector('.audio-play'),audio=box.querySelector('audio'),label=box.querySelector('.audio-play__label'),status=box.querySelector('.audio-status');button.addEventListener('click',function(){if(!audio.src){audio.src=button.dataset.audioUrl;button.classList.add('is-loading');status.textContent=(t.loadingRecording || 'Loading recording…');}if(audio.paused){audio.play().catch(function(){button.classList.remove('is-loading');status.textContent=(t.couldNotPlay || 'Could not play this recording.');});}else{audio.pause();}});audio.addEventListener('playing',function(){button.classList.remove('is-loading');label.textContent=(t.pauseRecording || 'Pause recording');status.textContent=(t.playingNow || 'Playing now');});audio.addEventListener('pause',function(){if(!audio.ended){label.textContent=(t.resumeRecording || 'Resume recording');status.textContent=(t.paused || 'Paused');}});audio.addEventListener('ended',function(){label.textContent=(t.replayRecording || 'Replay recording');status.textContent=(t.finished || 'Finished');});audio.addEventListener('waiting',function(){button.classList.add('is-loading');status.textContent=(t.buffering || 'Buffering…');});audio.addEventListener('canplay',function(){button.classList.remove('is-loading');});audio.addEventListener('error',function(){button.classList.remove('is-loading');status.textContent=(t.couldNotLoad || 'Could not load this recording.');});});
+4 -3
View File
@@ -1,18 +1,19 @@
const t = window.BOOMCAST_I18N || {};
const form = document.querySelector('.upload-form');
const dropZone = document.querySelector('#drop-zone');
const fileInput = document.querySelector('#audio-file');
const fileName = document.querySelector('#file-name');
const status = document.querySelector('#upload-status');
const showFile = (file) => { fileName.textContent = file ? file.name : 'No file selected'; };
const showFile = (file) => { fileName.textContent = file ? file.name : (t.noFile || 'No file selected'); };
fileInput.addEventListener('change', () => showFile(fileInput.files[0]));
['dragenter', 'dragover'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.add('dragging'); }));
['dragleave', 'drop'].forEach((eventName) => dropZone.addEventListener(eventName, (event) => { event.preventDefault(); dropZone.classList.remove('dragging'); }));
dropZone.addEventListener('drop', (event) => { const [file] = event.dataTransfer.files; if (!file) return; fileInput.files = event.dataTransfer.files; showFile(file); });
form.addEventListener('htmx:beforeRequest', () => { status.textContent = 'Analysing your recording…'; form.setAttribute('aria-busy', 'true'); });
form.addEventListener('htmx:beforeRequest', () => { status.textContent = (t.analysing || 'Analysing your recording…'); form.setAttribute('aria-busy', 'true'); });
form.addEventListener('htmx:afterRequest', () => { status.textContent = ''; form.removeAttribute('aria-busy'); });
form.addEventListener('htmx:responseError', () => { status.textContent = 'Analysis could not be completed.'; });
form.addEventListener('htmx:responseError', () => { status.textContent = (t.analysisFailed || 'Analysis could not be completed.'); });
document.body.addEventListener('htmx:beforeSwap', (event) => {
if (event.detail.xhr.status >= 400) {
event.detail.shouldSwap = true;
+9 -8
View File
@@ -1,3 +1,4 @@
const t = window.BOOMCAST_I18N || {};
const mapElement = document.getElementById("event-map");
const h3Resolution = mapElement.dataset.h3Resolution;
@@ -7,7 +8,7 @@
compassControl.onAdd = () => {
const compass = L.DomUtil.create("div", "map-compass");
compass.setAttribute("role", "img");
compass.setAttribute("aria-label", "Map compass: north is up");
compass.setAttribute("aria-label", (t.mapCompass || "Map compass: north is up"));
compass.innerHTML = "<span class=\"compass-n\">N</span><span class=\"compass-e\">E</span><span class=\"compass-s\">S</span><span class=\"compass-w\">W</span><span class=\"compass-needle\">↑</span>";
L.DomEvent.disableClickPropagation(compass);
return compass;
@@ -28,8 +29,8 @@
}).addTo(map);
polygon.bindPopup(
"<span class=\"popup-title\">H3 " + cell.cell + "</span>" +
"<span class=\"popup-meta\">" + cell.reports + " reports · " + cell.occurrences +
" occurrences · resolution " + h3Resolution + "</span>"
"<span class=\"popup-meta\">" + cell.reports + " " + (cell.reports === 1 ? (t.report || "report") : (t.reports || "reports")) + " · " + cell.occurrences +
" " + (cell.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) + " · " + (t.resolution || "resolution") + " " + h3Resolution + "</span>"
);
bounds.extend(L.latLngBounds(cell.boundary));
});
@@ -60,17 +61,17 @@
className: "", html: "<div class=\"report-icon\">✦</div>", iconSize: [37, 37], iconAnchor: [19, 19],
});
reports.forEach((report) => {
const visualStatus = report.visually_confirmed ? "Visually confirmed" : "Not visually confirmed";
let detail = report.occurrences + " occurrence" + (report.occurrences === 1 ? "" : "s") +
" · " + visualStatus + "<br>Reported " + report.reported_on;
const visualStatus = report.visually_confirmed ? (t.visuallyConfirmed || "Visually confirmed") : (t.notVisuallyConfirmed || "Not visually confirmed");
let detail = report.occurrences + " " + (report.occurrences === 1 ? (t.occurrence || "occurrence") : (t.occurrences || "occurrences")) +
" · " + visualStatus + "<br>" + (t.reported || "Reported") + " " + report.reported_on;
if (report.direction_degrees !== null) {
detail += "<br>Compass direction " + Math.round(report.direction_degrees) + "° (" + cardinalDirection(report.direction_degrees) + ")";
detail += "<br>" + (t.compassDirection || "Compass direction") + " " + Math.round(report.direction_degrees) + "° (" + cardinalDirection(report.direction_degrees) + ")";
if (report.direction_accuracy_degrees !== null) {
detail += " (±" + Math.round(report.direction_accuracy_degrees) + "°)";
}
}
L.marker(report.center, { icon: reportIcon }).addTo(map).bindPopup(
"<span class=\"popup-title\">Manual report · H3 " + report.cell + "</span>" +
"<span class=\"popup-title\">" + (t.manualReport || "Manual report") + " · H3 " + report.cell + "</span>" +
"<span class=\"popup-meta\">" + detail + "</span>"
);
+13 -12
View File
@@ -1,3 +1,4 @@
const t = window.BOOMCAST_I18N || {};
const manualForm = document.querySelector("#manual-report-form");
const manualSubmit = document.querySelector("#manual-submit");
@@ -27,14 +28,14 @@
};
const showCapturedDirection = (heading, accuracy) => {
const accuracyText = accuracy === null ? "Accuracy unavailable" : "Accuracy: ±" + displayDegrees(accuracy) + "°";
const accuracyText = accuracy === null ? (t.accuracyUnavailable || "Accuracy unavailable") : (t.accuracy || "Accuracy") + ": ±" + displayDegrees(accuracy) + "°";
directionStatus.innerHTML = "<strong>" + displayDegrees(heading) + "° · " + cardinalDirection(heading) + "</strong><br>" + accuracyText;
captureDirectionButton.textContent = "Stop direction capture";
captureDirectionButton.textContent = (t.stopCapture || "Stop direction capture");
};
const listenForCompassReading = () => {
stopCompassReading();
directionStatus.textContent = "Point the top of your phone toward the sound — direction will update live.";
directionStatus.textContent = (t.pointPhone || "Point the top of your phone toward the sound — direction will update live.");
orientationListener = (event) => {
const isWebKitCompass = "webkitCompassHeading" in event;
const heading = isUsableNumber(event.webkitCompassHeading)
@@ -55,34 +56,34 @@
window.addEventListener("deviceorientation", orientationListener);
compassUnavailableTimeout = window.setTimeout(() => {
stopCompassReading();
captureDirectionButton.textContent = "Capture direction";
directionStatus.textContent = "Compass unavailable on this device.";
captureDirectionButton.textContent = (t.captureDirection || "Capture direction");
directionStatus.textContent = (t.compassUnavailable || "Compass unavailable on this device.");
}, 15000);
};
const captureDirection = async () => {
if (orientationListener) {
stopCompassReading();
captureDirectionButton.textContent = "Capture again";
captureDirectionButton.textContent = (t.captureAgain || "Capture again");
return;
}
if (!window.isSecureContext) {
directionStatus.textContent = "Compass capture requires a secure HTTPS connection.";
directionStatus.textContent = (t.secureCompass || "Compass capture requires a secure HTTPS connection.");
return;
}
if (typeof window.DeviceOrientationEvent === "undefined") {
directionStatus.textContent = "Compass unavailable on this device.";
directionStatus.textContent = (t.compassUnavailable || "Compass unavailable on this device.");
return;
}
if (typeof DeviceOrientationEvent.requestPermission === "function") {
directionStatus.textContent = "Requesting compass permission…";
directionStatus.textContent = (t.compassPermission || "Requesting compass permission…");
try {
if (await DeviceOrientationEvent.requestPermission(true) !== "granted") {
directionStatus.textContent = "Compass permission denied.";
directionStatus.textContent = (t.compassDenied || "Compass permission denied.");
return;
}
} catch (error) {
directionStatus.textContent = "Compass permission denied.";
directionStatus.textContent = (t.compassDenied || "Compass permission denied.");
return;
}
}
@@ -109,7 +110,7 @@
submitManualReport();
return;
}
manualStatus.textContent = "Requesting your optional location…";
manualStatus.textContent = (t.requestingLocation || "Requesting your optional location…");
navigator.geolocation.getCurrentPosition(
(position) => {
latitude.value = position.coords.latitude;
+3 -2
View File
@@ -14,8 +14,9 @@ function applyTheme(theme, button) {
document.documentElement.dataset.theme = theme;
if (!button) return;
const nextTheme = theme === "dark" ? "light" : "dark";
button.textContent = nextTheme === "light" ? "☀ Light mode" : "☾ Dark mode";
button.setAttribute("aria-label", "Switch to " + nextTheme + " mode");
const t = window.BOOMCAST_I18N || {};
button.textContent = nextTheme === "light" ? "☀ " + (t.lightMode || "Light mode") : "☾ " + (t.darkMode || "Dark mode");
button.setAttribute("aria-label", nextTheme === "light" ? (t.switchToLight || "Switch to light mode") : (t.switchToDark || "Switch to dark mode"));
button.setAttribute("aria-pressed", String(theme === "light"));
}