Merge pull request #11502 from osmandapp/Fix_11423

Fix #11423 Wikipedia labels on the map shown on few languages
This commit is contained in:
Vitaliy 2021-04-22 18:50:59 +03:00 committed by GitHub
commit e6be5dcab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -357,19 +357,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) { if (o instanceof Amenity) {
Amenity amenity = (Amenity) o; return new PointDescription(PointDescription.POINT_TYPE_POI, getAmenityName((Amenity) o));
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
boolean transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
if (amenity.getType().isWiki()) {
if (Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
preferredLang = OsmandPlugin.onGetMapObjectsLocale(amenity, preferredLang);
}
return new PointDescription(PointDescription.POINT_TYPE_POI,
amenity.getName(preferredLang, transliterateNames));
} }
return null; return null;
} }
@ -431,8 +419,20 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override @Override
public String getText(Amenity o) { public String getText(Amenity o) {
return o.getName(view.getSettings().MAP_PREFERRED_LOCALE.get(), return getAmenityName(o);
view.getSettings().MAP_TRANSLITERATE_NAMES.get()); }
private String getAmenityName(Amenity amenity) {
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (amenity.getType().isWiki()) {
if (Algorithms.isEmpty(locale)) {
locale = app.getLanguage();
}
locale = OsmandPlugin.onGetMapObjectsLocale(amenity, locale);
}
return amenity.getName(locale, app.getSettings().MAP_TRANSLITERATE_NAMES.get());
} }
@Override @Override