#22693 closed defect (fixed)
[PATCH] `PresetListEntry` should use `trc` instead of `tr` for `display_value`
| Reported by: | taylor.smock | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 23.02 |
| Component: | Core | Version: | |
| Keywords: | Cc: |
Description
The originating problem comes from comment:8:ticket:22588 (Hufkratzer):
I have tested this in the latest available build 18645 and found that in the preset for
sport=equestrianthe string "Horse Riding Arena" isn't translated, although there have been translations entered in launchpad.
[...snip...]
From comment:15:ticket:22588 (taylor.smock):
I've done a bit of debugging.
It looks like we are mapping_:riding\nHorse Riding ArenatoCancha para equitaciónduring i18n load.
The call tree for
trstarts inPresetListEntry#getDisplayValue. I think the problem here is that we are callingtr(display_value)instead oftrc(cms == null ? null : cms.values_context, display_value). The latter gives us the expected translation ofCancha para equitaciónwhile the former just returnsHorse Riding Arena.
A patch for that is relatively trivial, but I don't know what the fallout would be (are there some values that depend upon the context not being set?).
src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java
diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java
a b 130 130 cachedDisplayValue = Utils.firstNonNull(value, " "); 131 131 } else { 132 132 cachedDisplayValue = Utils.firstNonNull( 133 locale_display_value, tr(display_value), trc(cms == null ? null : cms.values_context, value), " "); 133 locale_display_value, trc(cms == null ? null : cms.values_context, display_value), 134 trc(cms == null ? null : cms.values_context, value), " "); 134 135 } 135 136 } 136 137 return cachedDisplayValue; The entries in the preset
leisurelist have other translation locations, as follows:
Horse Riding Arena: None (not translated elsewhere)Horse Riding Centre: source:trunk/resources/data/defaultpresets.xml#L4065Sports Centre: source:trunk/resources/data/defaultpresets.xml#L5162Stadium: source:trunk/resources/data/defaultpresets.xml#L5154Racetrack: source:trunk/resources/data/defaultpresets.xml#L5189This is probably why they all have translations -- the
gettextcode doesn't need the context for them, since they have been translated without context.
Attachments (0)
Change History (4)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
Yes, it is clearly a bug.
I was planning on applying a patch for this early in the 23.02 cycle (as in this Thursday/Friday). I do think that the fix could be done right now, but I had been planning on doing the 23.01 release today, and I have been trying to not do any non-essential (AKA "JOSM is crashing") fixes for at least 3 days prior to and after the release day.
comment:4 by , 3 years ago
As the translation of display_value is fixed proper sorting might be the next target, see #22001.



That's clearly simply a bug. If values_context is given, it should also be used for display value otherwise it translates the wrong string. We have no different context for values and display values. That's also how the i18n-extractor sees this.