diff --git a/README.md b/README.md index 86732d745..e278fb9e7 100644 --- a/README.md +++ b/README.md @@ -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 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). -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 ## diff --git a/src/main/resources/lang/howTo.txt b/src/main/resources/lang/howTo.md similarity index 60% rename from src/main/resources/lang/howTo.txt rename to src/main/resources/lang/howTo.md index 7caeda2fc..fe4f34979 100644 --- a/src/main/resources/lang/howTo.txt +++ b/src/main/resources/lang/howTo.md @@ -1,4 +1,4 @@ -= Translations = +## Translations ## If someone wants to contribute a new translation to Digital, the problem is not only to create the new translation. @@ -25,26 +25,50 @@ evolves after the new translation is completed: play. 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 English translation (lang_en.xml). When it is necessary to change a language text, it is possible to detect that afterwards: It is possible to compare the strings in the english translation with the content of the reference file 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 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 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. Then you can start the test case by typing: +``` 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. diff --git a/src/test/java/de/neemann/digital/lang/LanguageUpdater.java b/src/test/java/de/neemann/digital/lang/LanguageUpdater.java index 6eb347aa8..50ef23ee3 100644 --- a/src/test/java/de/neemann/digital/lang/LanguageUpdater.java +++ b/src/test/java/de/neemann/digital/lang/LanguageUpdater.java @@ -101,9 +101,22 @@ public class LanguageUpdater { } 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(); + fc.setDialogTitle("Select the updated diff File"); 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) new LanguageUpdater(fc.getSelectedFile()).update(); }