Update getaddr.app.js

Dynamically get device language
master
gellnerm 2025-02-28 11:11:51 +01:00 committed by GitHub
parent 49f7f507b3
commit 3c9e3aca20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,6 @@
// Set the API endpoint and parameters
const nominatimApi = 'https://nominatim.openstreetmap.org';
const lang = require("locale").name.substring(0, 2);
const params = {
format: 'json',
addressdetails: 1,
@ -94,7 +95,7 @@ function getCurrentLocation() {
function getStreetAndHouseNumber(lat, lon) {
const url = `${nominatimApi}/reverse`;
const paramsStr = Object.keys(params).map(key => `${key}=${encodeURIComponent(params[key])}`).join('&');
const fullUrl = `${url}?${paramsStr}&lat=${lat}&lon=${lon}&accept-language=de&format=json`;
const fullUrl = `${url}?${paramsStr}&lat=${lat}&lon=${lon}&accept-language=${lang}&format=json`;
Bangle.http(fullUrl).then(data => {
try {