mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use English instead of saved language if loading fails
This commit is contained in:
parent
8946ed8d82
commit
c501b2d0bf
@ -48,7 +48,7 @@ impl VoxygenLocalization {
|
||||
///
|
||||
/// If the key is not present in the localization object
|
||||
/// then the key is returned.
|
||||
pub fn get<'a>(&'a self, key: &'a str) -> &'a str {
|
||||
pub fn get<'a>(&'a self, key: &'a str) -> &str {
|
||||
match self.string_map.get(key) {
|
||||
Some(localized_text) => localized_text,
|
||||
None => key,
|
||||
|
@ -34,7 +34,7 @@ use crate::{
|
||||
settings::Settings,
|
||||
window::Window,
|
||||
};
|
||||
use common::assets::load_expect;
|
||||
use common::assets::{load, load_expect};
|
||||
use log::{debug, error};
|
||||
use std::{mem, panic, str::FromStr};
|
||||
|
||||
@ -139,9 +139,20 @@ fn main() {
|
||||
};
|
||||
|
||||
// Try to load the localization and log missing entries
|
||||
let localized_strings = load_expect::<VoxygenLocalization>(&i18n_asset_key(
|
||||
let localized_strings = load::<VoxygenLocalization>(&i18n_asset_key(
|
||||
&global_state.settings.language.selected_language,
|
||||
));
|
||||
))
|
||||
.unwrap_or_else(|error| {
|
||||
log::warn!(
|
||||
"Impossible to load {} language: change to the default language (English) instead. Source error: {:?}",
|
||||
&global_state.settings.language.selected_language,
|
||||
error
|
||||
);
|
||||
global_state.settings.language.selected_language = i18n::REFERENCE_LANG.to_owned();
|
||||
load_expect::<VoxygenLocalization>(&i18n_asset_key(
|
||||
&global_state.settings.language.selected_language,
|
||||
))
|
||||
});
|
||||
localized_strings.log_missing_entries();
|
||||
|
||||
// Set up panic handler to relay swish panic messages to the user
|
||||
|
Loading…
Reference in New Issue
Block a user