adds italian translation

This commit is contained in:
hneemann 2021-07-14 15:51:47 +02:00
parent 9aa2c6ccd0
commit 8e6f2bb42c
9 changed files with 4386 additions and 88 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="addr">Address</string>
<string name="tableOfContent">Table of Contents</string>
@ -90,10 +90,9 @@
</string>
<string name="elem_XNOr">XNOr</string>
<string name="elem_XNOr_tt">A combination of XOR and NOT. The inputs are combined with the XOR operation.
The result of this operation than is inverted.
The result of this operation is then inverted.
It is also possible to use buses with several bits per input. In this case, the operation is applied to each
bit of the inputs.
</string>
bit of the inputs.</string>
<string name="elem_Not">Not</string>
<string name="elem_Not_tt">Inverts the input value. A 1 becomes a 0 and a 0 becomes 1.
It is also possible to use a bus with several bits per input. In this case, the operation is applied to each
@ -125,8 +124,7 @@
<string name="elem_Out_tt">Can be used to display an output signal in a circuit.
This element is also used to connect a circuit to an embedding circuit.
In this case the connection is bidirectional.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.
</string>
Is also used to assign a pin number, if the code for a CPLD or FPGA is generated.</string>
<string name="elem_Out_pin_in">This value is used for the output connection.</string>
<string name="elem_LED">LED</string>
<string name="elem_LED_tt">A LED can be used to visualize an output value. Accepts a single bit.
@ -141,7 +139,7 @@
<string name="elem_RGBLED_pin_B">The blue color channel.</string>
<string name="elem_PolarityAwareLED">LED with two connections.</string>
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up,
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up
if the anode is connected to high and the cathode is connected to low.
This LED cannot be used as a pull-down resistor. It acts solely as a display element.
The shown resistor is only meant to symbolize the required series resistor to limit the current.</string>
@ -161,13 +159,12 @@
<string name="elem_DipSwitch_pin_out">The output value of the switch.</string>
<string name="elem_Clock">Clock Input</string>
<string name="elem_Clock_tt">A clock signal. Its possible to control it by a real-time clock.
<string name="elem_Clock_tt">A clock signal. It's possible to control it by a real-time clock.
Depending on the complexity of the circuit, the clock frequency achieved may be less than the selected value.
If the frequency is greater than 50Hz, the graphic representation of the circuit will no longer be updated at
every clock cycle so that the wire colors will no longer be updated.
If the real-time clock is not activated, the clock can be controlled by mouse clicks.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.
</string>
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.</string>
<string name="elem_Clock_pin_C">Switches between 0 and 1 with the selected clock frequency.</string>
<string name="elem_Button">Button</string>
<string name="elem_Button_tt">A simple push button which goes back to its original state when it is released.</string>
@ -261,9 +258,8 @@
A separate window is opened for the text input.
</string>
<string name="elem_Keyboard_pin_C">Clock. A rising edge removes the oldest character from the buffer.</string>
<string name="elem_Keyboard_pin_en">If high the output D is active and one character is output.
It also enables the clock input.
</string>
<string name="elem_Keyboard_pin_en">If high, the output D is active and one character is output.
It also enables the clock input.</string>
<string name="elem_Keyboard_pin_D">The last typed character, or zero if no character is available.
Output is the 16 bit Java char value.
</string>
@ -809,8 +805,8 @@
<string name="elem_Comparator_pin_a">Input a to compare.</string>
<string name="elem_Comparator_pin_b">Input b to compare.</string>
<string name="elem_Comparator_pin_=">Output is 1 if input a equals input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater then input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less then input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater than input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less than input b</string>
<string name="elem_Neg">Negation</string>
<string name="elem_Neg_short">Neg</string>
<string name="elem_Neg_tt">Negation in the 2th complement</string>
@ -1093,12 +1089,12 @@
<string name="err_noTestData">No test data found.</string>
<string name="err_pullUpAndDownNotAllowed">It's not allowed to connect a pull up and a pull down resistor to a single wire.</string>
<string name="err_openingDocumentation">Could not open the browser.</string>
<string name="err_couldNotCreateFolder_N0">Could not create folder &quot;{0}&quot;!</string>
<string name="err_couldNotCreateFolder_N0">Could not create folder "{0}"!</string>
<string name="err_switchHasNoNet">It is not allowed to connect only inputs to a switch.</string>
<string name="err_file_N0_ExistsTwiceBelow_N1">The file {0} exists multiple times under {1}.</string>
<string name="err_couldNotFindIncludedFile_N0">Could not find the file {0}.</string>
<string name="err_postProcessErrorIn_N0">Error during execution of &quot;{0}&quot;.</string>
<string name="err_processDoesNotTerminate_N">The process &quot;{0}&quot; does not return!</string>
<string name="err_postProcessErrorIn_N0">Error during execution of "{0}".</string>
<string name="err_processDoesNotTerminate_N">The process "{0}" does not return!</string>
<string name="err_processExitedWithError_N1_N2">The process returns the non zero value {0}: {1}</string>
<string name="err_errorRunningFitter">Error starting the external fitter!</string>
<string name="err_noExpressionsAvailable">There are no minimized equations!</string>
@ -1146,7 +1142,7 @@
<string name="err_notMoreOutBitsThanInBits">There must be more input bits than output bits!</string>
<string name="err_constantsNotAllowed">It is not possible to set physical pins to constant values!</string>
<string name="err_invalidNumberFormat_N_N">The string {0} is not a valid number (pos {1})!</string>
<string name="err_invalidPinName_N">The name &quot;{0}&quot; is not allowed!</string>
<string name="err_invalidPinName_N">The name "{0}" is not allowed!</string>
<string name="err_whiteSpaceNotAllowedInTT2Name">No white space is allowed in the name of the TT2 file!</string>
<string name="err_tableHasToManyResultColumns">The table has too many columns!</string>
<string name="err_errorExportingZip">Error writing the ZIP file.</string>
@ -2061,7 +2057,7 @@
<string name="msg_test_missingLines_tt">All test cases are executed, but not all results are shown.
The evaluation of the test result is nevertheless correct!</string>
<string name="msg_isLocked">The editing of the circuit is disabled. You can remove the lock at
"{0} -> {1} -> {2}".
"{0} -&gt; {1} -&gt; {2}".
However, copying of components and the configuration of diodes and FGFETs with the [P] key is also possible in
the locked mode.
</string>

