mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 17:04:42 -04:00
internationalization of PinMapper
This commit is contained in:
parent
de4203b42b
commit
b135b4828b
@ -1,5 +1,7 @@
|
||||
package de.neemann.digital.builder;
|
||||
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -52,11 +54,11 @@ public class PinMap {
|
||||
*/
|
||||
public PinMap assignPin(String name, int pin) throws PinMapException {
|
||||
if (name == null || name.length() == 0)
|
||||
throw new PinMapException("No name for pin " + pin);
|
||||
throw new PinMapException(Lang.get("err_pinMap_NoNameForPin_N", pin));
|
||||
if (pinMap.containsKey(name))
|
||||
throw new PinMapException("Pin " + name + " assigned twice");
|
||||
throw new PinMapException(Lang.get("err_pinMap_Pin_N_AssignedTwicerPin", name));
|
||||
if (pinMap.containsValue(pin))
|
||||
throw new PinMapException("Pin " + pin + " assigned twice");
|
||||
throw new PinMapException(Lang.get("err_pinMap_Pin_N_AssignedTwicerPin", pin));
|
||||
pinMap.put(name, pin);
|
||||
return this;
|
||||
}
|
||||
@ -74,7 +76,7 @@ public class PinMap {
|
||||
while (st.hasMoreTokens()) {
|
||||
String tok = st.nextToken();
|
||||
int p = tok.indexOf("=");
|
||||
if (p < 0) throw new PinMapException("No = found!");
|
||||
if (p < 0) throw new PinMapException(Lang.get("err_pinMap_noEqualsfound"));
|
||||
|
||||
String name = tok.substring(0, p).trim();
|
||||
String numStr = tok.substring(p + 1).trim();
|
||||
@ -118,9 +120,9 @@ public class PinMap {
|
||||
if (p == null)
|
||||
p = search(inputPins, in);
|
||||
if (p == null) {
|
||||
throw new PinMapException("To manny inputs defined!");
|
||||
throw new PinMapException(Lang.get("err_pinMap_toMannyInputsDefined"));
|
||||
} else if (!contains(inputPins, p)) {
|
||||
throw new PinMapException("Input " + p + " not allowed!");
|
||||
throw new PinMapException(Lang.get("err_pinMap_input_N_notAllowed", p));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@ -138,9 +140,9 @@ public class PinMap {
|
||||
if (p == null)
|
||||
p = search(outputPins, out);
|
||||
if (p == null) {
|
||||
throw new PinMapException("To manny outputs defined!");
|
||||
throw new PinMapException(Lang.get("err_pinMap_toMannyOutputsDefined"));
|
||||
} else if (!contains(outputPins, p)) {
|
||||
throw new PinMapException("Output " + p + " not allowed!");
|
||||
throw new PinMapException(Lang.get("err_pinMap_Output_N_notAllowed", p));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@ -160,35 +162,26 @@ public class PinMap {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
HashMap<Integer, String> revMap = new HashMap<>();
|
||||
for (Map.Entry<String, Integer> i : pinMap.entrySet())
|
||||
revMap.put(i.getValue(), i.getKey());
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Inputs:\n");
|
||||
sb.append(Lang.get("msg_pinMap_inputs")).append(":\n");
|
||||
for (int i : inputPins)
|
||||
sb.append("Pin ")
|
||||
.append(i)
|
||||
.append(": ")
|
||||
.append(checkName(revMap.get(i)))
|
||||
.append("\n");
|
||||
sb.append(Lang.get("msg_pinMap_pin_N_is_N", i, checkName(revMap.get(i)))).append("\n");
|
||||
|
||||
|
||||
sb.append("\nOutputs:\n");
|
||||
sb.append("\n").append(Lang.get("msg_pinMap_outputs")).append(":\n");
|
||||
for (int i : outputPins)
|
||||
sb.append("Pin ")
|
||||
.append(i)
|
||||
.append(": ")
|
||||
.append(checkName(revMap.get(i)))
|
||||
.append("\n");
|
||||
sb.append(Lang.get("msg_pinMap_pin_N_is_N", i, checkName(revMap.get(i)))).append("\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String checkName(String s) {
|
||||
if (s == null) return "not used";
|
||||
if (s == null) return Lang.get("msg_pinMap_notUsed");
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,14 @@ err_toManyInputs_N=Zu viele Eing\u00E4nge. Es sind nur {0} Eing\u00E4nge erlaubt
|
||||
err_oneResultIsRequired=Table zu klein: Mindestens ein Ergebnis ist erforderlich!
|
||||
err_tableBecomesToSmall=Es sind mindestens zwei Eing\u00E4nge erforderlich!
|
||||
err_varNotAllowedInCUPL_N= In CUPL ist die Variable {0} nicht erlaubt!
|
||||
err_pinMap_Pin_N_AssignedTwicerPin=Pin {0} doppelt belegt!
|
||||
err_pinMap_toMannyInputsDefined=Zu viele Eing\u00E4nge definiert!
|
||||
err_pinMap_toMannyOutputsDefined=Zu viele Ausg\u00E4nge definiert!
|
||||
err_pinMap_noEqualsfound=Kein \"=\" gefunden!
|
||||
err_pinMap_NoNameForPin_N=Kein Name f\u00FCr Pin {0}
|
||||
err_pinMap_input_N_notAllowed=Eingang {0} ist nicht erlaubt!
|
||||
err_pinMap_Output_N_notAllowed=Ausgang {0} ist nicht erlaubt!
|
||||
|
||||
|
||||
attr_dialogTitle=Eigenschaften
|
||||
msg_errorEditingValue=Fehler bei der Eingabe eines Wertes
|
||||
@ -207,6 +215,10 @@ msg_annalyseErr=Fehler bei der Analyse der Schaltung
|
||||
msg_errorDuringCalculation=Fehler w\u00E4hrend der Vereinfachung.
|
||||
msg_N_nodes={0} aktive Elemente
|
||||
msg_restartNeeded=Die \u00C4nderung erfordert einen Neustart!
|
||||
msg_pinMap_inputs=Eing\u00E4nge
|
||||
msg_pinMap_outputs=Ausg\u00E4nge
|
||||
msg_pinMap_pin_N_is_N=Pin {0}: {1}
|
||||
msg_pinMap_notUsed=nicht verwendet
|
||||
|
||||
|
||||
stat_clocks={0} Halbzyklen
|
||||
|
@ -169,6 +169,13 @@ err_toManyInputs_N=To many inputs, allowed are {0}
|
||||
err_oneResultIsRequired=Table to small: One result is required!
|
||||
err_tableBecomesToSmall=Two inputs are required!
|
||||
err_varNotAllowedInCUPL_N= Variable {0} is not allowed in CUPL source!
|
||||
err_pinMap_Pin_N_AssignedTwicerPin=Pin {0} assigned twice!
|
||||
err_pinMap_toMannyInputsDefined=To manny inputs defined
|
||||
err_pinMap_toMannyOutputsDefined=To manny outputs defined
|
||||
err_pinMap_noEqualsfound=No = found!
|
||||
err_pinMap_NoNameForPin_N=No Name for pin {0}
|
||||
err_pinMap_input_N_notAllowed=Input {0} not allowed!
|
||||
err_pinMap_Output_N_notAllowed=Output {0} not allowed!
|
||||
|
||||
attr_dialogTitle=Attributes
|
||||
|
||||
@ -187,6 +194,10 @@ msg_frequency_N=The maximum frequency is {0}Hz
|
||||
msg_errorDuringCalculation=Error during simplification
|
||||
msg_N_nodes={0} nodes
|
||||
msg_restartNeeded=Change needs a restart to take effect!
|
||||
msg_pinMap_inputs=Inputs
|
||||
msg_pinMap_outputs=Onputs
|
||||
msg_pinMap_pin_N_is_N=Pin {0}: {1}
|
||||
msg_pinMap_notUsed=not used
|
||||
|
||||
stat_clocks={0} half cycles
|
||||
|
||||
|
@ -105,4 +105,18 @@ public class PinMapTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// ToDo: fails if language is not german!
|
||||
public void testToString() throws PinMapException {
|
||||
pinMap.assignPin("A", 1);
|
||||
pinMap.assignPin("B", 4);
|
||||
assertEquals("Eingänge:\n" +
|
||||
"Pin 1: A\n" +
|
||||
"Pin 2: nicht verwendet\n" +
|
||||
"Pin 3: nicht verwendet\n" +
|
||||
"\n" +
|
||||
"Ausgänge:\n" +
|
||||
"Pin 4: B\n" +
|
||||
"Pin 5: nicht verwendet\n" +
|
||||
"Pin 6: nicht verwendet\n", pinMap.toString());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user