Opened 6 years ago
Closed 6 years ago
#17173 closed enhancement (fixed)
[Patch] Detect preset wiki languages automatically
Reported by: | simon04 | Owned by: | simon04 |
---|---|---|---|
Priority: | normal | Milestone: | 19.01 |
Component: | Internal preset | Version: | |
Keywords: | Cc: | Don-vip, michael2402, stoecker, naoliv, Simon, Poole |
Description (last modified by )
Instead of maintaining various OSM wiki languages in defaultpresets.xml
, maintaining presets_lang.pl
, running presets_lang.pl
from time to time, still applying manual changes (cf. #17171), let JOSM detect the wiki language automatically. This features has been implemented long ago in HelpAction.displayHelp
: it opens https://wiki.openstreetmap.org/wiki/[lang]:[page]
if it exists and falls back to https://wiki.openstreetmap.org/wiki/[page]
.
So in a nutshell …
-
data/defaultpresets.xml
diff --git a/data/defaultpresets.xml b/data/defaultpresets.xml index b88f3d9d4..0ec763ca8 100644
a b 326 326 <reference ref="voltage_frequency" /> 327 327 </chunk> 328 328 <chunk id="power_generator"> 329 <link href="https://wiki.openstreetmap.org/wiki/Tag:power=generator" 330 cs.href="https://wiki.openstreetmap.org/wiki/Cs:Tag:power=generator" 331 de.href="https://wiki.openstreetmap.org/wiki/DE:Tag:power=generator" 332 es.href="https://wiki.openstreetmap.org/wiki/ES:Tag:power=generator" 333 fr.href="https://wiki.openstreetmap.org/wiki/FR:Tag:power=generator" 334 it.href="https://wiki.openstreetmap.org/wiki/IT:Tag:power=generator" 335 ja.href="https://wiki.openstreetmap.org/wiki/JA:Tag:power=generator" 336 pl.href="https://wiki.openstreetmap.org/wiki/Pl:Tag:power=generator" 337 pt.href="https://wiki.openstreetmap.org/wiki/Pt:Tag:power=generator" 338 ru.href="https://wiki.openstreetmap.org/wiki/RU:Tag:power=generator" /> 329 <link wiki="Tag:power=generator" /> 339 330 <space /> 340 331 <key key="power" value="generator" /> 341 332 <reference ref="name_ref_operator" />
In total: 719 insertions(+), 5651 deletions(-)
Relates to this discussion at josm-dev@: https://lists.openstreetmap.org/pipermail/josm-dev/2018-November/008171.html (Add templated version of wiki href to link element in presets)
Attachments (1)
Change History (30)
by , 6 years ago
Attachment: | 17173.patch.gz added |
---|
comment:1 by , 6 years ago
Cc: | added |
---|
comment:2 by , 6 years ago
follow-up: 4 comment:3 by , 6 years ago
For pt_BR
it will be necessary to consider the language as pt
, since pt_BR
was unified into pt
(ie, people using JOSM in pt
or pt_BR
should open the same Portuguese wiki pages).
With the patch (actually after [14617]), using pt_BR
only opens the English pages.
follow-ups: 5 6 comment:4 by , 6 years ago
Replying to stoecker:
It's not so easy. You overlooked all these cases where the links don't have the same name.
Please name one. I only stumbled over https://wiki.openstreetmap.org/wiki/Link_(highway vs. https://wiki.openstreetmap.org/wiki/Cs:Highway_link, but the former redirects to https://wiki.openstreetmap.org/wiki/Highway_link. IMO we could accept 0.1% non-detected language links in favour of simplicity / elegance / reduced code / reduced maintenance burden.
Replying to naoliv:
For
pt_BR
it will be necessary to consider the language aspt
, sincept_BR
was unified intopt
(ie, people using JOSM inpt
orpt_BR
should open the same Portuguese wiki pages).
With the patch (actually after [14617]), usingpt_BR
only opens the English pages.
Good to know… We should reflect the merge in LanguageInfo
. The merge has taken place on the OSM wiki, the JOSM wiki, the JOSM i18n?
comment:5 by , 6 years ago
Replying to simon04:
Good to know… We should reflect the merge in
LanguageInfo
. The merge has taken place on the OSM wiki, the JOSM wiki, the JOSM i18n?
Only OSM wiki was unified. The rest are still (and I guess will stay) different.
comment:6 by , 6 years ago
Replying to simon04:
Replying to stoecker:
It's not so easy. You overlooked all these cases where the links don't have the same name.
Please name one. I only stumbled over https://wiki.openstreetmap.org/wiki/Link_(highway vs. https://wiki.openstreetmap.org/wiki/Cs:Highway_link, but the former redirects to https://wiki.openstreetmap.org/wiki/Highway_link. IMO we could accept 0.1% non-detected language links in favour of simplicity / elegance / reduced code / reduced maintenance burden.
Hmm, seems the wiki situation changed. E.g. Link_(highway) or Highway_link actually has references to "Pt:Tag:highway=motorway_link", but this is missing totally now. Also the wiki does not refernce redirects in the language pages. Maybe they broke the wiki in that instance? That would mean that your approach would actually be better, as the links then work again.
Can you please extract the code changes and attach them separately for review?
Replying to naoliv:
For
pt_BR
it will be necessary to consider the language aspt
, sincept_BR
was unified intopt
(ie, people using JOSM inpt
orpt_BR
should open the same Portuguese wiki pages).
With the patch (actually after [14617]), usingpt_BR
only opens the English pages.
Good to know… We should reflect the merge in
LanguageInfo
. The merge has taken place on the OSM wiki, the JOSM wiki, the JOSM i18n?
JOSM wiki and JOSM i18n is not affected. That would only be the case, when pt_BR translation gets dropped. But we need to change JOSM code, that the OSM wiki prefix for pt_BR is "Pt:".
Note that JOSM wiki uses language code derived rules, whereas the prefix for OSM wiki seems to be manually decided. They are not identical.
comment:8 by , 6 years ago
If we go this way we need to:
- test that the added English links actually refer to non-redirect pages
- have a way to test redirects later (i.e. modify the wiki scraper)
If not:
- update the wiki scraper to handle redirects correct
comment:9 by , 6 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
follow-up: 15 comment:14 by , 6 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
You missed to address the comment:8, the wiki documentation is missing and this
else if (type == LocaleType.OSM_WIKI) { return locale.getLanguage() + ':'; }
causes lowercase results which produce a redirect always. It should not be default to produce useless redirects for each wiki call. We should use a correct uppercase/lowercase table instead.
follow-ups: 16 28 29 comment:15 by , 6 years ago
Replying to stoecker:
It should not be default to produce useless redirects for each wiki call.
We should add an integration test to check this.
follow-up: 17 comment:16 by , 6 years ago
Replying to Don-vip:
Replying to stoecker:
It should not be default to produce useless redirects for each wiki call.
We should add an integration test to check this.
Sidenote: We must be careful with remote integration tests. E.g. We are currently accessing all our map services 4 times a day with our JOSM user agent. I'm not sure this is a good idea. Probably that should be reduced to once a day and also use another user agent.
follow-up: 18 comment:17 by , 6 years ago
comment:18 by , 6 years ago
Replying to Don-vip:
Replying to stoecker:
I'm not sure this is a good idea.
Why?
Because as administrator I tend to block user agents and servers which constantly access the same stuff. Algorithmic data access is usually not caused by humans and thus unwanted data access. Other operators handle that similar.
Actually for automatic access we'd need to follow robots.txt protocols and thus be restricted.
If some operator decides to block JOSM user agent because of this that would be a VERY unwanted effect.
follow-up: 20 comment:19 by , 6 years ago
OK.
The i18n build is broken:
[exec] /* unparsed line 7481 <link wiki="Relations/Proposed/Bridges_and_Tunnels" /> */ BUILD FAILED /var/lib/jenkins/jobs/JOSM-i18n/workspace/i18n/build.xml:29: exec returned: 20
follow-up: 21 comment:20 by , 6 years ago
Replying to stoecker:
You missed to address the comment:8
I checked my replacements of href
with wiki
by hand: Except for Highway_link (see above), all localized href
s only differed by their language prefix. Thus, I consider the probability of localized pages redirecting anywhere differnt very low.
the wiki documentation is missing
Done: TaggingPresets
causes lowercase results which produce a redirect always. It should not be default to produce useless redirects for each wiki call. We should use a correct uppercase/lowercase table instead.
This is (a) not a problem and (b) not new: (a) https://wiki.openstreetmap.org/wiki/de:key:name automatically resolves to https://wiki.openstreetmap.org/wiki/DE:Key:name not involving a redirect. (b) from org.openstreetmap.josm.gui.dialogs.properties.HelpAction
we gladly opened De:
beforehand.
Replying to Don-vip:
The i18n build is broken:
Thanks for noticing! Fixed in [o34809].
comment:21 by , 6 years ago
Replying to simon04:
Replying to stoecker:
You missed to address the comment:8
I checked my replacements of
href
withwiki
by hand: Except for Highway_link (see above), all localizedhref
s only differed by their language prefix. Thus, I consider the probability of localized pages redirecting anywhere differnt very low.
As said in #17171 the script probably didn't handle redirects well. Thus I assume our links contain a lot of redirects or there wouldn't have been so many pt_BR remaining for manual fixing. This must be checked now (and later automatically) and cleaned. Redirects should only remain in seldom cases.
causes lowercase results which produce a redirect always. It should not be default to produce useless redirects for each wiki call. We should use a correct uppercase/lowercase table instead.
This is (a) not a problem and
Well, as said it is bad default behaviour.
(a) https://wiki.openstreetmap.org/wiki/de:key:name automatically resolves to https://wiki.openstreetmap.org/wiki/DE:Key:name not involving a redirect.
Check the data transmission yourself. It involves always a 301 redirect. If the URL line changes in a browser there is no way except a redirect to reach that goal (or JavaScript quirks).
(b) from
org.openstreetmap.josm.gui.dialogs.properties.HelpAction
we gladly openedDe:
beforehand.
Which tells me, that the existing code was not properly tested. Still that's no reason to leave it that way.
follow-up: 24 comment:23 by , 6 years ago
Replying to stoecker:
In 14660/josm:
I don't have time to test each case ATM. Hope this is ok as is. 😇
comment:24 by , 6 years ago
Replying to stoecker:
I don't have time to test each case ATM. Hope this is ok as is. 😇
The unit tests need to be adapted: https://josm.openstreetmap.de/jenkins/job/JOSM/4936/jdk=JDK8/testReport/org.openstreetmap.josm.tools/LanguageInfoTest/getWikiLanguagePrefix/
comment:26 by , 6 years ago
The information=map
preset points to the Key:information page instead of the Tag:information=map page on the wiki.
comment:29 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
It's not so easy. You overlooked all these cases where the links don't have the same name.