Ignore:
Timestamp:
2015-08-22T21:32:45+02:00 (9 years ago)
Author:
simon04
Message:

fix #11755 - Update version of opening_hours.js to 3.3.0

Location:
trunk/src/org/openstreetmap/josm/data/validation/tests
Files:
2 edited

Legend:

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

    r8540 r8680  
    1717import org.openstreetmap.josm.data.validation.Test;
    1818import org.openstreetmap.josm.data.validation.TestError;
     19import org.openstreetmap.josm.tools.LanguageInfo;
    1920import org.openstreetmap.josm.tools.Predicates;
    2021import org.openstreetmap.josm.tools.Utils;
     
    132133                    if (condition.matches(".*[0-9]:[0-9]{2}.*")) {
    133134                        final List<OpeningHourTest.OpeningHoursTestError> errors = openingHourTest.checkOpeningHourSyntax(
    134                                 "", condition, OpeningHourTest.CheckMode.TIME_RANGE, true);
     135                                "", condition, OpeningHourTest.CheckMode.TIME_RANGE, true, LanguageInfo.getJOSMLocaleCode());
    135136                        if (!errors.isEmpty()) {
    136137                            return errors.get(0).getMessage();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r8540 r8680  
    2525import org.openstreetmap.josm.data.validation.TestError;
    2626import org.openstreetmap.josm.io.CachedFile;
     27import org.openstreetmap.josm.tools.LanguageInfo;
    2728
    2829/**
     
    5556                    new CachedFile("resource://data/validator/opening_hours.js").getInputStream(), StandardCharsets.UTF_8)) {
    5657                ENGINE.eval(reader);
     58                ENGINE.eval("var opening_hours = require('opening_hours');");
    5759                // fake country/state to not get errors on holidays
    5860                ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};");
    5961                ENGINE.eval(
    60                         "var oh = function (value, mode) {" +
     62                        "var oh = function (value, mode, locale) {" +
    6163                        " try {" +
    62                         "    var r= new opening_hours(value, nominatimJSON, mode);" +
     64                        "    var r = new opening_hours(value, nominatimJSON, {mode: mode, locale: locale});" +
    6365                        "    r.getErrors = function() {return [];};" +
    6466                        "    return r;" +
     
    8587    }
    8688
    87     protected Object parse(String value, CheckMode mode) throws ScriptException, NoSuchMethodException {
    88         return ((Invocable) ENGINE).invokeFunction("oh", value, mode.code);
     89    protected Object parse(String value, CheckMode mode, String locale) throws ScriptException, NoSuchMethodException {
     90        return ((Invocable) ENGINE).invokeFunction("oh", value, mode.code, locale);
    8991    }
    9092
     
    179181     */
    180182    public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value, CheckMode mode) {
    181         return checkOpeningHourSyntax(key, value, mode, false);
     183        return checkOpeningHourSyntax(key, value, mode, false, LanguageInfo.getJOSMLocaleCode());
    182184    }
    183185
     
    190192     * @param mode whether to validate {@code value} as a time range, or points in time, or both.
    191193     * @param ignoreOtherSeverity whether to ignore errors with {@link Severity#OTHER}.
     194     * @param locale the locale code used for localizing messages
    192195     * @return a list of {@link TestError} or an empty list
    193196     */
    194197    public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value, CheckMode mode,
    195             boolean ignoreOtherSeverity) {
     198            boolean ignoreOtherSeverity, String locale) {
    196199        if (ENGINE == null || value == null || value.trim().isEmpty()) {
    197200            return Collections.emptyList();
     
    199202        final List<OpeningHoursTestError> errors = new ArrayList<>();
    200203        try {
    201             final Object r = parse(value, mode);
     204            final Object r = parse(value, mode, locale);
    202205            String prettifiedValue = null;
    203206            try {
Note: See TracChangeset for help on using the changeset viewer.