Commit e222bf99 authored by Matthias Betz's avatar Matthias Betz
Browse files

moved version string to Localization

parent f3da76cf
Pipeline #1012 passed with stage
in 1 minute and 52 seconds
......@@ -30,7 +30,7 @@
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
......@@ -53,4 +53,13 @@
<artifactId>proj4j</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
......@@ -27,6 +27,8 @@ import java.util.ResourceBundle;
*
*/
public class Localization {
public static final String VERSION = "CityDoctorValidation.Version";
private static ResourceBundle bundle;
......
CityDoctorValidation.Version=${project.version}
DistanceError.distanceFromPlane=distance from plane
AboutDialog.developedBy=Developed by
AboutDialog.contact=Contact
......
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
/**
* Provides access to message strings in different languages.
*
* @author Matthias Betz - 12bema1bif@hft-stuttgart.de
* @version 1.0
*
*/
public class CDVMessages {
public static final String MISSING_SOURCE_FILE = "ArgumentParser.MissingSourceFile";
public static final String INVALID_PARAMETER = "ArgumentParser.InvalidParameter";
public static final String VERSION = "CityDoctorValidation.Version";
private static final String BUNDLE_NAME = "de.hft.stuttgart.citydoctor2.cdvmessages";
private static final ResourceBundle RESOURCE_BUNDLE;
static {
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault());
}
/**
* Gives the message string for the given key based on the default locale.
*
* @param key
* the key for the message
* @return localized message.
*/
public static String getString(String key) {
return RESOURCE_BUNDLE.getString(key);
}
/**
* Constructs a string out of the key and the given parameters with the
* MessageFormatter.
*
* @param key
* the key for the message
* @param params
* the parameters for the message
* @return the localized message with the parameters substituted.
* @see MessageFormat#format(String, Object...);
*/
public static String getString(String key, Object... params) {
String msg = getString(key);
return MessageFormat.format(msg, params);
}
private CDVMessages() {
}
}
......@@ -32,7 +32,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.CDVMessages;
import de.hft.stuttgart.citydoctor2.check.CheckConfiguration;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -64,6 +63,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.utils.Localization;
/**
* Report for creating a XML report out of a stream of feature results
......@@ -105,7 +105,7 @@ public class XmlStreamReporter implements StreamReporter {
env.setJavaVmVersion(System.getProperties().getProperty("java.version"));
env.setOsArch(System.getProperties().getProperty("os.arch"));
env.setOsName(System.getProperties().getProperty("os.name"));
env.setValidationVersion(CDVMessages.getString(CDVMessages.VERSION));
env.setValidationVersion(Localization.getText(Localization.VERSION));
return header;
}
......
......@@ -33,7 +33,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.CDVMessages;
import de.hft.stuttgart.citydoctor2.check.CheckConfiguration;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -57,6 +56,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.reporting.StreamReporter;
import de.hft.stuttgart.citydoctor2.utils.Localization;
/**
* Reporter to create a PDF report out of a stream of feature results
......@@ -156,7 +156,7 @@ public class PdfStreamReporter implements StreamReporter {
env.addTextElement("The checks were executed under the following environment:");
Table t = new Table(2);
t.setTitle("Name", "Value");
t.addRow("City Doctor Version", CDVMessages.getString(CDVMessages.VERSION));
t.addRow("City Doctor Version", Localization.getText(Localization.VERSION));
t.addRow("Java VM-Version", System.getProperties().getProperty("java.vm.version"));
t.addRow("Java VM-Vendor", System.getProperties().getProperty("java.vm.vendor"));
t.addRow("Java Version", System.getProperties().getProperty("java.version"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment