Changeset 26956 in osm for applications/editors/josm
- Timestamp:
- 2011-10-24T01:20:34+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/tag2link
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tag2link/resources/tag2link_sources.xml
r26936 r26956 49 49 <source name="WHC"> 50 50 <rule> 51 <condition k="ref:whc" v=" \p{Digit}+" />51 <condition k="ref:whc" v="[0-9-]+" /> 52 52 <link name="View UNESCO sheet" href="http://whc.unesco.org/%lang(en,fr):en%/list/%v%" /> 53 53 </rule> -
applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkPlugin.java
r26936 r26956 28 28 * Main class of tag2link plugin. 29 29 * @author Don-vip 30 * @version 0.2a31 30 * History: 31 * 0.2b 24-Oct-2011 UNESCO WHC rule working 32 32 * 0.2a 23-Oct-2011 add Mail support + initial work on UNESCO WHC 33 33 * 0.1c 23-Oct-2011 add MHS rule (French heritage) -
applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java
r26936 r26956 20 20 import java.util.ArrayList; 21 21 import java.util.Collection; 22 import java.util.Locale; 22 23 import java.util.regex.Matcher; 23 24 import java.util.regex.Pattern; 24 25 26 import org.openstreetmap.josm.Main; 25 27 import org.openstreetmap.josm.data.osm.IPrimitive; 26 28 import org.openstreetmap.josm.data.osm.Tag; … … 63 65 while (m.find()) { 64 66 String arg = m.group(1); 67 68 // Search for a standard value 65 69 String val = findValue(arg, eval.matchingTags); 70 71 // No standard value found: test lang() function 72 if (val == null) { 73 Matcher lm = Pattern.compile(".*lang(?:\\((\\p{Lower}{2,})(?:,(\\p{Lower}{2,}))*\\))?.*").matcher(arg); 74 if (lm.matches()) { 75 String josmLang = Main.pref.get("language"); 76 String jvmLang = (josmLang.isEmpty() ? Locale.getDefault().getLanguage() : josmLang).split("_")[0]; 77 if (lm.groupCount() == 0) { 78 val = jvmLang; 79 } else { 80 for (int i = 1; i<=lm.groupCount() && val == null; i++) { 81 if (jvmLang.equals(lm.group(i))) { 82 val = jvmLang; 83 } 84 } 85 } 86 } 87 } 88 89 // Find a default value if set after ":" 66 90 if (val == null && arg.contains(":")) { 67 91 String[] vars = arg.split(":"); … … 74 98 } 75 99 } 76 if (val == null) { 77 Matcher lm = Pattern.compile("lang(?:\\(\\p{Lower}{2,}(?:,\\p{Lower}{2,})*\\))?(?::(\\p{Lower}{2,}))?").matcher(arg); 78 if (lm.matches()) { 79 if (lm.groupCount() == 0) { 80 // TODO: get JOSM current language 81 } else { 82 // TODO: parse next groups 83 } 84 } 85 } 100 101 // Has a value been found ? 86 102 if (val != null) { 87 103 try { … … 95 111 } 96 112 // Finally replace parameter 97 copy.url = copy.url.replaceFirst( m.group(), val);113 copy.url = copy.url.replaceFirst(Pattern.quote(m.group()), val); 98 114 } catch (UnsupportedEncodingException e) { 99 115 e.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.