mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-10 13:26:43 -04:00
Improved the translation howTo.md.
This commit is contained in:
parent
3efac3274a
commit
25b73586e4
@ -84,7 +84,8 @@ translate than the [files](https://github.com/hneemann/Digital/blob/master/src/m
|
|||||||
used directly by Digital. So you don't have to deal with GitHub or the
|
used directly by Digital. So you don't have to deal with GitHub or the
|
||||||
Java source code. Simply add the respective translation of the English
|
Java source code. Simply add the respective translation of the English
|
||||||
text to this file and send it back to [me](mailto:digital-simulator@web.de).
|
text to this file and send it back to [me](mailto:digital-simulator@web.de).
|
||||||
If you want to know how to create the necessary files yourself, see [here](https://github.com/hneemann/Digital/blob/master/src/main/resources/lang/lang.xml).
|
If you want to know how to create the necessary files yourself, see
|
||||||
|
[here](https://github.com/hneemann/Digital/blob/master/src/main/resources/lang/howTo.md).
|
||||||
|
|
||||||
## Comments ##
|
## Comments ##
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
= Translations =
|
## Translations ##
|
||||||
|
|
||||||
If someone wants to contribute a new translation to Digital,
|
If someone wants to contribute a new translation to Digital,
|
||||||
the problem is not only to create the new translation.
|
the problem is not only to create the new translation.
|
||||||
@ -25,26 +25,50 @@ evolves after the new translation is completed:
|
|||||||
play.
|
play.
|
||||||
|
|
||||||
If a new translation is added not only the translated language file
|
If a new translation is added not only the translated language file
|
||||||
is added (e.g. lang_pt.xml) but also a reference file (lang_pt_ref.xml).
|
is added (e.g. lang_pt.xml) but also a file (lang_pt_ref.xml).
|
||||||
The latter one is the reference file and is a copy of the original
|
The latter one is the reference file and is a copy of the original
|
||||||
English translation (lang_en.xml).
|
English translation (lang_en.xml).
|
||||||
When it is necessary to change a language text, it is possible to
|
When it is necessary to change a language text, it is possible to
|
||||||
detect that afterwards: It is possible to compare the strings
|
detect that afterwards: It is possible to compare the strings
|
||||||
in the english translation with the content of the reference file
|
in the english translation with the content of the reference file
|
||||||
which is also English.
|
which is also English.
|
||||||
If the strings are not identical, the translation needs to be reworked.
|
If the strings are not identical, the translation needs to be revised.
|
||||||
To do so, one has to update the translation and the English text in
|
To do so, one has to update the translation and the English text in
|
||||||
the reference file.
|
the reference file.
|
||||||
|
|
||||||
= How to find keys that need to be revised? =
|
## How to add a new Language ##
|
||||||
|
|
||||||
|
Add the new language to the file "Digital/src/main/resources/lang/lang.xml"
|
||||||
|
Then start the language test by running
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn -Dtest=TestLang test
|
||||||
|
```
|
||||||
|
|
||||||
|
Now all necessary files are created. In the target folder you can
|
||||||
|
find a diff file that contains all missing keys. Now you can start
|
||||||
|
adding your translation. **Copy this file to another location! The file
|
||||||
|
will be overwritten every time Digital is built!**
|
||||||
|
Use the Language Importer
|
||||||
|
"Digital/src/test/java/de/neemann/digital/lang/LanguageUpdater.java" to
|
||||||
|
import your work. It is possible to import only partially translated files.
|
||||||
|
This helps you to test your translation step by step.
|
||||||
|
|
||||||
|
## How to find keys that need to be revised later on ##
|
||||||
|
|
||||||
Digital contains some test cases that check the consistency of
|
Digital contains some test cases that check the consistency of
|
||||||
the translations. The test class "TestLang" checks the consistency
|
the translations. The test class "TestLang" checks the consistency
|
||||||
of the language files, which I cannot maintain myself.
|
of the language files.
|
||||||
|
|
||||||
The easiest way to run the test case is to install maven.
|
The easiest way to run the test case is to install maven.
|
||||||
Then you can start the test case by typing:
|
Then you can start the test case by typing:
|
||||||
|
|
||||||
|
```
|
||||||
mvn -Dtest=TestLang test
|
mvn -Dtest=TestLang test
|
||||||
|
```
|
||||||
|
|
||||||
This gives you a report of the state of the translations.
|
This gives you a diff file for each language. This file contains all
|
||||||
|
keys that have been added or modified. You can now add or update the
|
||||||
|
language fragments contained in this file. After that start the class
|
||||||
|
"Digital/src/test/java/de/neemann/digital/lang/LanguageUpdater.java".
|
||||||
|
This allows you to select the reworked diff file and import it.
|
@ -101,9 +101,22 @@ public class LanguageUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws JDOMException, IOException {
|
public static void main(String[] args) throws JDOMException, IOException {
|
||||||
|
JFileChooser dc = new JFileChooser();
|
||||||
|
dc.setDialogTitle("Select the Digital \"src\" Folder");
|
||||||
|
dc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
File src = null;
|
||||||
|
if (dc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
src = dc.getSelectedFile();
|
||||||
|
System.setProperty("testdata", new File(src, "test/resources").getPath());
|
||||||
|
}
|
||||||
|
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setDialogTitle("Select the updated diff File");
|
||||||
fc.addChoosableFileFilter(new FileNameExtensionFilter("xml", "xml"));
|
fc.addChoosableFileFilter(new FileNameExtensionFilter("xml", "xml"));
|
||||||
fc.setSelectedFile(new File("/home/hneemann/Dokumente/Java/digital/target/language_pt.xml"));
|
if (src != null) {
|
||||||
|
final File s = new File(src.getParentFile(), "target/lang_diff_pt.xml");
|
||||||
|
fc.setSelectedFile(s);
|
||||||
|
}
|
||||||
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
|
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
|
||||||
new LanguageUpdater(fc.getSelectedFile()).update();
|
new LanguageUpdater(fc.getSelectedFile()).update();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user