Changeset 8680 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
- Timestamp:
- 2015-08-22T21:32:45+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r8540 r8680 25 25 import org.openstreetmap.josm.data.validation.TestError; 26 26 import org.openstreetmap.josm.io.CachedFile; 27 import org.openstreetmap.josm.tools.LanguageInfo; 27 28 28 29 /** … … 55 56 new CachedFile("resource://data/validator/opening_hours.js").getInputStream(), StandardCharsets.UTF_8)) { 56 57 ENGINE.eval(reader); 58 ENGINE.eval("var opening_hours = require('opening_hours');"); 57 59 // fake country/state to not get errors on holidays 58 60 ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};"); 59 61 ENGINE.eval( 60 "var oh = function (value, mode ) {" +62 "var oh = function (value, mode, locale) {" + 61 63 " try {" + 62 " var r = new opening_hours(value, nominatimJSON, mode);" +64 " var r = new opening_hours(value, nominatimJSON, {mode: mode, locale: locale});" + 63 65 " r.getErrors = function() {return [];};" + 64 66 " return r;" + … … 85 87 } 86 88 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); 89 91 } 90 92 … … 179 181 */ 180 182 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()); 182 184 } 183 185 … … 190 192 * @param mode whether to validate {@code value} as a time range, or points in time, or both. 191 193 * @param ignoreOtherSeverity whether to ignore errors with {@link Severity#OTHER}. 194 * @param locale the locale code used for localizing messages 192 195 * @return a list of {@link TestError} or an empty list 193 196 */ 194 197 public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value, CheckMode mode, 195 boolean ignoreOtherSeverity ) {198 boolean ignoreOtherSeverity, String locale) { 196 199 if (ENGINE == null || value == null || value.trim().isEmpty()) { 197 200 return Collections.emptyList(); … … 199 202 final List<OpeningHoursTestError> errors = new ArrayList<>(); 200 203 try { 201 final Object r = parse(value, mode );204 final Object r = parse(value, mode, locale); 202 205 String prettifiedValue = null; 203 206 try {
Note:
See TracChangeset
for help on using the changeset viewer.