Opened 5 years ago
Last modified 5 years ago
#17173 closed enhancement
[Patch] Detect preset wiki languages automatically — at Version 9
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)
Change History (10)
by , 5 years ago
Attachment: | 17173.patch.gz added |
---|
comment:1 by , 5 years ago
Cc: | added |
---|
comment:2 by , 5 years ago
follow-up: 4 comment:3 by , 5 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 , 5 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 , 5 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 , 5 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 , 5 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 , 5 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
It's not so easy. You overlooked all these cases where the links don't have the same name.