[Bug] Unit symbols are hardcoded in the sources and cannot be localized
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- internationalization, localization
Direzione di ricerca
Start with the unit constructors in core/src/main/java/info/openrocket/core/unit/UnitGroup.java and the other call sites named in the report, including CaliberUnit, PercentageOfLengthUnit, DegreeUnit, AppearancePanel, UIPreferencesPanel, and MultiLevelPinkNoiseWindModel. Read how UnitGroup lookup, equality, preferences, and .ork serialization use unit strings before proposing localization, then inspect the message files and existing translator initialization. Done means unit labels can be localized without breaking parsing, stored preferences, or file compatibility.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Unit symbols shown in the UI are hardcoded string literals in the Java sources. None of them are looked up in the translation files, so every locale displays the same English/ASCII symbols and a translator has no key that could change them. The only localized unit text today is the compass-rose letter used for latitude and longitude (CompassRose.lbl.north/south/east/west). Number formatting is localized (Unit builds its DecimalFormatSymbols from Locale.getDefault(FORMAT)), which is why a Russian locale already renders Длина: 0,5 cm — localized number, untranslatable unit.
Most labels are literals passed to unit constructors in the static initializer of core/src/main/java/info/openrocket/core/unit/UnitGroup.java (lines 107-420), for example:
- length:
mm,cm,m,km,in,in/64,ft,yd,mi,nmi - area/inertia/densities:
mm²,in²,ft²,kg·m²,lb·ft²,g/cm³,oz/in³,lb/ft³,g/m²,oz/ft²,g/cm,oz/ft - energy/power/moment:
J,erg,BTU,cal,ft·lbf,W,hp,N·m,lbf·in,kg·m/s,N·m·s - mass/force:
g,kg,oz,lb,N,lbf,kgf,Ns,lbf·s - velocity/windspeed:
m/s,km/h,ft/s,mph,kt - time:
ms,s,min,Hz,rpm,r/s,rad/s,°/s - temperature/pressure/shear modulus/roughness:
K,°C,°F,mbar,bar,atm,mmHg,inHg,psi,Pa,GPa,ksi,µm,mil - angle/stability/relative:
°,rad,arcmin,cal,%,‰
A few units are built outside UnitGroup and carry their label in the constructor as well: CaliberUnit ("cal"), PercentageOfLengthUnit ("%"), DegreeUnit (°), AppearancePanel.TEXTURE_UNIT, the scale unit in UIPreferencesPanel, and DegreeUnit in MultiLevelPinkNoiseWindModel. FixedUnitGroup reproduces an arbitrary user-supplied string from a custom expression.
No unit keys exist in any language file. Searching for keys that would name a unit (^unit[._], ^Unit[._]) gives zero hits in messages.properties, messages_de.properties, messages_zh.properties and messages_ru.properties, and the keys that do contain the word unit are dialog labels (pref.dlg.tab.Units, simplotpanel.lbl.Unit, …). This is therefore not an incomplete translation that a locale file could fix.
AI assistance
Model(s): DeepSeek 4.1 Flash (via OpenCode)
AI located the hardcoded labels and their call sites and drafted this report. Every file path, line reference and behaviour described here was checked against the repository.
To Reproduce
- Start OpenRocket with a non-English locale, e.g.
LANG=ru_RU.UTF-8(or pick the language in the preferences and restart). - Add or open any component and look at the fields that carry a unit in their label, for example a mass component: the values read
Длина: 0,5 cm,Внешний диаметр: 4,6 cm,Внутренний диаметр: 4,6 cm,Толщина стенки: 0 cm,Материал компонента: Картон (0,68 g/cm³),Масса компонента: 0 g. - Compare the number and the unit in the same string: the number is localized (
0,5with a decimal comma), the unit is not (cm,g/cm³,g). - Open the unit chooser next to such a field: every entry is one of the hardcoded labels —
cm,mm,m,in,in/64,ft— regardless of language. - Open the preferences, Units tab: the combos that pick the default unit for each quantity show the same untranslated labels.
- Switch to a second non-English language (for example German) and repeat: the labels are byte-for-byte identical, so this is not a missing Russian translation.
- Optional cross-check without the GUI: searching the message files for keys that would name a unit (
^unit[._],^Unit[._]) returns nothing in any language, so there is no key a translator could fill in.
Screenshots / .ork file
No response
OpenRocket version
unstable
What platform are you running on?
Linux
Additional context
Why the label cannot simply be wrapped in trans.get()
The literal doubles as the unit's identity, so changing the display text affects equality, parsing, preferences and file format:
UnitGroup.getUnit(String)andsetDefaultUnit(String)resolve a unit by comparinggetUnit()Unit.equals/hashCodeandUnitGroup.equalscompare the stringUnitGroup.SIUNITSis keyed by strings such as"m/s"and"kg m^2"ApplicationPreferences.setMultiLevelWindCsvImportAltitudeUnit(Unit)storesunit.toString()as a preference and reads it back withUnitGroup.UNITS_DISTANCE.getUnit(unitString), so a localizedtoString()would invalidate stored preferencesOpenRocketSaverwrites the same string into.orkfilesUnitGroup.fromString(...)accepts a unit typed after the value ("3 cm") and matches it againstgetUnit(), so users can type the translated labelUnitobjects are created once in a static initializer, andUnitGroupcaptures the translator at class-init time (private static final Translator trans = Application.getTranslator();) and uses it for the latitude/longitude labels, so translating in the constructor would freeze the language at that point
- Lingua principale
- Java
- Stelle
- 3.1k
- Fork
- 703
- Merge medio
- 21h 26m
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openrocket/openrocket
-
[Bug] Material names are not translated when the generated key is missing or wrongForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
openrocket/openrocket#3417 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] MassObject packed length with automatic radius depends on getter order, so saved files differApertarelease blocker
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openrocket/openrocket#3399 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
release blocker
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
openrocket/openrocket#3398 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openrocket/openrocket#3377 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
openrocket/openrocket#3230 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openrocket/openrocket
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
quarkusio/quarkus-agent-mcp#302 ·
I maintainer di solito rispondono entro 2 giorni
-
build
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
MetricsHub/metricshub-community#1472 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
IdentityArrayObjectSet iterator remove may throw ArrayIndexOutOfBoundsExceptionForse già presa @jiteshkhatri11 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
javapathfinder/jpf-core#660 · 1 commento ·