From a607571eed6fbd2e03296816318cab5f9beab6a2 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:04:30 +0100 Subject: [PATCH 01/14] Create app.js Initial commit, v0.1 --- apps/getaddr/app.js | 148 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 apps/getaddr/app.js diff --git a/apps/getaddr/app.js b/apps/getaddr/app.js new file mode 100644 index 0000000000..70365f44d4 --- /dev/null +++ b/apps/getaddr/app.js @@ -0,0 +1,148 @@ +// Set the API endpoint and parameters +const nominatimApi = 'https://nominatim.openstreetmap.org'; +const params = { + format: 'json', + addressdetails: 1, + zoom: 18, + extratags: 1 +}; + +// Function to break a string into lines +function breakStringIntoLines(str, maxWidth) { + const words = str.split(' '); + const lines = []; + let currentLine = ''; + for (const word of words) { + if (currentLine.length + word.length + 1 > maxWidth) { + lines.push(currentLine); + currentLine = word; + } else { + if (currentLine!== '') { + currentLine +=' '; + } + currentLine += word; + } + } + lines.push(currentLine); + return lines; +} + +// Function to clear the screen and display a message +function showMessage(address, error, dir) { + g.clear(); + g.reset(); + g.setFontVector(16); + const addressLines = breakStringIntoLines(address, 20); + let y = 20; + for (const line of addressLines) { + g.drawString(line, 10, y); + y += 20; + } + if (error) { + y += 10; + const errorLines = breakStringIntoLines(error, 20); + for (const line of errorLines) { + g.drawString(line, 10, y); + y += 20; + } + } + g.drawString(`Direction: ${dir}`, 10, 150); + g.flip(); +} + +// Function to get the compass direction +function getCompassDirection() { + const compass = Bangle.getCompass(); + if (compass && compass.heading) { + const direction = Math.floor(compass.heading); + const directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']; + const index = Math.floor(((direction % 360) + 22.5) / 45) % 8; + if (index >= 0 && index < directions.length) { + return directions[index]; + } else { + return 'Invalid index'; + } + } else { + return 'No compass data'; + } +} + +// Variable to store the current address and error +let currentAddress = 'Getting address...'; +let currentError = ''; +let lastUpdateTime = 0; + +// Function to get the current location +function getCurrentLocation() { + Bangle.setGPSPower(1); + Bangle.setCompassPower(1); + Bangle.on('GPS', (gps) => { + if (gps.fix) { + const now = Date.now(); + if (now - lastUpdateTime < 30000) return; + lastUpdateTime = now; + getStreetAndHouseNumber(gps.lat, gps.lon); + } else { + currentAddress = 'No GPS signal'; + currentError = `Sats: ${gps.satellites}`; + showMessage(currentAddress, currentError, getCompassDirection()); + } + }); +} + +// Function to get the street and house number +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`; + + Bangle.http(fullUrl).then(data => { + try { + const jsonData = JSON.parse(data.resp); + if (jsonData && jsonData.address) { + let street = jsonData.address.road; + if (street.includes('Straße')) { + street = street.replace('Straße', 'Str.'); + } else if (street.includes('Street')) { + street = street.replace('Street', 'St.'); + } + const houseNumber = jsonData.address.house_number; + const newAddress = `${street} ${houseNumber}`; + if (newAddress!== currentAddress) { + currentAddress = newAddress; + currentError = ''; + } + } else { + const newAddress = 'No address'; + if (newAddress!== currentAddress) { + currentAddress = newAddress; + currentError = ''; + } + } + } catch (err) { + const newError = `Error: ${err}`; + if (newError!== currentError) { + currentError = newError; + } + } + showMessage(currentAddress, currentError, getCompassDirection()); + }).catch(err => { + const newError = `Error: ${err}`; + if (newError!== currentError) { + currentError = newError; + } + showMessage(currentAddress, currentError, getCompassDirection()); + }); +} + +// Main function +function main() { + showMessage('Getting address...', '', getCompassDirection()); + getCurrentLocation(); + setInterval(() => { + showMessage(currentAddress, currentError, getCompassDirection()); + }, 1000); +} + +// Call the main function +main(); From f7206258a3ac11e709680cfed87d71b8a513576c Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:12:34 +0100 Subject: [PATCH 02/14] Create app-icon.js add app image --- apps/getaddr/app-icon.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/getaddr/app-icon.js diff --git a/apps/getaddr/app-icon.js b/apps/getaddr/app-icon.js new file mode 100644 index 0000000000..b2f820e485 --- /dev/null +++ b/apps/getaddr/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwwYcZhMkyVACBkSpIRBpMgCBUEBwIRCkmACBEBBwYCDIhYRFJRAOFAQVICA0CCJFJNBYCFNwwOHCJpBCCgiMJQY6SECIeQBAYRMBBosVMRAR/CMR9NUKLFVdJpQDyVIAwIFCMRQCICIsSCJMgCK8CCJIQFCKRlFOIwAFhIRHoARZVoi5GAAwRGbogRXdgjmHbRYQKZArCGCK7IECBbIEYRC2IWBC2ICBqkCTxSkGTxYAOA")) From c0212541ab40ac4beab068e3100e1a0749f5f3c5 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 17:40:55 +0100 Subject: [PATCH 03/14] Rename app.js to getaddr.app.js --- apps/getaddr/{app.js => getaddr.app.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/getaddr/{app.js => getaddr.app.js} (100%) diff --git a/apps/getaddr/app.js b/apps/getaddr/getaddr.app.js similarity index 100% rename from apps/getaddr/app.js rename to apps/getaddr/getaddr.app.js From c514218cc07484a83e76ff543b03dbe7d43a9ab5 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 17:46:17 +0100 Subject: [PATCH 04/14] Add files via upload --- apps/getaddr/image1.png | Bin 0 -> 2362 bytes apps/getaddr/image2.png | Bin 0 -> 2126 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/getaddr/image1.png create mode 100644 apps/getaddr/image2.png diff --git a/apps/getaddr/image1.png b/apps/getaddr/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..a0bbf50efbb11878682a2a13a8b82317d30c2c96 GIT binary patch literal 2362 zcmeH}c~sJg7RTu)^>7$XQ)z5CS+4UmN+lb$uyRl|w8mXQIZsC=MMx7BO)ZMaTn2M{ z%$Pck+f)WP7^0cNE039?C?YCuOwG8Zxo;&ny#L>yGw+Xg-XC}Q{PjKee$Tn*W`BJd zqw~p;Pe34$j;9COS5q7Q9gqW>%oY4b(3E|Nz8F^!rw={{0zuY2(HH$`gvIj3e^xtw zy8rCbUjJwjswkwCj|ltbrGspD0b<7LesMoPwQXu?>)_t8hA-%cfm1jqshR}>%w9;r zdbGLKf^)!I(O=g}0U?1aLkp+$Rh`_;@&VPkpq}#qHR!J&WsV9h?q2ye67H(h=~kF# zRCR=eAPZ~b5a6iJ%h2a0=aIB)Z-U^%)+1IX=IWhMWa;9C=yb5U5oh1P2@VdbNbIS3 z$}jCbfmENSlj@W3_f?rKLvu|a(uA#npMj|s=|)^k>wsc!xKonn7ZKQM%6yK4>pS}8 z272Z8aGlrH4W9nXc_N1&Hg88;7G-BY3rWtq%6;oMY5tSW-{nFfJH+GwJh4zzF|h+cfw$|pkrCD#oh#MiY&Y8L1W}zT2OQkVz15MGos;QHJqN z>wW(j9nIt4-9hj>swJ-J%+FJUOxkQte@JhHc5Vx`snF1mBNeMFt)&mE!F}yfPV?zq zNiOu08WX$=!s|o>L&p;>9EI>QAB$tq(D~Rl`!Ynl4wE9_V)=~Dz9=n0e;F%Y-t;+B(uh>rasKCTLtb+UptU@9T{ABqoc{9$jVLyu7iXY z2JiF@-qYQ6lco(u+PVmB(o=#^aC%bAWs)sV2w&$B`#bYPD@dNl3IK90O_0xtWy^MHlcWxk?#|L%2}zS?z9Uh^_3x0jAs@NwBOF-0~R5z8Ahdsoz|j%pT-}Io{_L z*6Sx~#DJ48Q!JnB+D<`jHi#^i`JACN-xVqy8}w7_r7y1&vcR0A@5}(A`BX~3D)X5@ ziwJuQ8KC8zxf~v%ls+12i>A))wNIw8xEubJo3vAhex^>!?bvJ&|0;2B_~`@OyYn~yHr`u&T$Mqk#{{UzoVDkU~ literal 0 HcmV?d00001 diff --git a/apps/getaddr/image2.png b/apps/getaddr/image2.png new file mode 100644 index 0000000000000000000000000000000000000000..112fb8c5af1b9fc9278595e117387bfc07336d04 GIT binary patch literal 2126 zcmeH}Ygm#86vy!m+pEoHQqJ4F+Y-?=bWLWaB7zRWH1ozlmZ2$`*Syp+Ut3!`Z>84M zrAwlRr3j(~)zDWfF|T1tr4w024wbYuowJ2wANPIVwh!n0pL0H(^F06G`EW}1QAuW| zHl_#!!YnM55NS~1-vMqkWP#)v!yrc4kt95#ZNyHCK!9KvAt)-Jq5Doz!P#k!{CIs` zfnyz0I5p|CJsT(Yy_QnGr|-84CNLI%fBojR1JcrM39kQh81**AIqM#2A;xWNb`K{$`*SllbHg5Kjyp!D`8)uj}ek_^W>K#rd@130{CEhPp`|) z&6vFi=;Bd_pSM`ObzyrEOqNtGfn^*1F}5G*W(Z~=rOHT`)(|v%YhBkhU?;ARR*kL? zuDPhv{Oie;x>|XoBKw#_3dD}IGj4IyKhnLwOEF(H?lrzge6;E{-dtMka}_80*jShEnT@<3O@)Rh&&( z(tc#>aIs=IsZ*ABgcW(Oza6jhf(D-x@W~f9$jD5#d-aVH55Z<}Locs@kGd-HO3$1t ziAj_s2PpERr}tno7O_^-hmO5FTQ1LygKD{h{U*`2r*Py#@88-ilE+)o+VKXdiqk?t zIe&XDO3~_|>;9>cF6#8s)LBb&xwyz*G1c4V@>@43g{BECNlR&I0kKeExwt)eS-pXTuJQBB~ASH!rj8>^&xc?E<6zB{ohkIeVU4O`a#Qo9g9W6c5n%UlCm1v$0Yh*F-Km;_fLKvm zKd}g8%G;{K42OY5o4#k_C`^p$cSQvfu3!J#sKX(HnSa#7YAXDV6tpi3!_Pi5t!p3c<>r#J@z;dX%U{O;xc*R)NcTHyBrWa9M5BLlwFA?N6I2;zoyA;k0RZo`R=fN{h zBVQza1HZbP`Iv(duI)%&u{hXQS;Tuxug7n`RD=;`Wh?9byVqkHeRd@HE)@L9U5Jqr zxtpLG_@ffqy!@9iy!$QZyx;1;xgl0q4(57Ou%qV^uHDxZ=>veRnau+=2%urtSFtum zNTqKC>r(`@*ESeajsV!-@vv@1@YQms3q%C;5jCpLfaF1+IoYKMwt4>=#o&HQ;#uyN zKxR4Wz*Pg1&JXX5fsVqy67+rmJThr@FvWo6DWTTg2)Qfm?e_oI{g=$FGA@)cCY*kp zSzOnz^Z99hr-SELV`kBE23A)3(Apn2XLTDmRa~nUSh9>EZ&Yu@aQE%P2S7S&dRI@% zigXQGdWWaUW?7eO=5)cpsb0V0ga~y@NbK_JZ6MuEKhnz$6c4i4ebLmjjJ=Doim_&i z-Q=$PoO{m-i}|jvSU}~#m<8G+BPYw9J>ich%IRUv9vzM74E9$qhM&+BC%jLjrP&YH z4Crg>WoCpYvS<2}FDxK-JI$LOu2wE_xV??2FkBFE@-pTUaply*(aoDa+b~lvJ|2#4 z^vckob7Hhf73@&8vh_n}p>qN5^o4n?%v+d+9WgJLAAYr!y6H2&oLs&&eXV=y#LTbD zji#OUiy=?OE2dsk(%mh@p*L`4D?KYsO`k)xg7e;a+JX3eKWL||u2ZF|>T@a^U+*q{ z4)+cSl*JP3%e5GtV! H&n*56hZnLe literal 0 HcmV?d00001 From 54f347e8e0146a9ed7a3ec58a43ef655c6c9548b Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:06:31 +0100 Subject: [PATCH 05/14] Create README.md --- apps/getaddr/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 apps/getaddr/README.md diff --git a/apps/getaddr/README.md b/apps/getaddr/README.md new file mode 100644 index 0000000000..3e6b490ee4 --- /dev/null +++ b/apps/getaddr/README.md @@ -0,0 +1,24 @@ +# GPS Compass App +This app uses the GPS and compass capabilities of the Bangle.js 2 watch to display your current location and direction. + +The app uses the Nominatim API to reverse geocode your location and display the street and house number. It also uses the compass to display your current direction. + +## Screenshots +![](image1.png) +![](image2.png) + +## Requirements +To run this app, you will need to meet the following requirements: + +1. Android Integration app or iOS integration app must be installed. +2. In Bangle.js Gadgetbridge connect the watch, then navigate to the **Gear icon** and enable "Use GPS data from phone". +3. In the same settings dialog scroll down and enable "Allow internet access". +4. Under **System** > **Settings** > **General Settings**, press "Get location" once and wait until it finds a location +5. In the same settings dialog enable "Keep location up to date". +7. The watch must have a clear view of the sky to receive GPS signals. +8. The compass must be calibrated by moving the watch in a figure-eight motion. + +Note: This app requires an active internet connection to function. It uses the Nominatim API to reverse geocode your location, and it may not work in areas with limited or no internet connectivity. + + +by [Online Speech to Text Cloud](https://www.speech-to-text.cloud/) From 279e364ca544d319e6a67b7bfe2cdf2a75bad5ad Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:08:10 +0100 Subject: [PATCH 06/14] Update README.md --- apps/getaddr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/getaddr/README.md b/apps/getaddr/README.md index 3e6b490ee4..a80486da44 100644 --- a/apps/getaddr/README.md +++ b/apps/getaddr/README.md @@ -1,4 +1,4 @@ -# GPS Compass App +# Get Address App This app uses the GPS and compass capabilities of the Bangle.js 2 watch to display your current location and direction. The app uses the Nominatim API to reverse geocode your location and display the street and house number. It also uses the compass to display your current direction. From c127560a2db571b9a61cf0311942133007473761 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:13:40 +0100 Subject: [PATCH 07/14] Create metadata.json --- apps/getaddr/metadata.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 apps/getaddr/metadata.json diff --git a/apps/getaddr/metadata.json b/apps/getaddr/metadata.json new file mode 100644 index 0000000000..efce94d7f3 --- /dev/null +++ b/apps/getaddr/metadata.json @@ -0,0 +1,17 @@ +{ + "id": "getaddr", + "name": "Get Current Address", + "version": "0.01", + "description": "An app that shows the address of the current location", + "readme": "README.md", + "icon": "getaddr.png", + "screenshots": [{"url":"image1.png"}, {"url":"image2.png"}], + "type": "app", + "tags": "gps,outdoors,tools", + "supports": ["BANGLEJS2"], + "dependencies" : {}, + "storage": [ + {"name":"getaddr.app.js","url":"getaddr.app.js"}, + {"name":"getaddr.img","url":"app-icon.js","evaluate":true} + ] + } From 65c6430ca2abbb5444be76c5d15f9a6ddb2f1e57 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:17:00 +0100 Subject: [PATCH 08/14] Rename app-icon.js to getaddr-icon.js --- apps/getaddr/{app-icon.js => getaddr-icon.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/getaddr/{app-icon.js => getaddr-icon.js} (100%) diff --git a/apps/getaddr/app-icon.js b/apps/getaddr/getaddr-icon.js similarity index 100% rename from apps/getaddr/app-icon.js rename to apps/getaddr/getaddr-icon.js From a3338ea419829943a7cd91a76ff56aabcb1898fe Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:17:37 +0100 Subject: [PATCH 09/14] Update metadata.json --- apps/getaddr/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/getaddr/metadata.json b/apps/getaddr/metadata.json index efce94d7f3..24a369e859 100644 --- a/apps/getaddr/metadata.json +++ b/apps/getaddr/metadata.json @@ -12,6 +12,6 @@ "dependencies" : {}, "storage": [ {"name":"getaddr.app.js","url":"getaddr.app.js"}, - {"name":"getaddr.img","url":"app-icon.js","evaluate":true} + {"name":"getaddr.img","url":"getaddr-icon.js","evaluate":true} ] } From f64a2aad06dcef56244bd80768bc9b8c0a1062db Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:18:34 +0100 Subject: [PATCH 10/14] Add files via upload --- apps/getaddr/getaddr.png | Bin 0 -> 871 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/getaddr/getaddr.png diff --git a/apps/getaddr/getaddr.png b/apps/getaddr/getaddr.png new file mode 100644 index 0000000000000000000000000000000000000000..6dc5cc94d824c4bb94bcbd3f02ce64ac7473eba7 GIT binary patch literal 871 zcmV-t1DO1YP)3jO+nL1(`Jo)b3sDoE}Oxs0Pub zX(WlF)FdYjf@t2Lh#(MYUNmVEg%puUlT;c-L1j_&R!YVG*yrAEVrhGy*F8cD7F;fu zfB)Y)>n!%!=K}wu5LB$CpoNMa3La7Lj)Dm)#;JHqMLz}IR2*Xt)yPUv&`iZ$DkiC* zWt!jKrl7IB#sz&2rvILT2dRRv5i2OT7TNfpAl=NNDp~U$Hc{{-cJo@wA^O;ul=*EG zyh+eJi&tWp9=615K8I=wULGDQG1ye@49{SU^P^6=Mz% z7s8p(p^Azx*5*Czb|}mqYY4$7a~0hI6o(zEbRvX)yMz8AcL2d<>z<#bZT`_tgO&i7 z!T{Lqa|9jE;=k88X$f%OUA(XbwgIRK4dA2Ja*fyS;^xM*5%*CU8Xy-83acUEE^cP9 zjd+9|B%2lI`^(+XPTd)8o)GeEGA;)+9+%-*Jbwss2I zrcilX^E5kxQ09x3s&@eRm4m^}X(o)1%3{`1aLS?QIVI~t0|XF?dm$E$Ck4Hc%m)A- z4weldj{}hb0tj>Xlz#R52+WHIK;fkh;MqSQ*+B?yqzG_5R`XLH@JCWGKT5^=*Z~3v zMOO;Fe>xHK0f3K+gm376bC8x8KmZ}wV0~KQR{0SMHYaL+3Pei+0LN1?UxHBFj1k~g zY%|{)pdKrOqwwgJA2wR4nlC|k*y(soI6cSdLCa#k1W`Ea3|swHWFe@y8UmmPSqU~^ zspCtKe)?E~ECm&-sCaH+{$*^hkKzt}002ovPDHLkV1ij*eWm~a literal 0 HcmV?d00001 From 7a0efec0ae4063dccb3944bf5442d45b770c70e5 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:31:18 +0100 Subject: [PATCH 11/14] Update metadata.json --- apps/getaddr/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/getaddr/metadata.json b/apps/getaddr/metadata.json index 24a369e859..f176a83d1f 100644 --- a/apps/getaddr/metadata.json +++ b/apps/getaddr/metadata.json @@ -1,6 +1,6 @@ { "id": "getaddr", - "name": "Get Current Address", + "name": "Get Addr", "version": "0.01", "description": "An app that shows the address of the current location", "readme": "README.md", From 49f7f507b3d820360e49cf76fb6c698d7128a585 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:33:55 +0100 Subject: [PATCH 12/14] Create ChangeLog --- apps/getaddr/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/getaddr/ChangeLog diff --git a/apps/getaddr/ChangeLog b/apps/getaddr/ChangeLog new file mode 100644 index 0000000000..af7f83942b --- /dev/null +++ b/apps/getaddr/ChangeLog @@ -0,0 +1 @@ +0.01: Initial release From 3c9e3aca2000336b761a9de8a2a73be11b439f1e Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:11:51 +0100 Subject: [PATCH 13/14] Update getaddr.app.js Dynamically get device language --- apps/getaddr/getaddr.app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/getaddr/getaddr.app.js b/apps/getaddr/getaddr.app.js index 70365f44d4..6901295711 100644 --- a/apps/getaddr/getaddr.app.js +++ b/apps/getaddr/getaddr.app.js @@ -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 { From 1fdebeae99ff93cd4bfda6f17d64d513238ca659 Mon Sep 17 00:00:00 2001 From: gellnerm <47713613+gellnerm@users.noreply.github.com> Date: Fri, 28 Feb 2025 14:42:19 +0100 Subject: [PATCH 14/14] Update getaddr.app.js Add fallback for "system" language --- apps/getaddr/getaddr.app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/getaddr/getaddr.app.js b/apps/getaddr/getaddr.app.js index 6901295711..93215c4910 100644 --- a/apps/getaddr/getaddr.app.js +++ b/apps/getaddr/getaddr.app.js @@ -1,6 +1,14 @@ // Set the API endpoint and parameters const nominatimApi = 'https://nominatim.openstreetmap.org'; -const lang = require("locale").name.substring(0, 2); +const locale = require('locale'); +let lang = locale.name; + +if (lang.toLowerCase() === 'system') { + lang = 'en'; +} else { + lang = lang.substring(0, 2); +} + const params = { format: 'json', addressdetails: 1,