Opened 16 years ago
Closed 16 years ago
#3261 closed enhancement (fixed)
[PATCH] Use the "name:$CURRENT_LOCALE" name in the JOSM UI instead of "name" when it exists
Reported by: | Owned by: | Gubaer | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Core | Version: | latest |
Keywords: | Cc: |
Description
UI elements in JOSM such as the selection dialog will display the value of the "name" tag instead of just "node/way/relation" if it exists.
This feature should be expanded so that JOSM looks at "name:$CURRENT_LOCALE" first, then "name". So that someone using JOSM in e.g. German or Icelandic will get a localized interface when viewing objects with name:de or name:is tags.
Attachments (1)
Change History (10)
follow-up: 2 comment:1 by , 16 years ago
by , 16 years ago
Attachment: | locale-name.patch added |
---|
comment:2 by , 16 years ago
Priority: | major → minor |
---|---|
Summary: | Use the "name:$CURRENT_LOCALE" name in the JOSM UI instead of "name" when it exists → [PATCH] Use the "name:$CURRENT_LOCALE" name in the JOSM UI instead of "name" when it exists |
Replying to avar:
I note that it looks like mappaint already does this. But the rest of the UI doesn't.
I did not know that. I think this should always show the same name. Because I did not realize this fact I only write a patch for the selected name.
follow-up: 4 comment:3 by , 16 years ago
This line
if (Main.pref.getBoolean("tags.name.uselocale", true)) {
creates a dependency from the basic OSM data class OsmPrimitive
to Main which, I think, we should avoid.
There is already the preference osm-primitives.showid
which controls whether the display name of a primitive should include its id. The formatting code is in PrimitiveNameFormatter.java in order to avoid dependencies to Main.pref
.
I see two alternatives:
- a new method
getLocalizedName()
on OsmPrimitive and derived classes. Depending ontags.name.uselocale
getName() in PrimitiveNameFormatter whould then either invoke getName() or getLocalizedName()
- don't make localized names configurable at all. If the name of a primitive is always localized the dependency to
Main.prefs
is gone.
Actually, I'd prefer the following API on OSMPrimitive:
- getName() - replies the content of the tag "name" if present; null, otherwise
- getName(Locale locale) - replies the content of the "name:xx" tag matching locale, or getName() if no such tag exists
- getDisplayName(INameFormatter formatter) - replies the display name of an OSM primititive formatted by a formatter. Is abstract on OsmPrimitive and dispatches to formatter on Node, Way and Relation.
where
interface INameFormatter { // implementations will encapsulate the "name formatting strategy", // including whether an id is to be displayed, whether a localized // name is to be displayed, which other tags are to be used to build the tag, etc. // void String format(Node node); void String format(Way way) void String format(Relation relation) }
follow-up: 5 comment:4 by , 16 years ago
Replying to Gubaer:
creates a dependency from the basic OSM data class
OsmPrimitive
to Main which, I think, we should avoid.
Okay. But there is already a dependency to Main.pref for "tags.uninteresting" and "tags.direction".
[...]
- don't make localized names configurable at all. If the name of a primitive is always localized the dependency to
Main.prefs
is gone.
First I did not think about preference. Then I think different users may have different preferences in this topic. That's why I added the preference to code. One point against localize names: Names may different from rendered map.
[...]
- getDisplayName(INameFormatter formatter) - replies the display name of an OSM primititive formatted by a formatter. Is abstract on OsmPrimitive and dispatches to formatter on Node, Way and Relation.
where
interface INameFormatter {
[...]
You have to add DataSet to INameFormatter (in may opinion the name should not include an "i" as all other interfaces). Then it is only different in return value to org.openstreetmap.josm.data.osm.visitor.Visitor.
follow-up: 6 comment:5 by , 16 years ago
Replying to plaicy:
Replying to Gubaer:
creates a dependency from the basic OSM data class
OsmPrimitive
to Main which, I think, we should avoid.
Okay. But there is already a dependency to Main.pref for "tags.uninteresting" and "tags.direction".
Yes, I know - and I don't like them either. In the last couple of weeks/months we removed more and more dependencies to Main.xyz
, for instance as result of the the work Jiri did on progress monitoring. I'd like to continue our work in this direction.
[...]
- don't make localized names configurable at all. If the name of a primitive is always localized the dependency to
Main.prefs
is gone.First I did not think about preference. Then I think different users may have different preferences in this topic. That's why I added the preference to code. One point against localize names: Names may different from rendered map.
I support making localized names configurable, I'm only suggesting to do it outside of the base OsmPrimitive class.
You have to add DataSet to INameFormatter (in may opinion the name should not include an "i" as all other interfaces). Then it is only different in return value to org.openstreetmap.josm.data.osm.visitor.Visitor.
Agree. NameFormatter without an I is fine for me.
Why do you think DataSet should be added to NameFormatter? It is not required today in getName(). Furthermore, if the "strategy" in a particular NameFormatter would require access to a dataset you can always write one à la
public class MyNameFormatterDependingOnDataSet implements NameFormatter { private DataSet ds; public MyNameFormatterDependingOnDataSet(DataSet ds) { this.ds = ds; } public String format(Node node) { // build the name depending on the current dataset } }
Jiri is also working on keeping a reference from each primitive to "its" dataset in the future which will make access to a primitives "parent dataset" easier, too.
Then it is only different in return value to org.openstreetmap.josm.data.osm.visitor.Visitor.
Indeed, it follows the same visitor pattern but it was for the different return type that I didn't propose to either use Visitor
or to have
interface NameFormatter extends Visitor ....
follow-up: 7 comment:6 by , 16 years ago
You have to add DataSet to INameFormatter (in may opinion the name should not include an "i" as all other interfaces). Then it is only different in return value to org.openstreetmap.josm.data.osm.visitor.Visitor.
Agree. NameFormatter without an I is fine for me.
Why do you think DataSet should be added to NameFormatter? It is not required today in getName(). Furthermore, if the "strategy" in a particular NameFormatter would require access to a dataset you can always write one à la
I do not need it. But if you make getDisplayName(INameFormatter formatter)
abstract in OsmPrimitive you have to overwrite it in org.openstreetmap.josm.data.osm.Changeset (sorry for that typo). If you simple ignore this call in Changeset write some documentation in INameFormatter (or which ever name). Would confuse the next person otherwise.
Choose a solution you like. This patch was only one possible way to add locale names.
comment:7 by , 16 years ago
I do not need it. But if you make
getDisplayName(INameFormatter formatter)
abstract in OsmPrimitive you have to overwrite it in org.openstreetmap.josm.data.osm.Changeset (sorry for that typo).
Sure. That's what I recently did for getName(), too. And, of course, I forgot to add
String format(Changeset changeset);
in the definition of NameFormatter above.
comment:8 by , 16 years ago
Owner: | changed from | to
---|
I'm going to take care of this but I wait until the next tested
release is released. Changing this naming stuff will impact a couple of classes in the core, it might also have an impact on plugins.
comment:9 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I note that it looks like mappaint already does this. But the rest of the UI doesn't.