Entpacken (zum Laden) der Sprachdatei beim Start implementiert

This commit is contained in:
2023-07-20 01:32:55 +02:00
parent 02118d0887
commit 9bdd2ca394
16 changed files with 62 additions and 61 deletions

View File

@@ -14,5 +14,4 @@ Diese Anwendung soll helfen
* vordefinierte Platzhalter
* nutzerdefinierte Platzhalter
* Löschen von Profilen
* Beispiele für Profile
* einfacheres Starten mit der richtigen Sprache
* Beispiele für Profile

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>BelegScanner</groupId>
<artifactId>BelegScanner</artifactId>
<version>1.0.11</version>
<version>1.1.0</version>
<name>BelegScanner</name>
<packaging>jar</packaging>
@@ -120,7 +120,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>de.srsoftware.web4rail.Application</mainClass>
<mainClass>de.srsoftware.belegscanner.Application</mainClass>
</configuration>
</plugin>
<plugin>

View File

@@ -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;
*
*/
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.

View File

@@ -1,5 +1,10 @@
package de.srsoftware.belegscanner;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
@@ -8,11 +13,6 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* JSON-based Configuration manager for the Application.

View File

@@ -22,8 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -32,8 +30,6 @@ import java.util.Vector;
import java.util.stream.Stream;
import static de.srsoftware.belegscanner.Application.t;
import static de.srsoftware.belegscanner.Constants.DEFAULT_HEIGHT;
import static de.srsoftware.belegscanner.Constants.DEFAULT_WIDTH;
import static de.srsoftware.belegscanner.Constants.JPG;
import static de.srsoftware.belegscanner.Constants.OCR;
import static de.srsoftware.belegscanner.Constants.PDF;

View File

@@ -1,7 +1,14 @@
package de.srsoftware.belegscanner.gui;
import static de.srsoftware.belegscanner.Application.t;
import de.srsoftware.belegscanner.Worker;
import de.srsoftware.belegscanner.listeners.ProjectListener;
import de.srsoftware.belegscanner.model.ScanProject;
import de.srsoftware.belegscanner.model.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import java.awt.*;
import java.awt.event.ActionListener;
import java.io.FilenameFilter;
@@ -10,15 +17,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import de.srsoftware.belegscanner.Worker;
import de.srsoftware.belegscanner.listeners.ProjectListener;
import de.srsoftware.belegscanner.model.ScanProject;
import de.srsoftware.belegscanner.model.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static de.srsoftware.belegscanner.Application.t;
/**
*

View File

@@ -12,10 +12,8 @@ import java.awt.event.KeyEvent;
import static de.srsoftware.belegscanner.Application.t;
import static de.srsoftware.belegscanner.Constants.DEFAULT_HEIGHT;
import static de.srsoftware.belegscanner.Constants.DEFAULT_WIDTH;
import static java.awt.BorderLayout.CENTER;
import static java.awt.BorderLayout.NORTH;
import static java.awt.BorderLayout.SOUTH;
import static java.awt.BorderLayout.WEST;
import static javax.swing.BoxLayout.X_AXIS;
import static javax.swing.BoxLayout.Y_AXIS;

View File

@@ -8,7 +8,6 @@ import org.icepdf.ri.common.views.DocumentViewController;
import javax.swing.*;
import java.awt.*;
import java.nio.file.Path;
public class Preview extends JPanel {
private final SwingController pdfViewer;

View File

@@ -4,8 +4,8 @@ import de.srsoftware.belegscanner.Worker;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
import static de.srsoftware.belegscanner.Application.t;
import static java.awt.BorderLayout.CENTER;

View File

@@ -3,14 +3,13 @@ package de.srsoftware.belegscanner.gui;
import de.srsoftware.belegscanner.Worker;
import javax.swing.*;
import java.util.List;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import static de.srsoftware.belegscanner.Application.t;
import static java.awt.BorderLayout.CENTER;
import static java.awt.BorderLayout.NORTH;
import static java.awt.BorderLayout.WEST;
public class RotationSelector extends JPanel {

View File

@@ -1,21 +1,17 @@
package de.srsoftware.belegscanner.gui;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import de.srsoftware.belegscanner.Application;
import de.srsoftware.belegscanner.Worker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.srsoftware.belegscanner.Application;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
/**
* Simple status barwith updateable text.

View File

@@ -1,24 +1,21 @@
package de.srsoftware.belegscanner.gui;
import java.awt.Component;
import java.awt.Dimension;
import de.srsoftware.belegscanner.Worker;
import de.srsoftware.tools.gui.DateChooser;
import de.srsoftware.tools.gui.SelectComboBox;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import de.srsoftware.belegscanner.Worker;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.srsoftware.tools.gui.DateChooser;
import de.srsoftware.tools.gui.SelectComboBox;
import static de.srsoftware.belegscanner.Application.*;
import static de.srsoftware.belegscanner.Application.t;
import static javax.swing.BoxLayout.X_AXIS;
import static javax.swing.BoxLayout.Y_AXIS;

View File

@@ -1,6 +1,5 @@
package de.srsoftware.belegscanner.gui;
import de.srsoftware.belegscanner.Configuration;
import de.srsoftware.belegscanner.Worker;
import javax.swing.*;
@@ -9,13 +8,11 @@ import java.util.ArrayList;
import java.util.List;
import static de.srsoftware.belegscanner.Application.t;
import static de.srsoftware.belegscanner.Constants.CONFIG_TARGET;
import static de.srsoftware.belegscanner.Constants.JPG;
import static de.srsoftware.belegscanner.Constants.OCR;
import static de.srsoftware.belegscanner.Constants.PDF;
import static java.awt.BorderLayout.CENTER;
import static java.awt.BorderLayout.NORTH;
import static java.awt.BorderLayout.WEST;
import static javax.swing.BoxLayout.X_AXIS;
public class TypeSelector extends JPanel {