Ignore:
Timestamp:
2015-06-01T18:04:14+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11498 - Warn about obvious misspelled tag values (modified patch by mdk) + i18n fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r8435 r8438  
    421421                        // try to fix common typos and check again if value is still unknown
    422422                        String fixedValue = prettifyValue(prop.getValue());
    423                         if (values != null && values.contains(fixedValue)) {
     423                        Map<String, String> possibleValues = getPossibleValues(values);
     424                        if (possibleValues.containsKey(fixedValue)) {
     425                            fixedValue = possibleValues.get(fixedValue);
    424426                            // misspelled preset value
    425                             String i = marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}}.");
     427                            String i = marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}''.");
    426428                            errors.add(new FixableTestError(this, Severity.WARNING, tr("Misspelled property value"),
    427429                                    tr(i, prop.getValue(), key, fixedValue), MessageFormat.format(i, prop.getValue(), fixedValue),
     
    449451            }
    450452        }
     453    }
     454
     455    private Map<String, String> getPossibleValues(Set<String> values) {
     456        // generate a map with common typos
     457        Map<String, String> map = new HashMap<>();
     458        if (values != null) {
     459            for (String value : values) {
     460                map.put(value, value);
     461                if (value.contains("_")) {
     462                    map.put(value.replace("_", ""), value);
     463                }
     464            }
     465        }
     466        return map;
    451467    }
    452468
Note: See TracChangeset for help on using the changeset viewer.