Modify

Opened 3 years ago

Closed 2 years ago

#21965 closed enhancement (fixed)

[PATCH] Use <different> translation from KeyedItem

Reported by: gaben Owned by: team
Priority: minor Milestone: 23.03
Component: Core Version:
Keywords: Cc:

Description


Attachments (2)

josm_different.patch (10.8 KB ) - added by gaben 3 years ago.
josm_different_v2.patch (11.7 KB ) - added by gaben 2 years ago.
v2 reupload

Download all attachments as: .zip

Change History (23)

by gaben, 3 years ago

Attachment: josm_different.patch added

comment:1 by gaben, 3 years ago

Priority: normalminor

comment:2 by gaben, 3 years ago

Milestone: 22.06

comment:3 by stoecker, 3 years ago

Milestone: 22.0622.07

comment:4 by stoecker, 3 years ago

Hmm, your change will make that string untranslated, as there isn't a single place where the string is marked as translatable. Anyway, why is this necessary?

in reply to:  4 ; comment:5 by gaben, 3 years ago

Replying to stoecker:

Hmm, your change will make that string untranslated, as there isn't a single place where the string is marked as translatable.

In KeyedItem.java the DIFFERENT_I18N is already used and translateable to my knowledge.

Anyway, why is this necessary?

Removing the error prone code usage based on previous experience in JOSM.

in reply to:  5 comment:6 by stoecker, 3 years ago

Replying to gaben:

Replying to stoecker:

Hmm, your change will make that string untranslated, as there isn't a single place where the string is marked as translatable.

In KeyedItem.java the DIFFERENT_I18N is already used and translateable to my knowledge.

No. As you remove all other places it's not. Software doesn't care how many, but there must be at least one place, where a tr() or trm() is around the string, not a variable of the string. ;-)

comment:7 by taylor.smock, 3 years ago

Milestone: 22.0722.08

comment:8 by taylor.smock, 2 years ago

Milestone: 22.0822.09

comment:9 by taylor.smock, 2 years ago

Milestone: 22.0922.10

comment:10 by taylor.smock, 2 years ago

Milestone: 22.10
Summary: [patch] Use <different> translation from KeyedItem[WIP PATCH] Use <different> translation from KeyedItem

@gaben: stoecker is correct in saying that your patch would remove all translations for <different>.

Possible solutions:

  1. Wrap the "<different>" string in KeyedItem with marktr
  2. Don't apply the patch.

Personally, I probably would have wrapped the "<different>" string with marktr, and used that variable everywhere else (so tr(KeyedItem.DIFFERENT), mostly to make it easier if we ever decide to try and make it possible to change the JOSM language without restarting. But your method has its pro's as well, but mostly if it is called inside a loop on the EDT.

comment:11 by gaben, 2 years ago

Yep, I know just currently have no time to reduce my JOSM ticket backlog.

Thanks for the heads up. I'll look into it and other tickets as well.

comment:12 by taylor.smock, 2 years ago

No worries. I'm just going through the tickets marked for 22.10 and applying the ones that are ready/fix a bug and probably won't cause issues (next tested version will either be released this weekend by one of the other maintainers, or early next week by me).

This particular ticket just hasn't shown any movement in a few months, so I dropped the milestone to reduce the number of Milestone: uu.vv -> xx.yy messages.

comment:13 by gaben, 2 years ago

Suggestion applied, now there is a marktr() around the string. Not sure what's the difference to the simple tr() in this case.

Last edited 2 years ago by gaben (previous) (diff)

comment:14 by taylor.smock, 2 years ago

tr does the actual translation, marktr is effectively a no-op, only used to ensure that the translation system doesn't miss strings that are set to variables, but not translated in that context (for whatever reason).

So

static final String DIFFERENT = "different";
System.out.println(tr(DIFFERENT));

would always print "different", since it will never be translated.

static final String DIFFERENT = marktr("different"); // we can now pass the string to tr for the actual translation
System.out.println(tr(DIFFERENT));
// or just
System.out.println(tr("different"));

would work, since the "different" string will be picked up by the translation tools.

comment:15 by gaben, 2 years ago

Thanks for the explanation! So the second version of the patch is also wrong, as I only used marktr(). I'm going to reupload with this modification.

by gaben, 2 years ago

Attachment: josm_different_v2.patch added

v2 reupload

comment:16 by gaben, 2 years ago

Milestone: 23.01

Please review and remove the WIP from the title if you find the second version acceptable.

comment:17 by taylor.smock, 2 years ago

It looks better now.

I would have done things slightly differently, but that is almost a style/implementation detail. Specifically, in source:trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java, I would have used protected static final String DIFFERENT = marktr("<different>"); public static final String DIFFERENT_I18N = tr(DIFFERENT);, but it is arguable as to which style is better.

I'm uncertain about the change to toString in PropertiesDialog -- the String.format code is easier to read, but is a bit slower. I'd have to profile it and see if it slows a code path down too much. I don't think it will, since toString isn't usually called in a loop.

comment:18 by taylor.smock, 2 years ago

Summary: [WIP PATCH] Use <different> translation from KeyedItem[PATCH] Use <different> translation from KeyedItem

comment:19 by taylor.smock, 2 years ago

Milestone: 23.0123.02

Ticket retargeted after milestone closed

comment:20 by taylor.smock, 2 years ago

Milestone: 23.0223.03

Ticket retargeted after milestone closed

comment:21 by taylor.smock, 2 years ago

Resolution: fixed
Status: newclosed

In 18692/josm:

Fix #21965: Reuse same instance of "<different>" for consistency (patch by gaben)

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.