View File

@ -89,7 +89,7 @@ In the file howTo.md you can find more details about translations.
bit of the inputs.</string>
<string name="elem_XNOr">XNOr</string>
<string name="elem_XNOr_tt">A combination of XOR and NOT. The inputs are combined with the XOR operation.
The result of this operation than is inverted.
The result of this operation is then inverted.
It is also possible to use buses with several bits per input. In this case, the operation is applied to each
bit of the inputs.</string>
<string name="elem_Not">Not</string>
@ -117,7 +117,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Out_tt">Can be used to display an output signal in a circuit.
This element is also used to connect a circuit to an embedding circuit.
In this case the connection is bidirectional.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.</string>
Is also used to assign a pin number, if the code for a CPLD or FPGA is generated.</string>
<string name="elem_Out_pin_in">This value is used for the output connection.</string>
<string name="elem_LED">LED</string>
<string name="elem_LED_tt">A LED can be used to visualize an output value. Accepts a single bit.
@ -139,7 +139,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_DipSwitch_tt">Simple DIP switch that can output either high or low.</string>
<string name="elem_DipSwitch_pin_out">The output value of the switch.</string>
<string name="elem_Clock">Clock Input</string>
<string name="elem_Clock_tt">A clock signal. Its possible to control it by a real-time clock.
<string name="elem_Clock_tt">A clock signal. It's possible to control it by a real-time clock.
Depending on the complexity of the circuit, the clock frequency achieved may be less than the selected value.
If the frequency is greater than 50Hz, the graphic representation of the circuit will no longer be updated at
every clock cycle so that the wire colors will no longer be updated.
@ -168,7 +168,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_LightBulb_pin_A">Connection</string>
<string name="elem_LightBulb_pin_B">Connection</string>
<string name="elem_PolarityAwareLED">LED with two connections.</string>
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up,
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up
if the anode is connected to high and the cathode is connected to low.
This LED cannot be used as a pull-down resistor. It acts solely as a display element.
The shown resistor is only meant to symbolize the required series resistor to limit the current.</string>
@ -222,9 +222,8 @@ In the file howTo.md you can find more details about translations.
A separate window is opened for the text input.
</string>
<string name="elem_Keyboard_pin_C">Clock. A rising edge removes the oldest character from the buffer.</string>
<string name="elem_Keyboard_pin_en">If high the output D is active and one character is output.
It also enables the clock input.
</string>
<string name="elem_Keyboard_pin_en">If high, the output D is active and one character is output.
It also enables the clock input.</string>
<string name="elem_Keyboard_pin_D">The last typed character, or zero if no character is available.
Output is the 16 bit Java char value.
</string>
@ -641,8 +640,8 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Comparator_pin_a">Input a to compare.</string>
<string name="elem_Comparator_pin_b">Input b to compare.</string>
<string name="elem_Comparator_pin_=">Output is 1 if input a equals input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater then input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less then input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater than input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less than input b</string>
<string name="elem_Neg">Negation</string>
<string name="elem_Neg_short">Neg</string>
<string name="elem_Neg_pin_in">Input of the data word to be negated in 2th complement</string>

