Skip to content

Commit 747ce01

Browse files
committed
Use un-translated labels to sort boards submenus
Otherwise it may happen some weird sorting when untraslated and translated labels are sorted together: Arduino megaAVR Boards Arduino nRF52 Board ESP32 Arduino ESP8266 Modules Schede Arduino AVR <-- the localized string falls to the bottom all the Arduino boards should be packed together, so it's better to not use localization at all while sorting. After this patch it will look like Schede Arduino AVR Arduino megaAVR Boards Arduino nRF52 Board ESP32 Arduino ESP8266 Modules
1 parent 55fa3f5 commit 747ce01

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

Diff for: app/src/processing/app/Base.java

+19-9
Original file line numberDiff line numberDiff line change
@@ -1481,19 +1481,29 @@ public void actionPerformed(ActionEvent actionevent) {
14811481
ButtonGroup boardsButtonGroup = new ButtonGroup();
14821482
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>();
14831483

1484-
List<JMenu> platformMenus = new ArrayList<JMenu>();
1484+
class PlatformJMenu extends JMenu {
1485+
private String untraslatedText;
1486+
1487+
public PlatformJMenu(TargetPlatform pl) {
1488+
super();
1489+
untraslatedText = pl.getPreferences().get("name");
1490+
if (untraslatedText == null) {
1491+
untraslatedText = pl.getContainerPackage().getId() + "-" + pl.getId();
1492+
}
1493+
setText(tr(untraslatedText));
1494+
}
1495+
1496+
public String getUntraslatedText() {
1497+
return untraslatedText;
1498+
}
1499+
}
1500+
List<PlatformJMenu> platformMenus = new ArrayList<>();
14851501

14861502
// Cycle through all packages
14871503
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
14881504
// For every package cycle through all platform
14891505
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
1490-
1491-
// Add a title for each platform
1492-
String platformLabel = targetPlatform.getPreferences().get("name");
1493-
if (platformLabel == null)
1494-
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();
1495-
1496-
JMenu platformBoardsMenu = new JMenu(tr(platformLabel));
1506+
PlatformJMenu platformBoardsMenu = new PlatformJMenu(targetPlatform);
14971507
MenuScroller.setScrollerFor(platformBoardsMenu);
14981508
platformMenus.add(platformBoardsMenu);
14991509

@@ -1510,7 +1520,7 @@ public void actionPerformed(ActionEvent actionevent) {
15101520
}
15111521
}
15121522

1513-
platformMenus.sort((x,y) -> x.getText().compareToIgnoreCase(y.getText()));
1523+
platformMenus.sort((x,y) -> x.getUntraslatedText().compareToIgnoreCase(y.getUntraslatedText()));
15141524

15151525
JMenuItem firstBoardItem = null;
15161526
if (platformMenus.size() == 1) {

0 commit comments

Comments
 (0)