[fixes #825] Add translation keys for update checking

This commit is contained in:
Sibo Van Gool 2022-01-26 03:04:37 +01:00
parent de646e80a9
commit 581f0c4e2c
4 changed files with 28 additions and 18 deletions

View File

@ -333,9 +333,19 @@ generalprefs.lbl.languageEffect = The language will change the next time you sta
! Software update checker
update.dlg.error.title = Unable to retrieve update information
update.dlg.error = An error occurred while communicating with the server.
update.dlg.exception.title = Could not check for updates
update.dlg.latestVersion.title = No updates available
update.dlg.latestVersion = You are running the latest version of OpenRocket, version %s.
update.dlg.newerVersion.title = Newer version detected
update.dlg.newerVersion = You are either running a test/unofficial release of OpenRocket, or you have a time machine and are running an official release from the future.\n\nYour version: %s\nLatest official release: %s
update.dlg.updateAvailable.title = Update available
update.dlg.updateAvailable.txtPane.title = OpenRocket version %s available!
update.dlg.updateAvailable.txtPane.yourVersion = Your current version: %s
update.dlg.updateAvailable.txtPane.changelog = Changelog
update.dlg.updateAvailable.txtPane.readMore = Read more on GitHub
update.fetcher.badResponse = Bad response code from server: %d
update.fetcher.badConnection = Could not connect to the GitHub server. Please check your internet connection.
update.fetcher.malformedURL = Malformed URL: %s
! Simulation edit dialog
simedtdlg.but.runsimulation = Run simulation

View File

@ -229,8 +229,8 @@ public class UpdateInfoRetriever {
// Invalid response code
if (status != 200) {
log.warn("Bad response code for update checker: " + status);
throw new UpdateCheckerException("Bad response code for update checker: " + status); // TODO: replace by trans
log.warn(String.format("Bad response code from server: %d", status));
throw new UpdateCheckerException(String.format(trans.get("update.fetcher.badResponse"), status));
}
// Read the response JSON data into a StringBuilder
@ -257,12 +257,12 @@ public class UpdateInfoRetriever {
}
} catch (UnknownHostException | SocketTimeoutException | ConnectException e) {
log.warn(String.format("Could not connect to URL: %s. Please check your internet connection.", urlLink));
throw new UpdateCheckerException("Could not connect to the GitHub server. Please check your internet connection."); // TODO: replace by trans
throw new UpdateCheckerException(trans.get("update.fetcher.badConnection"));
} catch (MalformedURLException e) {
log.warn("Malformed URL for update checker: " + urlLink);
throw new UpdateCheckerException("Malformed URL for update checker: " + urlLink); // TODO: replace by trans
log.warn("Malformed URL: " + urlLink);
throw new UpdateCheckerException(String.format(trans.get("update.fetcher.malformedURL"), urlLink));
} catch (IOException e) {
throw new UpdateCheckerException(String.format("Exception - %s: %s", e, e.getMessage())); // TODO: replace by trans
throw new UpdateCheckerException(String.format("Exception - %s: %s", e, e.getMessage()));
} finally { // Close the connection to the release page
if (connection != null) {
try {

View File

@ -41,7 +41,7 @@ public class UpdateInfoDialog extends JDialog {
public UpdateInfoDialog(UpdateInfo info) {
//// OpenRocket update available
super(null, "Update OpenRocket", ModalityType.APPLICATION_MODAL); // TODO: replace with trans
super(null, trans.get("update.dlg.updateAvailable.title"), ModalityType.APPLICATION_MODAL);
JPanel panel = new JPanel(new MigLayout("fill"));
@ -59,13 +59,13 @@ public class UpdateInfoDialog extends JDialog {
// OpenRocket version available!
sb.append("<html>");
sb.append(String.format("<h1>OpenRocket version %s available!</h1>", release.getReleaseName()));
sb.append(String.format("<h1>%s</h1>", String.format(trans.get("update.dlg.updateAvailable.txtPane.title"), release.getReleaseName())));
// Your version
sb.append(String.format("<i>Your current version: %s </i> <br><br>", BuildProperties.getVersion()));
sb.append(String.format("<i>%s</i> <br><br>", String.format(trans.get("update.dlg.updateAvailable.txtPane.yourVersion"), BuildProperties.getVersion())));
// Changelog
sb.append("<h2>Changelog</h2>"); // TODO: replace with trans
sb.append(String.format("<h2>%s</h2>", trans.get("update.dlg.updateAvailable.txtPane.changelog")));
String releaseNotes = release.getReleaseNotes();
releaseNotes = releaseNotes.replaceAll("^\"|\"$", ""); // Remove leading and trailing quotations
sb.append(MarkdownUtil.toHtml(releaseNotes)).append("<br><br>");
@ -73,7 +73,7 @@ public class UpdateInfoDialog extends JDialog {
// GitHub link
String releaseURL = release.getReleaseURL();
releaseURL = releaseURL.replaceAll("^\"|\"$", ""); // Remove leading and trailing quotations
sb.append(String.format("<a href='%s'>Read more on GitHub</a>", releaseURL));
sb.append(String.format("<a href='%s'>%s</a>", releaseURL, trans.get("update.dlg.updateAvailable.txtPane.readMore")));
sb.append("</html>");
textPane.addHyperlinkListener(new HyperlinkListener() {
@Override

View File

@ -307,7 +307,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
if (info.getException() != null) {
JOptionPane.showMessageDialog(this,
info.getException().getMessage(),
"Could not check for updates", JOptionPane.WARNING_MESSAGE, null); // TODO: replace by trans
trans.get("update.dlg.exception.title"), JOptionPane.WARNING_MESSAGE, null);
return;
}
@ -324,11 +324,11 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
break;
case NEWER:
JOptionPane.showMessageDialog(this,
//// You are running the latest version of OpenRocket.
String.format("<html><body><p style='width: %dpx'>%s", 400, String.format("You are either running a test/unofficial release of OpenRocket, or you have a time machine and are running an official release from the future.\n\nYour version: %s\nLatest official release: %s",
BuildProperties.getVersion(), release.getReleaseName())), // TODO: trans
//// No updates available
"Newer version", JOptionPane.INFORMATION_MESSAGE, null); // TODO: trans
//// You are running a newer version than the latest official release
String.format("<html><body><p style='width: %dpx'>%s", 400, String.format(trans.get("update.dlg.newerVersion"),
BuildProperties.getVersion(), release.getReleaseName())),
//// Newer version detected
trans.get("update.dlg.newerVersion.title"), JOptionPane.INFORMATION_MESSAGE, null);
break;
case OLDER:
UpdateInfoDialog infoDialog = new UpdateInfoDialog(info);