Added localization support for Replay Mod API error messages
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||
import eu.crushedpixel.replaymod.api.client.holders.ApiError;
|
||||
import eu.crushedpixel.replaymod.api.client.holders.Category;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
@@ -85,7 +86,7 @@ public class FileUploader {
|
||||
uploading = false;
|
||||
current = 0;
|
||||
cancel = false;
|
||||
parent.onFinishUploading(false, "Upload has been canceled");
|
||||
parent.onFinishUploading(false, I18n.format("replaymod.gui.upload.canceled"));
|
||||
fis.close();
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +101,7 @@ public class FileUploader {
|
||||
|
||||
boolean success = false;
|
||||
int responseCode = con.getResponseCode();
|
||||
InputStream is = null;
|
||||
InputStream is;
|
||||
if(responseCode == 200) {
|
||||
success = true;
|
||||
is = con.getInputStream();
|
||||
@@ -119,15 +120,13 @@ public class FileUploader {
|
||||
json += r.readLine();
|
||||
}
|
||||
ApiError error = gson.fromJson(json, ApiError.class);
|
||||
info = error.getDesc();
|
||||
info = error.getTranslatedDesc();
|
||||
System.out.println(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
con.disconnect();
|
||||
|
||||
if(info == null) info = "An unknown error occured";
|
||||
if(info == null) info = I18n.format("replaymod.gui.unknownerror");
|
||||
|
||||
parent.onFinishUploading(success, info);
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package eu.crushedpixel.replaymod.api.client.holders;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
public class ApiError {
|
||||
|
||||
private int id;
|
||||
private String desc;
|
||||
private String key;
|
||||
private String[] objects;
|
||||
|
||||
public ApiError(int id, String desc) {
|
||||
this.id = id;
|
||||
this.desc = desc;
|
||||
@@ -25,5 +30,7 @@ public class ApiError {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
|
||||
public String getTranslatedDesc() {
|
||||
return I18n.format(key, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
replaymod.title=Replay Mod
|
||||
|
||||
#Website API translations
|
||||
replaymod.api.parammissing=Required parameter missing: %1$s
|
||||
replaymod.api.invalidvalue=Invalid value passed for parameter %1$s - Possible values: %2$s
|
||||
replaymod.api.invalidlogin=Invalid login data provided
|
||||
replaymod.api.invalidauthkey=Invalid authentication key provided
|
||||
replaymod.api.notenoughspace=Not enough space left to upload this file. Consider purchasing Premium on ReplayMod.com
|
||||
replaymod.api.invalidfile=This file is invalid
|
||||
replaymod.api.fileduplicate=This file has already been uploaded
|
||||
replaymod.api.filenoexist=This file does not exist
|
||||
replaymod.api.nopermissions=You don't have permission to access this file
|
||||
replaymod.api.alreadyrated=You already rated this file
|
||||
replaymod.api.usernoexist=This user does not exist
|
||||
replaymod.api.invalidcategory=Invalid file category
|
||||
replaymod.api.nofilesuploaded=No files uploaded
|
||||
replaymod.api.toomanyvalues=Too many values passed for %1$s
|
||||
replaymod.api.noparameters=At least one parameter required. Parameters: %1$s
|
||||
replaymod.api.invalidfilename=File name must be between 5 and 30 characters long
|
||||
replaymod.api.unknownlang=This language has not been translated
|
||||
replaymod.api.zippingerror=An error occured while zipping the language files
|
||||
replaymod.api.usernameexists=This username is already taken
|
||||
replaymod.api.mailexists=This email address is already linked to an account
|
||||
|
||||
|
||||
#All of the chat messages
|
||||
replaymod.chat.recordingstarted=Recording started
|
||||
replaymod.chat.recordingfailed=Failed to start recording
|
||||
@@ -42,6 +65,8 @@ replaymod.gui.delete=Delete
|
||||
replaymod.gui.recording=Recording
|
||||
replaymod.gui.speed=Speed
|
||||
|
||||
replaymod.gui.unknownerror=An unknown error occured
|
||||
|
||||
replaymod.gui.exit=Exit Replay
|
||||
replaymod.gui.java=Java 1.7 or newer required
|
||||
replaymod.gui.morereplays=At least one Replay required
|
||||
@@ -88,6 +113,7 @@ replaymod.gui.upload.cancel=Cancel Upload
|
||||
replaymod.gui.upload.tagshint=Tags separated by comma
|
||||
replaymod.gui.upload.uploading=Uploading...
|
||||
replaymod.gui.upload.success=File has been successfully uploaded
|
||||
replaymod.gui.upload.canceled=Upload has been canceled
|
||||
|
||||
#Replay Editor
|
||||
replaymod.gui.editor.replayfile=Replay File
|
||||
|
||||
Reference in New Issue
Block a user