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.ApiError;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.Category;
|
import eu.crushedpixel.replaymod.api.client.holders.Category;
|
||||||
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@@ -85,7 +86,7 @@ public class FileUploader {
|
|||||||
uploading = false;
|
uploading = false;
|
||||||
current = 0;
|
current = 0;
|
||||||
cancel = false;
|
cancel = false;
|
||||||
parent.onFinishUploading(false, "Upload has been canceled");
|
parent.onFinishUploading(false, I18n.format("replaymod.gui.upload.canceled"));
|
||||||
fis.close();
|
fis.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ public class FileUploader {
|
|||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
int responseCode = con.getResponseCode();
|
int responseCode = con.getResponseCode();
|
||||||
InputStream is = null;
|
InputStream is;
|
||||||
if(responseCode == 200) {
|
if(responseCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
is = con.getInputStream();
|
is = con.getInputStream();
|
||||||
@@ -119,15 +120,13 @@ public class FileUploader {
|
|||||||
json += r.readLine();
|
json += r.readLine();
|
||||||
}
|
}
|
||||||
ApiError error = gson.fromJson(json, ApiError.class);
|
ApiError error = gson.fromJson(json, ApiError.class);
|
||||||
info = error.getDesc();
|
info = error.getTranslatedDesc();
|
||||||
System.out.println(info);
|
System.out.println(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
|
|
||||||
if(info == null) info = "An unknown error occured";
|
if(info == null) info = I18n.format("replaymod.gui.unknownerror");
|
||||||
|
|
||||||
parent.onFinishUploading(success, info);
|
parent.onFinishUploading(success, info);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package eu.crushedpixel.replaymod.api.client.holders;
|
package eu.crushedpixel.replaymod.api.client.holders;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
public class ApiError {
|
public class ApiError {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
private String key;
|
||||||
|
private String[] objects;
|
||||||
|
|
||||||
public ApiError(int id, String desc) {
|
public ApiError(int id, String desc) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
@@ -25,5 +30,7 @@ public class ApiError {
|
|||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTranslatedDesc() {
|
||||||
|
return I18n.format(key, objects);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,28 @@
|
|||||||
replaymod.title=Replay Mod
|
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
|
#All of the chat messages
|
||||||
replaymod.chat.recordingstarted=Recording started
|
replaymod.chat.recordingstarted=Recording started
|
||||||
replaymod.chat.recordingfailed=Failed to start recording
|
replaymod.chat.recordingfailed=Failed to start recording
|
||||||
@@ -42,6 +65,8 @@ replaymod.gui.delete=Delete
|
|||||||
replaymod.gui.recording=Recording
|
replaymod.gui.recording=Recording
|
||||||
replaymod.gui.speed=Speed
|
replaymod.gui.speed=Speed
|
||||||
|
|
||||||
|
replaymod.gui.unknownerror=An unknown error occured
|
||||||
|
|
||||||
replaymod.gui.exit=Exit Replay
|
replaymod.gui.exit=Exit Replay
|
||||||
replaymod.gui.java=Java 1.7 or newer required
|
replaymod.gui.java=Java 1.7 or newer required
|
||||||
replaymod.gui.morereplays=At least one Replay 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.tagshint=Tags separated by comma
|
||||||
replaymod.gui.upload.uploading=Uploading...
|
replaymod.gui.upload.uploading=Uploading...
|
||||||
replaymod.gui.upload.success=File has been successfully uploaded
|
replaymod.gui.upload.success=File has been successfully uploaded
|
||||||
|
replaymod.gui.upload.canceled=Upload has been canceled
|
||||||
|
|
||||||
#Replay Editor
|
#Replay Editor
|
||||||
replaymod.gui.editor.replayfile=Replay File
|
replaymod.gui.editor.replayfile=Replay File
|
||||||
|
|||||||
Reference in New Issue
Block a user