Added localization for server error message display on client

This commit is contained in:
kaedr 2021-10-16 20:15:32 -04:00
parent eb02a4733d
commit cc98ccc371
2 changed files with 35 additions and 3 deletions

View File

@ -64,7 +64,13 @@ https://veloren.net/account/."#,
"main.login.username_bad_characters": "Username contains invalid characters! (Only alphanumeric, '_' and '-' are allowed)", "main.login.username_bad_characters": "Username contains invalid characters! (Only alphanumeric, '_' and '-' are allowed)",
"main.login.username_too_long": "Username is too long! Max length is: {max_len}", "main.login.username_too_long": "Username is too long! Max length is: {max_len}",
"main.servers.select_server": "Select a server", "main.servers.select_server": "Select a server",
"main.servers.singleplayer_error": "Failed to connect to internal server.", "main.servers.singleplayer_error": "Failed to connect to internal server: {sp_error}",
"main.servers.network_error": "Server network/socket error: {raw_error}",
"main.servers.participant_error": "Participant disconnect/protocol error: {raw_error}",
"main.servers.stream_error": "Client connection/compression/(de)serialization error: {raw_error}",
"main.servers.database_error": "Server database error: {raw_error}",
"main.servers.persistence_error": "Server persistence error (Probably Asset/Character Data related): {raw_error}",
"main.servers.other_error": "Server general error: {raw_error}",
// Credits screen // Credits screen
"main.credits": "Credits", "main.credits": "Credits",

View File

@ -113,17 +113,43 @@ impl PlayState for MainMenuState {
global_state.singleplayer = None; global_state.singleplayer = None;
self.init = InitState::None; self.init = InitState::None;
self.main_menu_ui.cancel_connection(); self.main_menu_ui.cancel_connection();
let server_err = match e {
server::Error::NetworkErr(e) => localized_strings
.get("main.servers.network_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
server::Error::ParticipantErr(e) => localized_strings
.get("main.servers.participant_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
server::Error::StreamErr(e) => localized_strings
.get("main.servers.stream_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
server::Error::DatabaseErr(e) => localized_strings
.get("main.servers.database_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
server::Error::PersistenceErr(e) => localized_strings
.get("main.servers.persistence_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
server::Error::Other(e) => localized_strings
.get("main.servers.other_error")
.to_owned()
.replace("{raw_error}", e.to_string().as_str()),
};
global_state.info_message = Some( global_state.info_message = Some(
localized_strings localized_strings
.get("main.servers.singleplayer_error") .get("main.servers.singleplayer_error")
.to_owned(), .to_owned()
.replace("{sp_error}", server_err.as_str()),
); );
}, },
Err(_) => (), Err(_) => (),
} }
} }
} }
// Handle window events. // Handle window events.
for event in events { for event in events {
// Pass all events to the ui first. // Pass all events to the ui first.