Add translations to search

This commit is contained in:
Victor Shcherb 2015-05-21 15:04:50 +03:00
parent a4fa5be8f6
commit 6dfc7041b5
2 changed files with 13 additions and 5 deletions

View file

@ -126,7 +126,7 @@ public class MapPoiTypes {
return null; return null;
} }
public Map<String, PoiType> getAllTranslatedNames() { public Map<String, PoiType> getAllTranslatedNames(boolean onlyTranslation) {
Map<String, PoiType> translation = new TreeMap<String, PoiType>(); Map<String, PoiType> translation = new TreeMap<String, PoiType>();
for(PoiCategory pc : categories) { for(PoiCategory pc : categories) {
for(PoiType pt : pc.getPoiTypes()) { for(PoiType pt : pc.getPoiTypes()) {
@ -134,6 +134,12 @@ public class MapPoiTypes {
continue; continue;
} }
translation.put(pt.getTranslation(), pt); translation.put(pt.getTranslation(), pt);
if(!onlyTranslation) {
String kn = pt.getKeyName().replace('_', ' ');
if(!pt.getTranslation().toLowerCase().contains(kn)) {
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt);
}
}
} }
} }
return translation; return translation;
@ -169,8 +175,10 @@ public class MapPoiTypes {
for (PoiType pt : pc.getPoiTypes()) { for (PoiType pt : pc.getPoiTypes()) {
translation.put(pt.getTranslation(), pt); translation.put(pt.getTranslation(), pt);
if (!onlyTranslation) { if (!onlyTranslation) {
// translation.put(pt.getKeyName(), pt); String kn = pt.getKeyName().replace('_', ' ');
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(pt.getKeyName().replace('_', ' ')), pt); if(!pt.getTranslation().toLowerCase().contains(kn)) {
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt);
}
} }
} }
return translation; return translation;

View file

@ -108,7 +108,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
private void prepareProvider() { private void prepareProvider() {
poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes(); poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes();
allTranslatedSubTypes = poiTypes.getAllTranslatedNames(); allTranslatedSubTypes = poiTypes.getAllTranslatedNames(false);
settings = ((OsmandApplication) activity.getApplication()).getSettings(); settings = ((OsmandApplication) activity.getApplication()).getSettings();
isLocalEdit = true; isLocalEdit = true;
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
@ -610,7 +610,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
private Map<String, PoiType> getSubCategoriesMap(PoiCategory poiCategory) { private Map<String, PoiType> getSubCategoriesMap(PoiCategory poiCategory) {
Map<String, PoiType> subCategories = new LinkedHashMap<>(poiTypes.getAllTranslatedNames(poiCategory, false)); Map<String, PoiType> subCategories = new LinkedHashMap<>(poiTypes.getAllTranslatedNames(poiCategory, false));
for (Map.Entry<String, PoiType> s : poiTypes.getAllTranslatedNames().entrySet()) { for (Map.Entry<String, PoiType> s : allTranslatedSubTypes.entrySet()) {
if (!subCategories.containsKey(s.getKey())) { if (!subCategories.containsKey(s.getKey())) {
subCategories.put(s.getKey(), s.getValue()); subCategories.put(s.getKey(), s.getValue());
} }