eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

i18n: hardcoded quoting used for UnresolvedElementsSubProcessor_swaparguments_description

Open
#542 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

Quickfix proposal for argument swapping errors, using the message `Swap arguments {0} and {1}`, may contain quoted variable names or plain argument position numbers. When quoting is needed in either the first or the second message placeholders, quoting is hardcoded, and therefore not suitable for translation. Single quotes is not a unique choice for all locales…

You may check on hover over the errors at:

```java
int a = 1, b = 3;
char[] charlist = { 'A', 'B', 'C', 'D', 'E' };

new String(a, b, charlist);
new String(a, charlist, b);
new String(a, new char[] { 'A', 'B', 'C', 'D', 'E' }, b);
new String(4, new char[] { 'A', 'B', 'C', 'D', 'E' }, 0);
```

BTW: The error description shown `The constructor String(int, int, char[]) is undefined` neither seems to be translated.

Quoting seems to be done at [org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.java](https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/9eb04778168dc7045d694d7dd923deae269f996f/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java#L1704) as:
```java
return '\'' + BasicElementLabels.getJavaElementName(ASTNodes.asString(expr)) + '\'';
```

A common quoting method at the Messages class applying a translatable quoting format pattern might be a good alternative.
David

Contributor guide

Open the contributing guide

Research direction

Start at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.java around line 1704 and inspect how the swap-arguments description is assembled. Then review the Messages class and its existing translatable formatting patterns. Done means the quoting used in both message placeholders is locale-suitable rather than hardcoded, while the hover error examples retain the intended meaning.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.