View File

@ -97,10 +97,9 @@ In the file howTo.md you can find more details about translations.
</string>
<string name="elem_XNOr">XNOr</string>
<string name="elem_XNOr_tt">A combination of XOR and NOT. The inputs are combined with the XOR operation.
The result of this operation than is inverted.
The result of this operation is then inverted.
It is also possible to use buses with several bits per input. In this case, the operation is applied to each
bit of the inputs.
</string>
bit of the inputs.</string>
<string name="elem_Not">Not</string>
<string name="elem_Not_tt">Inverts the input value. A 1 becomes a 0 and a 0 becomes 1.
It is also possible to use a bus with several bits per input. In this case, the operation is applied to each
@ -129,8 +128,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Out_tt">Can be used to display an output signal in a circuit.
This element is also used to connect a circuit to an embedding circuit.
In this case the connection is bidirectional.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.
</string>
Is also used to assign a pin number, if the code for a CPLD or FPGA is generated.</string>
<string name="elem_Out_pin_in">This value is used for the output connection.</string>
<string name="elem_LED">LED</string>
<string name="elem_LED_tt">A LED can be used to visualize an output value. Accepts a single bit.
@ -155,13 +153,12 @@ In the file howTo.md you can find more details about translations.
<string name="elem_DipSwitch_tt">Simple DIP switch that can output either high or low.</string>
<string name="elem_DipSwitch_pin_out">The output value of the switch.</string>
<string name="elem_Clock">Clock Input</string>
<string name="elem_Clock_tt">A clock signal. Its possible to control it by a real-time clock.
<string name="elem_Clock_tt">A clock signal. It's possible to control it by a real-time clock.
Depending on the complexity of the circuit, the clock frequency achieved may be less than the selected value.
If the frequency is greater than 50Hz, the graphic representation of the circuit will no longer be updated at
every clock cycle so that the wire colors will no longer be updated.
If the real-time clock is not activated, the clock can be controlled by mouse clicks.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.
</string>
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.</string>
<string name="elem_Clock_pin_C">Switches between 0 and 1 with the selected clock frequency.</string>
<string name="elem_Button">Button</string>
<string name="elem_Button_tt">A simple push button which goes back to its original state when it is released.
@ -196,7 +193,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_LightBulb_pin_A">Connection</string>
<string name="elem_LightBulb_pin_B">Connection</string>
<string name="elem_PolarityAwareLED">LED with two connections.</string>
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up,
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up
if the anode is connected to high and the cathode is connected to low.
This LED cannot be used as a pull-down resistor. It acts solely as a display element.
The shown resistor is only meant to symbolize the required series resistor to limit the current.</string>
@ -251,9 +248,8 @@ In the file howTo.md you can find more details about translations.
A separate window is opened for the text input.
</string>
<string name="elem_Keyboard_pin_C">Clock. A rising edge removes the oldest character from the buffer.</string>
<string name="elem_Keyboard_pin_en">If high the output D is active and one character is output.
It also enables the clock input.
</string>
<string name="elem_Keyboard_pin_en">If high, the output D is active and one character is output.
It also enables the clock input.</string>
<string name="elem_Keyboard_pin_D">The last typed character, or zero if no character is available.
Output is the 16 bit Java char value.
</string>
@ -770,8 +766,8 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Comparator_pin_a">Input a to compare.</string>
<string name="elem_Comparator_pin_b">Input b to compare.</string>
<string name="elem_Comparator_pin_=">Output is 1 if input a equals input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater then input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less then input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater than input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less than input b</string>
<string name="elem_Neg">Negation</string>
<string name="elem_Neg_short">Neg</string>
<string name="elem_Neg_pin_in">Input of the data word to be negated in 2th complement</string>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ In the file howTo.md you can find more details about translations.
bit of the inputs.</string>
<string name="elem_XNOr">XNOr</string>
<string name="elem_XNOr_tt">A combination of XOR and NOT. The inputs are combined with the XOR operation.
The result of this operation than is inverted.
The result of this operation is then inverted.
It is also possible to use buses with several bits per input. In this case, the operation is applied to each
bit of the inputs.</string>
<string name="elem_Not">Not</string>
@ -119,7 +119,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Out_tt">Can be used to display an output signal in a circuit.
This element is also used to connect a circuit to an embedding circuit.
In this case the connection is bidirectional.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.</string>
Is also used to assign a pin number, if the code for a CPLD or FPGA is generated.</string>
<string name="elem_Out_pin_in">This value is used for the output connection.</string>
<string name="elem_LED">LED</string>
<string name="elem_LED_tt">A LED can be used to visualize an output value. Accepts a single bit.
@ -132,7 +132,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_RGBLED_pin_G">The green color channel.</string>
<string name="elem_RGBLED_pin_B">The blue color channel.</string>
<string name="elem_PolarityAwareLED">LED with two connections.</string>
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up,
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up
if the anode is connected to high and the cathode is connected to low.
This LED cannot be used as a pull-down resistor. It acts solely as a display element.
The shown resistor is only meant to symbolize the required series resistor to limit the current.</string>
@ -148,7 +148,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_DipSwitch_tt">Simple DIP switch that can output either high or low.</string>
<string name="elem_DipSwitch_pin_out">The output value of the switch.</string>
<string name="elem_Clock">Clock Input</string>
<string name="elem_Clock_tt">A clock signal. Its possible to control it by a real-time clock.
<string name="elem_Clock_tt">A clock signal. It's possible to control it by a real-time clock.
Depending on the complexity of the circuit, the clock frequency achieved may be less than the selected value.
If the frequency is greater than 50Hz, the graphic representation of the circuit will no longer be updated at
every clock cycle so that the wire colors will no longer be updated.
@ -225,9 +225,8 @@ In the file howTo.md you can find more details about translations.
A separate window is opened for the text input.
</string>
<string name="elem_Keyboard_pin_C">Clock. A rising edge removes the oldest character from the buffer.</string>
<string name="elem_Keyboard_pin_en">If high the output D is active and one character is output.
It also enables the clock input.
</string>
<string name="elem_Keyboard_pin_en">If high, the output D is active and one character is output.
It also enables the clock input.</string>
<string name="elem_Keyboard_pin_D">The last typed character, or zero if no character is available.
Output is the 16 bit Java char value.
</string>
@ -641,8 +640,8 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Comparator_pin_a">Input a to compare.</string>
<string name="elem_Comparator_pin_b">Input b to compare.</string>
<string name="elem_Comparator_pin_=">Output is 1 if input a equals input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater then input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less then input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater than input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less than input b</string>
<string name="elem_Neg">Negation</string>
<string name="elem_Neg_short">Neg</string>
<string name="elem_Neg_tt">Negation in the 2th complement</string>

