Compare commits
6 Commits
feature/lo
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 20f63065ad | |||
| 39a7ec3595 | |||
| 32dfa3a30f | |||
| 64ccc694d3 | |||
| 87e2380ef6 | |||
| 66c31b19f1 |
@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
||||
import { fn } from '@ember/helper';
|
||||
import { on } from '@ember/modifier';
|
||||
import { humanizeOsmTag } from '../utils/format-text';
|
||||
import { getLocalizedName } from '../utils/osm';
|
||||
import Icon from '../components/icon';
|
||||
import PlaceEditForm from './place-edit-form';
|
||||
|
||||
@ -22,8 +23,7 @@ export default class PlaceDetails extends Component {
|
||||
get name() {
|
||||
return (
|
||||
this.place.title ||
|
||||
this.tags.name ||
|
||||
this.tags['name:en'] ||
|
||||
getLocalizedName(this.tags) ||
|
||||
'Unnamed Place'
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import or from 'ember-truth-helpers/helpers/or';
|
||||
import PlaceDetails from './place-details';
|
||||
import Icon from './icon';
|
||||
import humanizeOsmTag from '../helpers/humanize-osm-tag';
|
||||
import { getLocalizedName } from '../utils/osm';
|
||||
|
||||
export default class PlacesSidebar extends Component {
|
||||
@service storage;
|
||||
@ -85,8 +86,7 @@ export default class PlacesSidebar extends Component {
|
||||
} else {
|
||||
// It's a fresh POI -> Save it
|
||||
const placeData = {
|
||||
title:
|
||||
place.osmTags.name || place.osmTags['name:en'] || 'Untitled Place',
|
||||
title: getLocalizedName(place.osmTags, 'Untitled Place'),
|
||||
lat: place.lat,
|
||||
lon: place.lon,
|
||||
tags: [],
|
||||
|
||||
@ -46,7 +46,7 @@ export default class SettingsPane extends Component {
|
||||
</option>
|
||||
<option
|
||||
value="false"
|
||||
selected={{if (not this.settings.mapKinetic) "selected"}}
|
||||
selected={{unless this.settings.mapKinetic "selected"}}
|
||||
>
|
||||
Off
|
||||
</option>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import Service, { service } from '@ember/service';
|
||||
import { getLocalizedName } from '../utils/osm';
|
||||
|
||||
export default class OsmService extends Service {
|
||||
@service settings;
|
||||
@ -61,7 +62,7 @@ out center;
|
||||
|
||||
normalizePoi(poi) {
|
||||
return {
|
||||
title: poi.tags?.name || poi.tags?.['name:en'] || 'Untitled Place',
|
||||
title: getLocalizedName(poi.tags),
|
||||
lat: poi.lat || poi.center?.lat,
|
||||
lon: poi.lon || poi.center?.lon,
|
||||
url: poi.tags?.website,
|
||||
|
||||
32
app/utils/osm.js
Normal file
32
app/utils/osm.js
Normal file
@ -0,0 +1,32 @@
|
||||
export function getLocalizedName(tags, defaultName = 'Untitled Place') {
|
||||
if (!tags) return defaultName;
|
||||
|
||||
// 1. Get user's preferred languages
|
||||
const languages = navigator.languages || [navigator.language || 'en'];
|
||||
|
||||
// 2. Try to find a match for each preferred language
|
||||
for (const lang of languages) {
|
||||
if (!lang) continue;
|
||||
|
||||
// Handle "en-US", "de-DE", etc. -> look for "name:en", "name:de"
|
||||
const shortLang = lang.split('-')[0];
|
||||
const tagKey = `name:${shortLang}`;
|
||||
|
||||
if (tags[tagKey]) {
|
||||
return tags[tagKey];
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fallback to standard "name"
|
||||
if (tags.name) {
|
||||
return tags.name;
|
||||
}
|
||||
|
||||
// 4. Fallback to "name:en" (common in international places without local name)
|
||||
if (tags['name:en']) {
|
||||
return tags['name:en'];
|
||||
}
|
||||
|
||||
// 5. Final fallback
|
||||
return defaultName;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "marco",
|
||||
"version": "1.11.2",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"description": "Unhosted maps app",
|
||||
"repository": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
release/assets/main-G8wPYi_P.css
Normal file
1
release/assets/main-G8wPYi_P.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -26,8 +26,8 @@
|
||||
<meta name="msapplication-TileColor" content="#F6E9A6">
|
||||
<meta name="msapplication-TileImage" content="/icons/icon-144.png">
|
||||
|
||||
<script type="module" crossorigin src="/assets/main-CYFdUlXN.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D53xPL_H.css">
|
||||
<script type="module" crossorigin src="/assets/main-ji2SNMnp.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-G8wPYi_P.css">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
||||
@ -82,7 +82,7 @@ module('Acceptance | navigation', function (hooks) {
|
||||
|
||||
// Click the Close (X) button
|
||||
await click('.close-btn');
|
||||
await settled();
|
||||
|
||||
|
||||
assert.strictEqual(currentURL(), '/', 'Returned to index');
|
||||
assert.false(mapUi.returnToSearch, 'Flag is reset after closing sidebar');
|
||||
@ -95,7 +95,7 @@ module('Acceptance | navigation', function (hooks) {
|
||||
assert.ok(currentURL().includes('/place/'), 'Visited place directly');
|
||||
|
||||
await click('.back-btn');
|
||||
await settled();
|
||||
|
||||
|
||||
assert.strictEqual(currentURL(), '/', 'Returned to index/map');
|
||||
assert.true(backStub.notCalled, 'window.history.back() was NOT called');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user