Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#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=equestrian the 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 Arena to Cancha para equitación during i18n load.

The call tree for tr starts in PresetListEntry#getDisplayValue. I think the problem here is that we are calling tr(display_value) instead of trc(cms == null ? null : cms.values_context, display_value). The latter gives us the expected translation of Cancha para equitación while the former just returns Horse 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  
    130130                cachedDisplayValue = Utils.firstNonNull(value, " ");
    131131            } else {
    132132                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), " ");
    134135            }
    135136        }
    136137        return cachedDisplayValue;

The entries in the preset leisure list have other translation locations, as follows:

This is probably why they all have translations -- the gettext code doesn't need the context for them, since they have been translated without context.

Attachments (0)

Change History (4)

comment:1 by stoecker, 3 years ago

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.

comment:2 by taylor.smock, 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:3 by taylor.smock, 3 years ago

Resolution: fixed
Status: newclosed

In 18648/josm:

Fix #22693: PresetListEntry should use trc instead of tr for display_value

comment:4 by skyper, 3 years ago

As the translation of display_value is fixed proper sorting might be the next target, see #22001.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.