From 308b245828dcfecada8f418054add5a433a601a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 14 Jan 2024 19:37:23 +0100 Subject: [PATCH] AVC --- czkawka_core/src/common_dir_traversal.rs | 36 +++++--- czkawka_core/src/common_directory.rs | 23 ++--- czkawka_core/src/similar_videos.rs | 9 +- czkawka_gui/src/compute_results.rs | 91 ++++--------------- .../connect_things/connect_button_compare.rs | 9 +- .../connect_things/connect_button_delete.rs | 38 ++------ .../connect_things/connect_button_hardlink.rs | 28 +----- .../src/connect_things/connect_button_move.rs | 22 +---- .../src/connect_things/connect_button_save.rs | 3 +- .../connect_things/connect_progress_window.rs | 5 +- czkawka_gui/src/initialize_gui.rs | 23 +---- czkawka_gui/src/saving_loading.rs | 85 ++++------------- 12 files changed, 90 insertions(+), 282 deletions(-) diff --git a/czkawka_core/src/common_dir_traversal.rs b/czkawka_core/src/common_dir_traversal.rs index fe2414d..dae0fa4 100644 --- a/czkawka_core/src/common_dir_traversal.rs +++ b/czkawka_core/src/common_dir_traversal.rs @@ -18,7 +18,6 @@ use crate::common_items::ExcludedItems; use crate::common_tool::CommonToolData; use crate::common_traits::ResultEntry; use crate::flc; -use crate::localizer_core::generate_translation_hashmap; #[derive(Debug)] pub struct ProgressData { @@ -550,10 +549,7 @@ pub fn common_read_dir(current_folder: &Path, warnings: &mut Vec) -> Opt match fs::read_dir(current_folder) { Ok(t) => Some(t), Err(e) => { - warnings.push(flc!( - "core_cannot_open_dir", - generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())]) - )); + warnings.push(flc!("core_cannot_open_dir", dir = current_folder.to_string_lossy().to_string(), reason = e.to_string())); None } } @@ -564,7 +560,8 @@ pub fn common_get_entry_data<'a>(entry: &'a Result, wa Err(e) => { warnings.push(flc!( "core_cannot_read_entry_dir", - generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())]) + dir = current_folder.to_string_lossy().to_string(), + reason = e.to_string() )); return None; } @@ -577,7 +574,8 @@ pub fn common_get_metadata_dir(entry_data: &DirEntry, warnings: &mut Vec Err(e) => { warnings.push(flc!( "core_cannot_read_metadata_dir", - generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())]) + dir = current_folder.to_string_lossy().to_string(), + reason = e.to_string() )); return None; } @@ -591,7 +589,8 @@ pub fn common_get_entry_data_metadata<'a>(entry: &'a Result { warnings.push(flc!( "core_cannot_read_entry_dir", - generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())]) + dir = current_folder.to_string_lossy().to_string(), + reason = e.to_string() )); return None; } @@ -601,7 +600,8 @@ pub fn common_get_entry_data_metadata<'a>(entry: &'a Result { warnings.push(flc!( "core_cannot_read_metadata_dir", - generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())]) + dir = current_folder.to_string_lossy().to_string(), + reason = e.to_string() )); return None; } @@ -614,21 +614,27 @@ pub fn get_modified_time(metadata: &Metadata, warnings: &mut Vec, curren Ok(t) => match t.duration_since(UNIX_EPOCH) { Ok(d) => d.as_secs(), Err(_inspected) => { - let translation_hashmap = generate_translation_hashmap(vec![("name", current_file_name.to_string_lossy().to_string())]); if is_folder { - warnings.push(flc!("core_folder_modified_before_epoch", translation_hashmap)); + warnings.push(flc!("core_folder_modified_before_epoch", name = current_file_name.to_string_lossy().to_string())); } else { - warnings.push(flc!("core_file_modified_before_epoch", translation_hashmap)); + warnings.push(flc!("core_file_modified_before_epoch", name = current_file_name.to_string_lossy().to_string())); } 0 } }, Err(e) => { - let translation_hashmap = generate_translation_hashmap(vec![("name", current_file_name.to_string_lossy().to_string()), ("reason", e.to_string())]); if is_folder { - warnings.push(flc!("core_folder_no_modification_date", translation_hashmap)); + warnings.push(flc!( + "core_folder_no_modification_date", + name = current_file_name.to_string_lossy().to_string(), + reason = e.to_string() + )); } else { - warnings.push(flc!("core_file_no_modification_date", translation_hashmap)); + warnings.push(flc!( + "core_file_no_modification_date", + name = current_file_name.to_string_lossy().to_string(), + reason = e.to_string() + )); } 0 } diff --git a/czkawka_core/src/common_directory.rs b/czkawka_core/src/common_directory.rs index 732bd07..0b68fd9 100644 --- a/czkawka_core/src/common_directory.rs +++ b/czkawka_core/src/common_directory.rs @@ -5,7 +5,6 @@ use std::{fs, os::unix::fs::MetadataExt}; use crate::common_messages::Messages; use crate::flc; -use crate::localizer_core::generate_translation_hashmap; #[derive(Debug, Clone, Default)] pub struct Directories { @@ -105,19 +104,15 @@ impl Directories { let mut directory = directory.to_path_buf(); if !directory.exists() { if !is_excluded { - messages.warnings.push(flc!( - "core_directory_must_exists", - generate_translation_hashmap(vec![("path", directory.to_string_lossy().to_string())]) - )); + messages.warnings.push(flc!("core_directory_must_exists", path = directory.to_string_lossy().to_string())); } return (None, messages); } if !directory.is_dir() { - messages.warnings.push(flc!( - "core_directory_must_be_directory", - generate_translation_hashmap(vec![("path", directory.to_string_lossy().to_string())]) - )); + messages + .warnings + .push(flc!("core_directory_must_be_directory", path = directory.to_string_lossy().to_string())); return (None, messages); } @@ -290,10 +285,7 @@ impl Directories { for d in &self.included_directories { match fs::metadata(d) { Ok(m) => self.included_dev_ids.push(m.dev()), - Err(_) => messages.errors.push(flc!( - "core_directory_unable_to_get_device_id", - generate_translation_hashmap(vec![("path", d.to_string_lossy().to_string())]) - )), + Err(_) => messages.errors.push(flc!("core_directory_unable_to_get_device_id", path = d.to_string_lossy().to_string())), } } } @@ -322,10 +314,7 @@ impl Directories { let path = path.as_ref(); match fs::metadata(path) { Ok(m) => Ok(!self.included_dev_ids.iter().any(|&id| id == m.dev())), - Err(_) => Err(flc!( - "core_directory_unable_to_get_device_id", - generate_translation_hashmap(vec![("path", path.to_string_lossy().to_string())]) - )), + Err(_) => Err(flc!("core_directory_unable_to_get_device_id", path = path.to_string_lossy().to_string())), } } } diff --git a/czkawka_core/src/similar_videos.rs b/czkawka_core/src/similar_videos.rs index de8391e..23877a9 100644 --- a/czkawka_core/src/similar_videos.rs +++ b/czkawka_core/src/similar_videos.rs @@ -20,7 +20,6 @@ use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraver use crate::common_tool::{CommonData, CommonToolData, DeleteMethod}; use crate::common_traits::{DebugPrint, PrintResults, ResultEntry}; use crate::flc; -use crate::localizer_core::generate_translation_hashmap; pub const MAX_TOLERANCE: i32 = 20; @@ -121,10 +120,10 @@ impl SimilarVideos { #[cfg(target_os = "windows")] self.common_data.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows")); #[cfg(target_os = "linux")] - self.common_data.text_messages.errors.push(flc!( - "core_ffmpeg_missing_in_snap", - generate_translation_hashmap(vec![("url", "https://github.com/snapcrafters/ffmpeg/issues/73".to_string())]) - )); + self.common_data + .text_messages + .errors + .push(flc!("core_ffmpeg_missing_in_snap", url = "https://github.com/snapcrafters/ffmpeg/issues/73")); } else { self.optimize_dirs_before_start(); self.common_data.use_reference_folders = !self.common_data.directories.reference_directories.is_empty(); diff --git a/czkawka_gui/src/compute_results.rs b/czkawka_gui/src/compute_results.rs index 982633a..14b8223 100644 --- a/czkawka_gui/src/compute_results.rs +++ b/czkawka_gui/src/compute_results.rs @@ -21,7 +21,6 @@ use czkawka_core::duplicate::DuplicateFinder; use czkawka_core::empty_files::EmptyFiles; use czkawka_core::empty_folder::EmptyFolder; use czkawka_core::invalid_symlinks::InvalidSymlinks; -use czkawka_core::localizer_core::generate_translation_hashmap; use czkawka_core::same_music::{MusicSimilarity, SameMusic}; use czkawka_core::similar_images; use czkawka_core::similar_images::{ImagesEntry, SimilarImages}; @@ -250,13 +249,7 @@ fn computer_bad_extensions( let text_messages = be.get_text_messages(); let bad_extensions_number: usize = information.number_of_files_with_bad_extension; - entry_info.set_text( - flg!( - "compute_found_bad_extensions", - generate_translation_hashmap(vec![("number_files", bad_extensions_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_bad_extensions", number_files = bad_extensions_number).as_str()); // Create GUI { @@ -322,13 +315,7 @@ fn computer_broken_files( let broken_files_number: usize = information.number_of_broken_files; - entry_info.set_text( - flg!( - "compute_found_broken_files", - generate_translation_hashmap(vec![("number_files", broken_files_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_broken_files", number_files = broken_files_number).as_str()); // Create GUI { @@ -393,13 +380,7 @@ fn computer_invalid_symlinks( let invalid_symlinks: usize = information.number_of_invalid_symlinks; - entry_info.set_text( - flg!( - "compute_found_invalid_symlinks", - generate_translation_hashmap(vec![("number_files", invalid_symlinks.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_invalid_symlinks", number_files = invalid_symlinks).as_str()); // Create GUI { @@ -473,10 +454,8 @@ fn computer_same_music( entry_info.set_text( flg!( "compute_found_music", - generate_translation_hashmap(vec![ - ("number_files", information.number_of_duplicates.to_string()), - ("number_groups", information.number_of_groups.to_string()), - ]) + number_files = information.number_of_duplicates, + number_groups = information.number_of_groups ) .as_str(), ); @@ -640,10 +619,8 @@ fn computer_similar_videos( entry_info.set_text( flg!( "compute_found_videos", - generate_translation_hashmap(vec![ - ("number_files", information.number_of_duplicates.to_string()), - ("number_groups", information.number_of_groups.to_string()), - ]) + number_files = information.number_of_duplicates, + number_groups = information.number_of_groups ) .as_str(), ); @@ -738,10 +715,8 @@ fn computer_similar_images( entry_info.set_text( flg!( "compute_found_images", - generate_translation_hashmap(vec![ - ("number_files", information.number_of_duplicates.to_string()), - ("number_groups", information.number_of_groups.to_string()), - ]) + number_files = information.number_of_duplicates, + number_groups = information.number_of_groups ) .as_str(), ); @@ -862,13 +837,7 @@ fn computer_temporary_files( let text_messages = tf.get_text_messages(); let temporary_files_number: usize = information.number_of_temporary_files; - entry_info.set_text( - flg!( - "compute_found_temporary_files", - generate_translation_hashmap(vec![("number_files", temporary_files_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_temporary_files", number_files = temporary_files_number).as_str()); // Create GUI { @@ -932,13 +901,7 @@ fn computer_big_files( let biggest_files_number: usize = information.number_of_real_files; - entry_info.set_text( - flg!( - "compute_found_big_files", - generate_translation_hashmap(vec![("number_files", biggest_files_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_big_files", number_files = biggest_files_number).as_str()); // Create GUI { @@ -1000,13 +963,7 @@ fn computer_empty_files( let empty_files_number: usize = information.number_of_empty_files; - entry_info.set_text( - flg!( - "compute_found_empty_files", - generate_translation_hashmap(vec![("number_files", empty_files_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_empty_files", number_files = empty_files_number).as_str()); // Create GUI { @@ -1067,13 +1024,7 @@ fn computer_empty_folders( let empty_folder_number: usize = information.number_of_empty_folders; - entry_info.set_text( - flg!( - "compute_found_empty_folders", - generate_translation_hashmap(vec![("number_files", empty_folder_number.to_string()),]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_empty_folders", number_files = empty_folder_number).as_str()); // Create GUI { @@ -1167,22 +1118,14 @@ fn computer_duplicate_finder( _ => panic!(), } if duplicates_size == 0 { - entry_info.set_text( - flg!( - "compute_found_duplicates_name", - generate_translation_hashmap(vec![("number_files", duplicates_number.to_string()), ("number_groups", duplicates_group.to_string())]) - ) - .as_str(), - ); + entry_info.set_text(flg!("compute_found_duplicates_name", number_files = duplicates_number, number_groups = duplicates_group).as_str()); } else { entry_info.set_text( flg!( "compute_found_duplicates_hash_size", - generate_translation_hashmap(vec![ - ("number_files", duplicates_number.to_string()), - ("number_groups", duplicates_group.to_string()), - ("size", format_size(duplicates_size, BINARY)) - ]) + number_files = duplicates_number, + number_groups = duplicates_group, + size = format_size(duplicates_size, BINARY) ) .as_str(), ); diff --git a/czkawka_gui/src/connect_things/connect_button_compare.rs b/czkawka_gui/src/connect_things/connect_button_compare.rs index 07fd227..679d74f 100644 --- a/czkawka_gui/src/connect_things/connect_button_compare.rs +++ b/czkawka_gui/src/connect_things/connect_button_compare.rs @@ -15,7 +15,6 @@ use crate::gui_structs::gui_data::GuiData; use crate::help_functions::{ count_number_of_groups, get_all_direct_children, get_full_name_from_path_name, get_max_file_name, get_pixbuf_from_dynamic_image, resize_pixbuf_dimension, }; -use crate::localizer_core::generate_translation_hashmap; use crate::notebook_info::{NotebookObject, NOTEBOOKS_INFO}; const BIG_PREVIEW_SIZE: i32 = 600; @@ -303,11 +302,9 @@ fn populate_groups_at_start( label_group_info.set_text( flg!( "compare_groups_number", - generate_translation_hashmap(vec![ - ("current_group", current_group.to_string()), - ("all_groups", group_number.to_string()), - ("images_in_group", cache_all_images.len().to_string()) - ]) + current_group = current_group, + all_groups = group_number, + images_in_group = cache_all_images.len() ) .as_str(), ); diff --git a/czkawka_gui/src/connect_things/connect_button_delete.rs b/czkawka_gui/src/connect_things/connect_button_delete.rs index 9b60e99..22ac25a 100644 --- a/czkawka_gui/src/connect_things/connect_button_delete.rs +++ b/czkawka_gui/src/connect_things/connect_button_delete.rs @@ -8,7 +8,6 @@ use gtk4::{Align, CheckButton, Dialog, Orientation, ResponseType, TextView}; use crate::flg; use crate::gui_structs::gui_data::GuiData; use crate::help_functions::*; -use crate::localizer_core::generate_translation_hashmap; use crate::notebook_enums::*; use crate::notebook_info::NOTEBOOKS_INFO; @@ -148,13 +147,11 @@ fn create_dialog_ask_for_deletion(window_main: >k4::Window, number_of_selected let label: gtk4::Label = gtk4::Label::new(Some(&flg!("delete_question_label"))); let label2: gtk4::Label = match number_of_selected_groups { - 0 => gtk4::Label::new(Some(&flg!( - "delete_items_label", - generate_translation_hashmap(vec![("items", number_of_selected_items.to_string())]) - ))), + 0 => gtk4::Label::new(Some(&flg!("delete_items_label", items = number_of_selected_items))), _ => gtk4::Label::new(Some(&flg!( "delete_items_groups_label", - generate_translation_hashmap(vec![("items", number_of_selected_items.to_string()), ("groups", number_of_selected_groups.to_string())]) + items = number_of_selected_items, + groups = number_of_selected_groups ))), }; @@ -368,10 +365,7 @@ pub fn empty_folder_remover( } } if error_happened { - messages += &flg!( - "delete_folder_failed", - generate_translation_hashmap(vec![("dir", get_full_name_from_path_name(&path, &name))]) - ); + messages += &flg!("delete_folder_failed", dir = get_full_name_from_path_name(&path, &name)); messages += "\n"; } } @@ -425,11 +419,7 @@ pub fn basic_remove( } Err(e) => { - messages += flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &name)), ("reason", e.to_string())]) - ) - .as_str(); + messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &name), reason = e.to_string()).as_str(); messages += "\n"; } } @@ -439,11 +429,7 @@ pub fn basic_remove( model.remove(&iter); } Err(e) => { - messages += flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &name)), ("reason", e.to_string())]) - ) - .as_str(); + messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &name), reason = e.to_string()).as_str(); messages += "\n"; } } @@ -513,19 +499,11 @@ pub fn tree_remove( for file_name in vec_file_name { if !use_trash { if let Err(e) = fs::remove_file(get_full_name_from_path_name(&path, &file_name)) { - messages += flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &file_name)), ("reason", e.to_string())]) - ) - .as_str(); + messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &file_name), reason = e.to_string()).as_str(); messages += "\n"; } } else if let Err(e) = trash::delete(get_full_name_from_path_name(&path, &file_name)) { - messages += flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &file_name)), ("reason", e.to_string())]) - ) - .as_str(); + messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &file_name), reason = e.to_string()).as_str(); messages += "\n"; } diff --git a/czkawka_gui/src/connect_things/connect_button_hardlink.rs b/czkawka_gui/src/connect_things/connect_button_hardlink.rs index 1f570b7..4adaf9e 100644 --- a/czkawka_gui/src/connect_things/connect_button_hardlink.rs +++ b/czkawka_gui/src/connect_things/connect_button_hardlink.rs @@ -9,7 +9,6 @@ use czkawka_core::duplicate::make_hard_link; use crate::flg; use crate::gui_structs::gui_data::GuiData; use crate::help_functions::*; -use crate::localizer_core::generate_translation_hashmap; use crate::notebook_enums::*; use crate::notebook_info::NOTEBOOKS_INFO; @@ -211,42 +210,21 @@ fn hardlink_symlink( for symhardlink_data in vec_symhardlink_data { for file_to_symlink in symhardlink_data.files_to_symhardlink { if let Err(e) = fs::remove_file(&file_to_symlink) { - add_text_to_text_view( - text_view_errors, - flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str()); continue; }; #[cfg(target_family = "unix")] { if let Err(e) = std::os::unix::fs::symlink(&symhardlink_data.original_data, &file_to_symlink) { - add_text_to_text_view( - text_view_errors, - flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str()); continue; }; } #[cfg(target_family = "windows")] { if let Err(e) = std::os::windows::fs::symlink_file(&symhardlink_data.original_data, &file_to_symlink) { - add_text_to_text_view( - text_view_errors, - flg!( - "delete_file_failed", - generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str()); continue; }; } diff --git a/czkawka_gui/src/connect_things/connect_button_move.rs b/czkawka_gui/src/connect_things/connect_button_move.rs index 2c1d500..3346638 100644 --- a/czkawka_gui/src/connect_things/connect_button_move.rs +++ b/czkawka_gui/src/connect_things/connect_button_move.rs @@ -7,7 +7,6 @@ use gtk4::{ResponseType, TreePath}; use crate::flg; use crate::gui_structs::gui_data::GuiData; use crate::help_functions::*; -use crate::localizer_core::generate_translation_hashmap; use crate::notebook_enums::*; use crate::notebook_info::NOTEBOOKS_INFO; @@ -54,14 +53,7 @@ pub fn connect_button_move(gui_data: &GuiData) { } if folders.len() != 1 { - add_text_to_text_view( - &text_view_errors, - flg!( - "move_files_choose_more_than_1_path", - generate_translation_hashmap(vec![("path_number", folders.len().to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(&text_view_errors, flg!("move_files_choose_more_than_1_path", path_number = folders.len()).as_str()); } else { let folder = folders[0].clone(); if let Some(column_header) = nb_object.column_header { @@ -201,13 +193,13 @@ fn move_files_common( let destination_file = destination_folder.join(file_name); if Path::new(&thing).is_dir() { if let Err(e) = fs_extra::dir::move_dir(&thing, &destination_file, &CopyOptions::new()) { - messages += flg!("move_folder_failed", generate_translation_hashmap(vec![("name", thing), ("reason", e.to_string())])).as_str(); + messages += flg!("move_folder_failed", name = thing, reason = e.to_string()).as_str(); messages += "\n"; continue 'next_result; } } else { if let Err(e) = fs_extra::file::move_file(&thing, &destination_file, &fs_extra::file::CopyOptions::new()) { - messages += flg!("move_file_failed", generate_translation_hashmap(vec![("name", thing), ("reason", e.to_string())])).as_str(); + messages += flg!("move_file_failed", name = thing, reason = e.to_string()).as_str(); messages += "\n"; continue 'next_result; @@ -217,13 +209,7 @@ fn move_files_common( moved_files += 1; } - entry_info.set_text( - flg!( - "move_stats", - generate_translation_hashmap(vec![("num_files", moved_files.to_string()), ("all_files", selected_rows.len().to_string())]) - ) - .as_str(), - ); + entry_info.set_text(flg!("move_stats", num_files = moved_files, all_files = selected_rows.len()).as_str()); text_view_errors.buffer().set_text(messages.as_str()); } diff --git a/czkawka_gui/src/connect_things/connect_button_save.rs b/czkawka_gui/src/connect_things/connect_button_save.rs index c06e5c4..75b1f7e 100644 --- a/czkawka_gui/src/connect_things/connect_button_save.rs +++ b/czkawka_gui/src/connect_things/connect_button_save.rs @@ -11,7 +11,6 @@ use czkawka_core::common_traits::PrintResults; use crate::flg; use crate::gui_structs::gui_data::GuiData; use crate::help_functions::BottomButtonsEnum; -use crate::localizer_core::generate_translation_hashmap; use crate::notebook_enums::*; pub fn connect_button_save(gui_data: &GuiData) { @@ -76,7 +75,7 @@ fn post_save_things( buttons_save: &Button, current_path: String, ) { - entry_info.set_text(&flg!("save_results_to_file", generate_translation_hashmap(vec![("name", current_path),]))); + entry_info.set_text(&flg!("save_results_to_file", name = current_path)); // Set state { buttons_save.hide(); diff --git a/czkawka_gui/src/connect_things/connect_progress_window.rs b/czkawka_gui/src/connect_things/connect_progress_window.rs index 2e26df1..a464921 100644 --- a/czkawka_gui/src/connect_things/connect_progress_window.rs +++ b/czkawka_gui/src/connect_things/connect_progress_window.rs @@ -164,10 +164,7 @@ fn progress_collect_items(gui_data: &GuiData, item: &ProgressData, files: bool) if files { label_stage.set_text(&flg!("progress_scanning_general_file", file_number_tm(item))); } else { - label_stage.set_text(&flg!( - "progress_scanning_empty_folders", - generate_translation_hashmap(vec![("folder_number", item.entries_checked.to_string())]) - )); + label_stage.set_text(&flg!("progress_scanning_empty_folders", folder_number = item.entries_checked)); } } diff --git a/czkawka_gui/src/initialize_gui.rs b/czkawka_gui/src/initialize_gui.rs index 79a3dd2..200f80c 100644 --- a/czkawka_gui/src/initialize_gui.rs +++ b/czkawka_gui/src/initialize_gui.rs @@ -510,14 +510,7 @@ fn show_preview( let image = match get_dynamic_image_from_heic(file_name) { Ok(t) => t, Err(e) => { - add_text_to_text_view( - text_view_errors, - flg!( - "preview_image_opening_failure", - generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("preview_image_opening_failure", name = file_name, reason = e.to_string()).as_str()); break 'dir; } }; @@ -526,14 +519,7 @@ fn show_preview( match get_pixbuf_from_dynamic_image(&image) { Ok(t) => t, Err(e) => { - add_text_to_text_view( - text_view_errors, - flg!( - "preview_image_opening_failure", - generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())]) - ) - .as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("preview_image_opening_failure", name = file_name, reason = e.to_string()).as_str()); break 'dir; } } @@ -559,10 +545,7 @@ fn show_preview( pixbuf = match resize_pixbuf_dimension(&pixbuf, (800, 800), InterpType::Bilinear) { None => { - add_text_to_text_view( - text_view_errors, - flg!("preview_image_resize_failure", generate_translation_hashmap(vec![("name", file_name.to_string())])).as_str(), - ); + add_text_to_text_view(text_view_errors, flg!("preview_image_resize_failure", name = file_name).as_str()); break 'dir; } Some(pixbuf) => pixbuf, diff --git a/czkawka_gui/src/saving_loading.rs b/czkawka_gui/src/saving_loading.rs index ffc05c8..072cd2a 100644 --- a/czkawka_gui/src/saving_loading.rs +++ b/czkawka_gui/src/saving_loading.rs @@ -21,7 +21,6 @@ use crate::gui_structs::gui_upper_notebook::GuiUpperNotebook; use crate::help_combo_box::DUPLICATES_CHECK_METHOD_COMBO_BOX; use crate::help_functions::*; use crate::language_functions::{get_language_from_combo_box_text, LANGUAGES_ALL}; -use crate::localizer_core::generate_translation_hashmap; const SAVE_FILE_NAME: &str = "czkawka_gui_config_4.txt"; @@ -111,13 +110,7 @@ impl LoadSaveStruct { } else if item.is_empty() { String::new() } else { - add_text_to_text_view( - &self.text_view, - &flg!( - "saving_loading_invalid_string", - generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))]) - ), - ); + add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_string", key = key, result = format!("{item:?}"))); default_value }; } @@ -136,13 +129,7 @@ impl LoadSaveStruct { default_value } } else { - add_text_to_text_view( - &self.text_view, - &flg!( - "saving_loading_invalid_int", - generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))]) - ), - ); + add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_int", key = key, result = format!("{item:?}"))); default_value }; } @@ -159,23 +146,11 @@ impl LoadSaveStruct { } else if text == "true" || text == "1" { true } else { - add_text_to_text_view( - &self.text_view, - &flg!( - "saving_loading_decode_problem_bool", - generate_translation_hashmap(vec![("key", key), ("result", item[0].to_string())]) - ), - ); + add_text_to_text_view(&self.text_view, &flg!("saving_loading_decode_problem_bool", key = key, result = item[0].to_string())); default_value } } else { - add_text_to_text_view( - &self.text_view, - &flg!( - "saving_loading_invalid_bool", - generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))]) - ), - ); + add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_bool", key = key, result = format!("{item:?}"))); default_value }; } @@ -186,10 +161,7 @@ impl LoadSaveStruct { // Bool, int, string pub fn save_var(&mut self, key: String, value: &T) { if self.loaded_items.contains_key(&key) { - add_text_to_text_view( - &self.text_view, - &flg!("saving_loading_saving_same_keys", generate_translation_hashmap(vec![("key", key.clone())])), - ); + add_text_to_text_view(&self.text_view, &flg!("saving_loading_saving_same_keys", key = key.clone())); } self.loaded_items.insert(key, vec![value.to_string()]); @@ -224,10 +196,7 @@ impl LoadSaveStruct { if !config_dir.is_dir() { add_text_to_text_view( text_view_errors, - &flg!( - "saving_loading_folder_config_instead_file", - generate_translation_hashmap(vec![("path", config_dir.to_string_lossy().to_string())]) - ), + &flg!("saving_loading_folder_config_instead_file", path = config_dir.to_string_lossy().to_string()), ); return None; } @@ -236,7 +205,8 @@ impl LoadSaveStruct { text_view_errors, &flg!( "saving_loading_failed_to_create_configuration_folder", - generate_translation_hashmap(vec![("path", config_dir.to_string_lossy().to_string()), ("reason", e.to_string())]) + path = config_dir.to_string_lossy().to_string(), + reason = e.to_string() ), ); return None; @@ -249,7 +219,8 @@ impl LoadSaveStruct { text_view_errors, &flg!( "saving_loading_failed_to_create_config_file", - generate_translation_hashmap(vec![("path", config_file.to_string_lossy().to_string()), ("reason", e.to_string())]) + path = config_file.to_string_lossy().to_string(), + reason = e.to_string() ), ); return None; @@ -262,10 +233,7 @@ impl LoadSaveStruct { // Don't show errors when there is no configuration file when starting app add_text_to_text_view( text_view_errors, - &flg!( - "saving_loading_failed_to_read_config_file", - generate_translation_hashmap(vec![("path", config_file.to_string_lossy().to_string())]) - ), + &flg!("saving_loading_failed_to_read_config_file", path = config_file.to_string_lossy().to_string()), ); } return None; @@ -278,7 +246,8 @@ impl LoadSaveStruct { text_view_errors, &flg!( "saving_loading_failed_to_create_config_file", - generate_translation_hashmap(vec![("path", config_file.to_string_lossy().to_string()), ("reason", e.to_string())]) + path = config_file.to_string_lossy().to_string(), + reason = e.to_string() ), ); return None; @@ -299,7 +268,8 @@ impl LoadSaveStruct { text_view_errors, &flg!( "saving_loading_failed_to_read_data_from_file", - generate_translation_hashmap(vec![("path", config_file.to_string_lossy().to_string()), ("reason", e.to_string())]) + path = config_file.to_string_lossy().to_string(), + reason = e.to_string() ), ); return; @@ -314,23 +284,14 @@ impl LoadSaveStruct { } else if !header.is_empty() { self.loaded_items.entry(header.clone()).or_default().push(line.to_string()); } else { - add_text_to_text_view( - text_view_errors, - &flg!( - "saving_loading_orphan_data", - generate_translation_hashmap(vec![("data", line.to_string()), ("index", index.to_string())]) - ), - ); + add_text_to_text_view(text_view_errors, &flg!("saving_loading_orphan_data", data = line, line = index.to_string())); } } let (_, hashmap_sl) = create_hash_map(); for setting in self.loaded_items.keys() { if !hashmap_sl.contains_key(setting) { - add_text_to_text_view( - text_view_errors, - &flg!("saving_loading_not_valid", generate_translation_hashmap(vec![("data", setting.to_string())])), - ); + add_text_to_text_view(text_view_errors, &flg!("saving_loading_not_valid", data = setting.clone())); } } @@ -368,20 +329,12 @@ impl LoadSaveStruct { if data_saved { add_text_to_text_view( text_view_errors, - flg!( - "saving_loading_saving_success", - generate_translation_hashmap(vec![("name", config_file.to_string_lossy().to_string())]) - ) - .as_str(), + flg!("saving_loading_saving_success", name = config_file.to_string_lossy().to_string()).as_str(), ); } else { add_text_to_text_view( text_view_errors, - flg!( - "saving_loading_saving_failure", - generate_translation_hashmap(vec![("name", config_file.to_string_lossy().to_string())]) - ) - .as_str(), + flg!("saving_loading_saving_failure", name = config_file.to_string_lossy().to_string()).as_str(), ); } }