|
|
|
@ -1,10 +1,15 @@
@@ -1,10 +1,15 @@
|
|
|
|
|
package de.srsoftware.belegscanner; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
import de.srsoftware.belegscanner.gui.MainFrame; |
|
|
|
|
import de.srsoftware.tools.translations.Translation; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Application to scan receipts : entry point |
|
|
|
|
* |
|
|
|
@ -12,14 +17,30 @@ import de.srsoftware.tools.translations.Translation;
@@ -12,14 +17,30 @@ import de.srsoftware.tools.translations.Translation;
|
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public class Application { |
|
|
|
|
private static String locale = Locale.getDefault().getLanguage().toLowerCase(); |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
|
extractTranslation(); |
|
|
|
|
Configuration config = new Configuration(Constants.APPLICATION_NAME); |
|
|
|
|
MainFrame app = new MainFrame(config); |
|
|
|
|
app.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE); |
|
|
|
|
app.checkDependencies(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void extractTranslation() throws IOException { |
|
|
|
|
var name = String.join(".", Application.class.getSimpleName(), locale, "translation"); |
|
|
|
|
var path = String.join("/", "", "translations", name); |
|
|
|
|
URL res = Application.class.getResource(path); |
|
|
|
|
if (res != null && res.toString().contains("jar!")) try { |
|
|
|
|
var outFile = new File(Application.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile().toPath().resolve(name).toFile(); |
|
|
|
|
try (var translation = res.openStream(); var file = new FileOutputStream(outFile)) { |
|
|
|
|
translation.transferTo(file); |
|
|
|
|
} |
|
|
|
|
} catch (URISyntaxException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Translate a text. |
|
|
|
|
* @param txt the text to be translated. |
|
|
|
|