mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
clear i18n code + revert back some other part of the code to its original state
This commit is contained in:
parent
59651eb032
commit
a0a51110a5
@ -1883,7 +1883,7 @@ impl Hud {
|
||||
tooltip_manager,
|
||||
&mut self.slot_manager,
|
||||
self.pulse,
|
||||
&i18n,
|
||||
i18n,
|
||||
&player_stats,
|
||||
&self.show,
|
||||
)
|
||||
@ -1966,7 +1966,7 @@ impl Hud {
|
||||
client,
|
||||
&self.imgs,
|
||||
&self.fonts,
|
||||
&i18n,
|
||||
i18n,
|
||||
&self.rot_imgs,
|
||||
tooltip_manager,
|
||||
&self.item_imgs,
|
||||
|
@ -56,7 +56,7 @@ pub struct RawLocalization {
|
||||
}
|
||||
|
||||
/// Store internationalization data
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Localization {
|
||||
|
||||
/// A list of subdirectories to lookup for localization files
|
||||
@ -237,41 +237,6 @@ impl assets::Compound for Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes and return a Localization with the given key
|
||||
pub fn init_localization(asset_key: &str) -> Result<Localization, assets::BoxedError> {
|
||||
// retrieve a Localization struct, clone it to allow writing
|
||||
// for this, we load a special file called "_root.ron"
|
||||
let mut asked_localization = Localization::load(&(asset_key.to_string() + "._root"))?.cloned();
|
||||
|
||||
// walk through files in the folder, collecting localization fragment to merge inside the asked_localization
|
||||
for localization_asset in assets::load_dir::<LocalizationFragment>(asset_key)?.iter() {
|
||||
asked_localization.string_map.extend(localization_asset.read().string_map.clone());
|
||||
asked_localization.vector_map.extend(localization_asset.read().vector_map.clone());
|
||||
}
|
||||
// use the localization's subdirectory list to load fragments from there
|
||||
for sub_directory in asked_localization.sub_directories.iter() {
|
||||
for localization_asset in assets::load_dir::<LocalizationFragment>(&(asset_key.to_string() + "." + &sub_directory))?.iter() {
|
||||
asked_localization.string_map.extend(localization_asset.read().string_map.clone());
|
||||
asked_localization.vector_map.extend(localization_asset.read().vector_map.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// Update the text if UTF-8 to ASCII conversion is enabled
|
||||
if asked_localization.convert_utf8_to_ascii {
|
||||
for value in asked_localization.string_map.values_mut() {
|
||||
*value = deunicode(value);
|
||||
}
|
||||
|
||||
for value in asked_localization.vector_map.values_mut() {
|
||||
*value = value.iter().map(|s| deunicode(s)).collect();
|
||||
}
|
||||
}
|
||||
asked_localization.metadata.language_name =
|
||||
deunicode(&asked_localization.metadata.language_name);
|
||||
|
||||
Ok(asked_localization)
|
||||
}
|
||||
|
||||
/// Load all the available languages located in the voxygen asset directory
|
||||
pub fn list_localizations() -> Vec<LanguageMetadata> {
|
||||
let mut languages = vec![];
|
||||
|
@ -157,7 +157,6 @@ fn main() {
|
||||
// Load the profile.
|
||||
let profile = Profile::load();
|
||||
|
||||
|
||||
let i18n = Localization::load(&i18n_asset_key(&settings.language.selected_language))
|
||||
.unwrap_or_else(|error| {
|
||||
let selected_language = &settings.language.selected_language;
|
||||
|
@ -162,7 +162,7 @@ impl PlayState for CharSelectionState {
|
||||
}
|
||||
|
||||
// Tick the client (currently only to keep the connection alive).
|
||||
let localized_strings = &global_state.i18n.read();
|
||||
let localized_strings = &*global_state.i18n.read();
|
||||
|
||||
match self.client.borrow_mut().tick(
|
||||
comp::ControllerInputs::default(),
|
||||
|
@ -261,9 +261,9 @@ impl PlayState for MainMenuState {
|
||||
MainMenuEvent::ChangeLanguage(new_language) => {
|
||||
global_state.settings.language.selected_language =
|
||||
new_language.language_identifier;
|
||||
global_state.i18n = Localization::load_expect(
|
||||
&i18n_asset_key(&global_state.settings.language.selected_language)
|
||||
);
|
||||
global_state.i18n = Localization::load_expect(&i18n_asset_key(
|
||||
&global_state.settings.language.selected_language
|
||||
));
|
||||
global_state.i18n.read().log_missing_entries();
|
||||
self.main_menu_ui
|
||||
.update_language(global_state.i18n, &global_state.settings);
|
||||
|
Loading…
Reference in New Issue
Block a user