View File

@ -84,7 +84,7 @@ In the file howTo.md you can find more details about translations.
bit of the inputs.</string>
<string name="elem_XNOr">XNOr</string>
<string name="elem_XNOr_tt">A combination of XOR and NOT. The inputs are combined with the XOR operation.
The result of this operation than is inverted.
The result of this operation is then inverted.
It is also possible to use buses with several bits per input. In this case, the operation is applied to each
bit of the inputs.</string>
<string name="elem_Not">Not</string>
@ -112,7 +112,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Out_tt">Can be used to display an output signal in a circuit.
This element is also used to connect a circuit to an embedding circuit.
In this case the connection is bidirectional.
Is also used to assign an pin number, if code for a CPLD or FPGA is generated.</string>
Is also used to assign a pin number, if the code for a CPLD or FPGA is generated.</string>
<string name="elem_Out_pin_in">This value is used for the output connection.</string>
<string name="elem_LED">LED</string>
<string name="elem_LED_tt">A LED can be used to visualize an output value. Accepts a single bit.
@ -134,7 +134,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_DipSwitch_tt">Simple DIP switch that can output either high or low.</string>
<string name="elem_DipSwitch_pin_out">The output value of the switch.</string>
<string name="elem_Clock">Clock Input</string>
<string name="elem_Clock_tt">A clock signal. Its possible to control it by a real-time clock.
<string name="elem_Clock_tt">A clock signal. It's possible to control it by a real-time clock.
Depending on the complexity of the circuit, the clock frequency achieved may be less than the selected value.
If the frequency is greater than 50Hz, the graphic representation of the circuit will no longer be updated at
every clock cycle so that the wire colors will no longer be updated.
@ -168,7 +168,7 @@ In the file howTo.md you can find more details about translations.
<string name="elem_LightBulb_pin_A">Connection</string>
<string name="elem_LightBulb_pin_B">Connection</string>
<string name="elem_PolarityAwareLED">LED with two connections.</string>
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up,
<string name="elem_PolarityAwareLED_tt">LED with connections for the cathode and the anode. The LED lights up
if the anode is connected to high and the cathode is connected to low.
This LED cannot be used as a pull-down resistor. It acts solely as a display element.
The shown resistor is only meant to symbolize the required series resistor to limit the current.</string>
@ -215,7 +215,7 @@ In the file howTo.md you can find more details about translations.
This component buffers the input, which can then be read out.
A separate window is opened for the text input.</string>
<string name="elem_Keyboard_pin_C">Clock. A rising edge removes the oldest character from the buffer.</string>
<string name="elem_Keyboard_pin_en">If high the output D is active and one character is output.
<string name="elem_Keyboard_pin_en">If high, the output D is active and one character is output.
It also enables the clock input.</string>
<string name="elem_Keyboard_pin_D">The last typed character, or zero if no character is available.
Output is the 16 bit Java char value.</string>
@ -1506,8 +1506,8 @@ In the file howTo.md you can find more details about translations.
<string name="elem_Comparator_pin_a">Input a to compare.</string>
<string name="elem_Comparator_pin_b">Input b to compare.</string>
<string name="elem_Comparator_pin_=">Output is 1 if input a equals input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater then input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less then input b</string>
<string name="elem_Comparator_pin_&gt;">Output is 1 if input a is greater than input b</string>
<string name="elem_Comparator_pin_&lt;">Output is 1 if input a is less than input b</string>
<string name="elem_Neg">Negation</string>
<string name="elem_Neg_short">Neg</string>
<string name="elem_Neg_pin_in">Input of the data word to be negated in 2th complement</string>

View File

@ -24,6 +24,10 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class LanguageUpdater {
public static final Format FORMAT = Format.getPrettyFormat()
.setIndent(" ")
.setTextMode(Format.TextMode.PRESERVE);
private static final String COMMENT_REF = " IMPORTANT\nDo not edit this file directly!\n" +
"This makes it very difficult for me to continue to maintain the translation.\n" +
"Pull requests in which this file is modified cannot be accepted.\n" +
@ -37,6 +41,7 @@ public class LanguageUpdater {
private final Document ref;
private final File langFileName;
private final File refFileName;
private final TypoFixer typoFixer;
private int modified;
private LanguageUpdater(File sourceFilename) throws JDOMException, IOException {
@ -47,6 +52,8 @@ public class LanguageUpdater {
if (!langPath.exists())
throw new IOException("lang folder not found!");
typoFixer = new TypoFixer(langPath, "lang_" + langName + "_ref.xml");
langFileName = new File(langPath, "lang_" + langName + ".xml");
refFileName = new File(langPath, "lang_" + langName + "_ref.xml");
lang = new SAXBuilder().build(langFileName);
@ -73,9 +80,13 @@ public class LanguageUpdater {
modified++;
break;
case "typo":
System.out.println("key: " + key);
System.out.println("en: " + enText);
throw new IOException("There is a typo in the english translation!");
typoFixer.fix(key, enText);
if (!contains(lang, key)) {
add(ref, key, enText);
add(lang, key, transText);
modified++;
break;
}
case "modified":
if (replace(lang, key, transText)) {
replace(ref, key, enText);
@ -169,13 +180,20 @@ public class LanguageUpdater {
throw new IOException("key " + key + " not found in " + xml);
}
private boolean contains(Document xml, String key) {
for (Element e : xml.getRootElement().getChildren()) {
String k = e.getAttributeValue("name");
if (k.equals(key))
return true;
}
return false;
}
private void update() throws IOException {
typoFixer.update();
if (modified > 0) {
Format format = Format.getPrettyFormat()
.setIndent(" ")
.setTextMode(Format.TextMode.PRESERVE);
new XMLOutputter(format).output(ref, new FileOutputStream(refFileName));
new XMLOutputter(format).output(lang, new FileOutputStream(langFileName));
new XMLOutputter(FORMAT).output(ref, new FileOutputStream(refFileName));
new XMLOutputter(FORMAT).output(lang, new FileOutputStream(langFileName));
System.out.println(modified + " keys updated!");
} else {
System.out.println("no modification found!");
@ -183,7 +201,9 @@ public class LanguageUpdater {
}
public static void main(String[] args) throws JDOMException, IOException {
if (args.length == 1) {
new LanguageUpdater(new File(args[0])).update();
} else {
File src = new File("/home/hneemann/Dokumente/Java/digital/src");
if (!src.exists()) {
JFileChooser dc = new JFileChooser();
@ -206,5 +226,6 @@ public class LanguageUpdater {
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
new LanguageUpdater(fc.getSelectedFile()).update();
}
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2021 Helmut Neemann.
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.lang;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.XMLOutputter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static de.neemann.digital.lang.LanguageUpdater.FORMAT;
public class TypoFixer {
private final File langPath;
private final String fileToIgnore;
private HashMap<File, Document> documents;
public TypoFixer(File langPath, String fileToIgnore) {
this.langPath = langPath;
this.fileToIgnore = fileToIgnore;
}
/**
* Replaces all en text fragments of key key with the newEnText.
*
* @param key the key
* @param newEnText the corrected en text
*/
public void fix(String key, String newEnText) throws IOException, JDOMException {
if (documents == null)
initDocuments();
for (Map.Entry<File, Document> e : documents.entrySet()) {
System.out.println("fixed typo " + key + " in " + e.getKey());
replace(e.getValue(), key, newEnText);
}
}
private void initDocuments() throws IOException, JDOMException {
String[] list = langPath.list((file, name) -> name.endsWith("_ref.xml") && !name.equals(fileToIgnore));
documents = new HashMap<>();
load("lang_en.xml");
for (String n : list)
load(n);
}
private void load(String name) throws IOException, JDOMException {
File f = new File(langPath, name);
Document doc = new SAXBuilder().build(f);
documents.put(f, doc);
}
static boolean replace(Document xml, String key, String text) throws IOException {
for (Element e : xml.getRootElement().getChildren()) {
String k = e.getAttributeValue("name");
if (k.equals(key)) {
if (e.getText().trim().equals(text.trim())) {
return false;
} else {
e.setText(text);
return true;
}
}
}
throw new IOException("key " + key + " not found in " + xml);
}
public void update() throws IOException {
if (documents != null)
for (Map.Entry<File, Document> e : documents.entrySet())
new XMLOutputter(FORMAT).output(e.getValue(), new FileOutputStream(e.getKey()));
}
}