2
0
mirror of https://github.com/qarmin/czkawka synced 2024-11-16 06:12:48 +00:00
This commit is contained in:
Rafał Mikrut 2024-01-14 19:37:23 +01:00
parent 6cde5ab7a0
commit 308b245828
12 changed files with 90 additions and 282 deletions

View File

@ -18,7 +18,6 @@ use crate::common_items::ExcludedItems;
use crate::common_tool::CommonToolData; use crate::common_tool::CommonToolData;
use crate::common_traits::ResultEntry; use crate::common_traits::ResultEntry;
use crate::flc; use crate::flc;
use crate::localizer_core::generate_translation_hashmap;
#[derive(Debug)] #[derive(Debug)]
pub struct ProgressData { pub struct ProgressData {
@ -550,10 +549,7 @@ pub fn common_read_dir(current_folder: &Path, warnings: &mut Vec<String>) -> Opt
match fs::read_dir(current_folder) { match fs::read_dir(current_folder) {
Ok(t) => Some(t), Ok(t) => Some(t),
Err(e) => { Err(e) => {
warnings.push(flc!( warnings.push(flc!("core_cannot_open_dir", dir = current_folder.to_string_lossy().to_string(), reason = e.to_string()));
"core_cannot_open_dir",
generate_translation_hashmap(vec![("dir", current_folder.to_string_lossy().to_string()), ("reason", e.to_string())])
));
None None
} }
} }
@ -564,7 +560,8 @@ pub fn common_get_entry_data<'a>(entry: &'a Result<DirEntry, std::io::Error>, wa
Err(e) => { Err(e) => {
warnings.push(flc!( warnings.push(flc!(
"core_cannot_read_entry_dir", "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; return None;
} }
@ -577,7 +574,8 @@ pub fn common_get_metadata_dir(entry_data: &DirEntry, warnings: &mut Vec<String>
Err(e) => { Err(e) => {
warnings.push(flc!( warnings.push(flc!(
"core_cannot_read_metadata_dir", "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; return None;
} }
@ -591,7 +589,8 @@ pub fn common_get_entry_data_metadata<'a>(entry: &'a Result<DirEntry, std::io::E
Err(e) => { Err(e) => {
warnings.push(flc!( warnings.push(flc!(
"core_cannot_read_entry_dir", "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; return None;
} }
@ -601,7 +600,8 @@ pub fn common_get_entry_data_metadata<'a>(entry: &'a Result<DirEntry, std::io::E
Err(e) => { Err(e) => {
warnings.push(flc!( warnings.push(flc!(
"core_cannot_read_metadata_dir", "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; return None;
} }
@ -614,21 +614,27 @@ pub fn get_modified_time(metadata: &Metadata, warnings: &mut Vec<String>, curren
Ok(t) => match t.duration_since(UNIX_EPOCH) { Ok(t) => match t.duration_since(UNIX_EPOCH) {
Ok(d) => d.as_secs(), Ok(d) => d.as_secs(),
Err(_inspected) => { Err(_inspected) => {
let translation_hashmap = generate_translation_hashmap(vec![("name", current_file_name.to_string_lossy().to_string())]);
if is_folder { 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 { } 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 0
} }
}, },
Err(e) => { 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 { 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 { } 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 0
} }

View File

@ -5,7 +5,6 @@ use std::{fs, os::unix::fs::MetadataExt};
use crate::common_messages::Messages; use crate::common_messages::Messages;
use crate::flc; use crate::flc;
use crate::localizer_core::generate_translation_hashmap;
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct Directories { pub struct Directories {
@ -105,19 +104,15 @@ impl Directories {
let mut directory = directory.to_path_buf(); let mut directory = directory.to_path_buf();
if !directory.exists() { if !directory.exists() {
if !is_excluded { if !is_excluded {
messages.warnings.push(flc!( messages.warnings.push(flc!("core_directory_must_exists", path = directory.to_string_lossy().to_string()));
"core_directory_must_exists",
generate_translation_hashmap(vec![("path", directory.to_string_lossy().to_string())])
));
} }
return (None, messages); return (None, messages);
} }
if !directory.is_dir() { if !directory.is_dir() {
messages.warnings.push(flc!( messages
"core_directory_must_be_directory", .warnings
generate_translation_hashmap(vec![("path", directory.to_string_lossy().to_string())]) .push(flc!("core_directory_must_be_directory", path = directory.to_string_lossy().to_string()));
));
return (None, messages); return (None, messages);
} }
@ -290,10 +285,7 @@ impl Directories {
for d in &self.included_directories { for d in &self.included_directories {
match fs::metadata(d) { match fs::metadata(d) {
Ok(m) => self.included_dev_ids.push(m.dev()), Ok(m) => self.included_dev_ids.push(m.dev()),
Err(_) => messages.errors.push(flc!( Err(_) => messages.errors.push(flc!("core_directory_unable_to_get_device_id", path = d.to_string_lossy().to_string())),
"core_directory_unable_to_get_device_id",
generate_translation_hashmap(vec![("path", d.to_string_lossy().to_string())])
)),
} }
} }
} }
@ -322,10 +314,7 @@ impl Directories {
let path = path.as_ref(); let path = path.as_ref();
match fs::metadata(path) { match fs::metadata(path) {
Ok(m) => Ok(!self.included_dev_ids.iter().any(|&id| id == m.dev())), Ok(m) => Ok(!self.included_dev_ids.iter().any(|&id| id == m.dev())),
Err(_) => Err(flc!( Err(_) => Err(flc!("core_directory_unable_to_get_device_id", path = path.to_string_lossy().to_string())),
"core_directory_unable_to_get_device_id",
generate_translation_hashmap(vec![("path", path.to_string_lossy().to_string())])
)),
} }
} }
} }

View File

@ -20,7 +20,6 @@ use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraver
use crate::common_tool::{CommonData, CommonToolData, DeleteMethod}; use crate::common_tool::{CommonData, CommonToolData, DeleteMethod};
use crate::common_traits::{DebugPrint, PrintResults, ResultEntry}; use crate::common_traits::{DebugPrint, PrintResults, ResultEntry};
use crate::flc; use crate::flc;
use crate::localizer_core::generate_translation_hashmap;
pub const MAX_TOLERANCE: i32 = 20; pub const MAX_TOLERANCE: i32 = 20;
@ -121,10 +120,10 @@ impl SimilarVideos {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
self.common_data.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows")); self.common_data.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows"));
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
self.common_data.text_messages.errors.push(flc!( self.common_data
"core_ffmpeg_missing_in_snap", .text_messages
generate_translation_hashmap(vec![("url", "https://github.com/snapcrafters/ffmpeg/issues/73".to_string())]) .errors
)); .push(flc!("core_ffmpeg_missing_in_snap", url = "https://github.com/snapcrafters/ffmpeg/issues/73"));
} else { } else {
self.optimize_dirs_before_start(); self.optimize_dirs_before_start();
self.common_data.use_reference_folders = !self.common_data.directories.reference_directories.is_empty(); self.common_data.use_reference_folders = !self.common_data.directories.reference_directories.is_empty();

View File

@ -21,7 +21,6 @@ use czkawka_core::duplicate::DuplicateFinder;
use czkawka_core::empty_files::EmptyFiles; use czkawka_core::empty_files::EmptyFiles;
use czkawka_core::empty_folder::EmptyFolder; use czkawka_core::empty_folder::EmptyFolder;
use czkawka_core::invalid_symlinks::InvalidSymlinks; use czkawka_core::invalid_symlinks::InvalidSymlinks;
use czkawka_core::localizer_core::generate_translation_hashmap;
use czkawka_core::same_music::{MusicSimilarity, SameMusic}; use czkawka_core::same_music::{MusicSimilarity, SameMusic};
use czkawka_core::similar_images; use czkawka_core::similar_images;
use czkawka_core::similar_images::{ImagesEntry, SimilarImages}; use czkawka_core::similar_images::{ImagesEntry, SimilarImages};
@ -250,13 +249,7 @@ fn computer_bad_extensions(
let text_messages = be.get_text_messages(); let text_messages = be.get_text_messages();
let bad_extensions_number: usize = information.number_of_files_with_bad_extension; let bad_extensions_number: usize = information.number_of_files_with_bad_extension;
entry_info.set_text( entry_info.set_text(flg!("compute_found_bad_extensions", number_files = bad_extensions_number).as_str());
flg!(
"compute_found_bad_extensions",
generate_translation_hashmap(vec![("number_files", bad_extensions_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -322,13 +315,7 @@ fn computer_broken_files(
let broken_files_number: usize = information.number_of_broken_files; let broken_files_number: usize = information.number_of_broken_files;
entry_info.set_text( entry_info.set_text(flg!("compute_found_broken_files", number_files = broken_files_number).as_str());
flg!(
"compute_found_broken_files",
generate_translation_hashmap(vec![("number_files", broken_files_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -393,13 +380,7 @@ fn computer_invalid_symlinks(
let invalid_symlinks: usize = information.number_of_invalid_symlinks; let invalid_symlinks: usize = information.number_of_invalid_symlinks;
entry_info.set_text( entry_info.set_text(flg!("compute_found_invalid_symlinks", number_files = invalid_symlinks).as_str());
flg!(
"compute_found_invalid_symlinks",
generate_translation_hashmap(vec![("number_files", invalid_symlinks.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -473,10 +454,8 @@ fn computer_same_music(
entry_info.set_text( entry_info.set_text(
flg!( flg!(
"compute_found_music", "compute_found_music",
generate_translation_hashmap(vec![ number_files = information.number_of_duplicates,
("number_files", information.number_of_duplicates.to_string()), number_groups = information.number_of_groups
("number_groups", information.number_of_groups.to_string()),
])
) )
.as_str(), .as_str(),
); );
@ -640,10 +619,8 @@ fn computer_similar_videos(
entry_info.set_text( entry_info.set_text(
flg!( flg!(
"compute_found_videos", "compute_found_videos",
generate_translation_hashmap(vec![ number_files = information.number_of_duplicates,
("number_files", information.number_of_duplicates.to_string()), number_groups = information.number_of_groups
("number_groups", information.number_of_groups.to_string()),
])
) )
.as_str(), .as_str(),
); );
@ -738,10 +715,8 @@ fn computer_similar_images(
entry_info.set_text( entry_info.set_text(
flg!( flg!(
"compute_found_images", "compute_found_images",
generate_translation_hashmap(vec![ number_files = information.number_of_duplicates,
("number_files", information.number_of_duplicates.to_string()), number_groups = information.number_of_groups
("number_groups", information.number_of_groups.to_string()),
])
) )
.as_str(), .as_str(),
); );
@ -862,13 +837,7 @@ fn computer_temporary_files(
let text_messages = tf.get_text_messages(); let text_messages = tf.get_text_messages();
let temporary_files_number: usize = information.number_of_temporary_files; let temporary_files_number: usize = information.number_of_temporary_files;
entry_info.set_text( entry_info.set_text(flg!("compute_found_temporary_files", number_files = temporary_files_number).as_str());
flg!(
"compute_found_temporary_files",
generate_translation_hashmap(vec![("number_files", temporary_files_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -932,13 +901,7 @@ fn computer_big_files(
let biggest_files_number: usize = information.number_of_real_files; let biggest_files_number: usize = information.number_of_real_files;
entry_info.set_text( entry_info.set_text(flg!("compute_found_big_files", number_files = biggest_files_number).as_str());
flg!(
"compute_found_big_files",
generate_translation_hashmap(vec![("number_files", biggest_files_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -1000,13 +963,7 @@ fn computer_empty_files(
let empty_files_number: usize = information.number_of_empty_files; let empty_files_number: usize = information.number_of_empty_files;
entry_info.set_text( entry_info.set_text(flg!("compute_found_empty_files", number_files = empty_files_number).as_str());
flg!(
"compute_found_empty_files",
generate_translation_hashmap(vec![("number_files", empty_files_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -1067,13 +1024,7 @@ fn computer_empty_folders(
let empty_folder_number: usize = information.number_of_empty_folders; let empty_folder_number: usize = information.number_of_empty_folders;
entry_info.set_text( entry_info.set_text(flg!("compute_found_empty_folders", number_files = empty_folder_number).as_str());
flg!(
"compute_found_empty_folders",
generate_translation_hashmap(vec![("number_files", empty_folder_number.to_string()),])
)
.as_str(),
);
// Create GUI // Create GUI
{ {
@ -1167,22 +1118,14 @@ fn computer_duplicate_finder(
_ => panic!(), _ => panic!(),
} }
if duplicates_size == 0 { if duplicates_size == 0 {
entry_info.set_text( entry_info.set_text(flg!("compute_found_duplicates_name", number_files = duplicates_number, number_groups = duplicates_group).as_str());
flg!(
"compute_found_duplicates_name",
generate_translation_hashmap(vec![("number_files", duplicates_number.to_string()), ("number_groups", duplicates_group.to_string())])
)
.as_str(),
);
} else { } else {
entry_info.set_text( entry_info.set_text(
flg!( flg!(
"compute_found_duplicates_hash_size", "compute_found_duplicates_hash_size",
generate_translation_hashmap(vec![ number_files = duplicates_number,
("number_files", duplicates_number.to_string()), number_groups = duplicates_group,
("number_groups", duplicates_group.to_string()), size = format_size(duplicates_size, BINARY)
("size", format_size(duplicates_size, BINARY))
])
) )
.as_str(), .as_str(),
); );

View File

@ -15,7 +15,6 @@ use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::{ 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, 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}; use crate::notebook_info::{NotebookObject, NOTEBOOKS_INFO};
const BIG_PREVIEW_SIZE: i32 = 600; const BIG_PREVIEW_SIZE: i32 = 600;
@ -303,11 +302,9 @@ fn populate_groups_at_start(
label_group_info.set_text( label_group_info.set_text(
flg!( flg!(
"compare_groups_number", "compare_groups_number",
generate_translation_hashmap(vec![ current_group = current_group,
("current_group", current_group.to_string()), all_groups = group_number,
("all_groups", group_number.to_string()), images_in_group = cache_all_images.len()
("images_in_group", cache_all_images.len().to_string())
])
) )
.as_str(), .as_str(),
); );

View File

@ -8,7 +8,6 @@ use gtk4::{Align, CheckButton, Dialog, Orientation, ResponseType, TextView};
use crate::flg; use crate::flg;
use crate::gui_structs::gui_data::GuiData; use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::*; use crate::help_functions::*;
use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_enums::*; use crate::notebook_enums::*;
use crate::notebook_info::NOTEBOOKS_INFO; use crate::notebook_info::NOTEBOOKS_INFO;
@ -148,13 +147,11 @@ fn create_dialog_ask_for_deletion(window_main: &gtk4::Window, number_of_selected
let label: gtk4::Label = gtk4::Label::new(Some(&flg!("delete_question_label"))); let label: gtk4::Label = gtk4::Label::new(Some(&flg!("delete_question_label")));
let label2: gtk4::Label = match number_of_selected_groups { let label2: gtk4::Label = match number_of_selected_groups {
0 => gtk4::Label::new(Some(&flg!( 0 => gtk4::Label::new(Some(&flg!("delete_items_label", items = number_of_selected_items))),
"delete_items_label",
generate_translation_hashmap(vec![("items", number_of_selected_items.to_string())])
))),
_ => gtk4::Label::new(Some(&flg!( _ => gtk4::Label::new(Some(&flg!(
"delete_items_groups_label", "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 { if error_happened {
messages += &flg!( messages += &flg!("delete_folder_failed", dir = get_full_name_from_path_name(&path, &name));
"delete_folder_failed",
generate_translation_hashmap(vec![("dir", get_full_name_from_path_name(&path, &name))])
);
messages += "\n"; messages += "\n";
} }
} }
@ -425,11 +419,7 @@ pub fn basic_remove(
} }
Err(e) => { Err(e) => {
messages += flg!( messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &name), reason = e.to_string()).as_str();
"delete_file_failed",
generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &name)), ("reason", e.to_string())])
)
.as_str();
messages += "\n"; messages += "\n";
} }
} }
@ -439,11 +429,7 @@ pub fn basic_remove(
model.remove(&iter); model.remove(&iter);
} }
Err(e) => { Err(e) => {
messages += flg!( messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &name), reason = e.to_string()).as_str();
"delete_file_failed",
generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &name)), ("reason", e.to_string())])
)
.as_str();
messages += "\n"; messages += "\n";
} }
} }
@ -513,19 +499,11 @@ pub fn tree_remove(
for file_name in vec_file_name { for file_name in vec_file_name {
if !use_trash { if !use_trash {
if let Err(e) = fs::remove_file(get_full_name_from_path_name(&path, &file_name)) { if let Err(e) = fs::remove_file(get_full_name_from_path_name(&path, &file_name)) {
messages += flg!( messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &file_name), reason = e.to_string()).as_str();
"delete_file_failed",
generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &file_name)), ("reason", e.to_string())])
)
.as_str();
messages += "\n"; messages += "\n";
} }
} else if let Err(e) = trash::delete(get_full_name_from_path_name(&path, &file_name)) { } else if let Err(e) = trash::delete(get_full_name_from_path_name(&path, &file_name)) {
messages += flg!( messages += flg!("delete_file_failed", name = get_full_name_from_path_name(&path, &file_name), reason = e.to_string()).as_str();
"delete_file_failed",
generate_translation_hashmap(vec![("name", get_full_name_from_path_name(&path, &file_name)), ("reason", e.to_string())])
)
.as_str();
messages += "\n"; messages += "\n";
} }

View File

@ -9,7 +9,6 @@ use czkawka_core::duplicate::make_hard_link;
use crate::flg; use crate::flg;
use crate::gui_structs::gui_data::GuiData; use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::*; use crate::help_functions::*;
use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_enums::*; use crate::notebook_enums::*;
use crate::notebook_info::NOTEBOOKS_INFO; use crate::notebook_info::NOTEBOOKS_INFO;
@ -211,42 +210,21 @@ fn hardlink_symlink(
for symhardlink_data in vec_symhardlink_data { for symhardlink_data in vec_symhardlink_data {
for file_to_symlink in symhardlink_data.files_to_symhardlink { for file_to_symlink in symhardlink_data.files_to_symhardlink {
if let Err(e) = fs::remove_file(&file_to_symlink) { if let Err(e) = fs::remove_file(&file_to_symlink) {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str());
text_view_errors,
flg!(
"delete_file_failed",
generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())])
)
.as_str(),
);
continue; continue;
}; };
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
{ {
if let Err(e) = std::os::unix::fs::symlink(&symhardlink_data.original_data, &file_to_symlink) { if let Err(e) = std::os::unix::fs::symlink(&symhardlink_data.original_data, &file_to_symlink) {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str());
text_view_errors,
flg!(
"delete_file_failed",
generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())])
)
.as_str(),
);
continue; continue;
}; };
} }
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
{ {
if let Err(e) = std::os::windows::fs::symlink_file(&symhardlink_data.original_data, &file_to_symlink) { if let Err(e) = std::os::windows::fs::symlink_file(&symhardlink_data.original_data, &file_to_symlink) {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("delete_file_failed", name = file_to_symlink, reason = e.to_string()).as_str());
text_view_errors,
flg!(
"delete_file_failed",
generate_translation_hashmap(vec![("name", file_to_symlink.to_string()), ("reason", e.to_string())])
)
.as_str(),
);
continue; continue;
}; };
} }

View File

@ -7,7 +7,6 @@ use gtk4::{ResponseType, TreePath};
use crate::flg; use crate::flg;
use crate::gui_structs::gui_data::GuiData; use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::*; use crate::help_functions::*;
use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_enums::*; use crate::notebook_enums::*;
use crate::notebook_info::NOTEBOOKS_INFO; use crate::notebook_info::NOTEBOOKS_INFO;
@ -54,14 +53,7 @@ pub fn connect_button_move(gui_data: &GuiData) {
} }
if folders.len() != 1 { if folders.len() != 1 {
add_text_to_text_view( add_text_to_text_view(&text_view_errors, flg!("move_files_choose_more_than_1_path", path_number = folders.len()).as_str());
&text_view_errors,
flg!(
"move_files_choose_more_than_1_path",
generate_translation_hashmap(vec![("path_number", folders.len().to_string())])
)
.as_str(),
);
} else { } else {
let folder = folders[0].clone(); let folder = folders[0].clone();
if let Some(column_header) = nb_object.column_header { 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); let destination_file = destination_folder.join(file_name);
if Path::new(&thing).is_dir() { if Path::new(&thing).is_dir() {
if let Err(e) = fs_extra::dir::move_dir(&thing, &destination_file, &CopyOptions::new()) { 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"; messages += "\n";
continue 'next_result; continue 'next_result;
} }
} else { } else {
if let Err(e) = fs_extra::file::move_file(&thing, &destination_file, &fs_extra::file::CopyOptions::new()) { 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"; messages += "\n";
continue 'next_result; continue 'next_result;
@ -217,13 +209,7 @@ fn move_files_common(
moved_files += 1; moved_files += 1;
} }
entry_info.set_text( entry_info.set_text(flg!("move_stats", num_files = moved_files, all_files = selected_rows.len()).as_str());
flg!(
"move_stats",
generate_translation_hashmap(vec![("num_files", moved_files.to_string()), ("all_files", selected_rows.len().to_string())])
)
.as_str(),
);
text_view_errors.buffer().set_text(messages.as_str()); text_view_errors.buffer().set_text(messages.as_str());
} }

View File

@ -11,7 +11,6 @@ use czkawka_core::common_traits::PrintResults;
use crate::flg; use crate::flg;
use crate::gui_structs::gui_data::GuiData; use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::BottomButtonsEnum; use crate::help_functions::BottomButtonsEnum;
use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_enums::*; use crate::notebook_enums::*;
pub fn connect_button_save(gui_data: &GuiData) { pub fn connect_button_save(gui_data: &GuiData) {
@ -76,7 +75,7 @@ fn post_save_things(
buttons_save: &Button, buttons_save: &Button,
current_path: String, 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 // Set state
{ {
buttons_save.hide(); buttons_save.hide();

View File

@ -164,10 +164,7 @@ fn progress_collect_items(gui_data: &GuiData, item: &ProgressData, files: bool)
if files { if files {
label_stage.set_text(&flg!("progress_scanning_general_file", file_number_tm(item))); label_stage.set_text(&flg!("progress_scanning_general_file", file_number_tm(item)));
} else { } else {
label_stage.set_text(&flg!( label_stage.set_text(&flg!("progress_scanning_empty_folders", folder_number = item.entries_checked));
"progress_scanning_empty_folders",
generate_translation_hashmap(vec![("folder_number", item.entries_checked.to_string())])
));
} }
} }

View File

@ -510,14 +510,7 @@ fn show_preview(
let image = match get_dynamic_image_from_heic(file_name) { let image = match get_dynamic_image_from_heic(file_name) {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("preview_image_opening_failure", name = file_name, reason = e.to_string()).as_str());
text_view_errors,
flg!(
"preview_image_opening_failure",
generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())])
)
.as_str(),
);
break 'dir; break 'dir;
} }
}; };
@ -526,14 +519,7 @@ fn show_preview(
match get_pixbuf_from_dynamic_image(&image) { match get_pixbuf_from_dynamic_image(&image) {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("preview_image_opening_failure", name = file_name, reason = e.to_string()).as_str());
text_view_errors,
flg!(
"preview_image_opening_failure",
generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())])
)
.as_str(),
);
break 'dir; break 'dir;
} }
} }
@ -559,10 +545,7 @@ fn show_preview(
pixbuf = match resize_pixbuf_dimension(&pixbuf, (800, 800), InterpType::Bilinear) { pixbuf = match resize_pixbuf_dimension(&pixbuf, (800, 800), InterpType::Bilinear) {
None => { None => {
add_text_to_text_view( add_text_to_text_view(text_view_errors, flg!("preview_image_resize_failure", name = file_name).as_str());
text_view_errors,
flg!("preview_image_resize_failure", generate_translation_hashmap(vec![("name", file_name.to_string())])).as_str(),
);
break 'dir; break 'dir;
} }
Some(pixbuf) => pixbuf, Some(pixbuf) => pixbuf,

View File

@ -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_combo_box::DUPLICATES_CHECK_METHOD_COMBO_BOX;
use crate::help_functions::*; use crate::help_functions::*;
use crate::language_functions::{get_language_from_combo_box_text, LANGUAGES_ALL}; 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"; const SAVE_FILE_NAME: &str = "czkawka_gui_config_4.txt";
@ -111,13 +110,7 @@ impl LoadSaveStruct {
} else if item.is_empty() { } else if item.is_empty() {
String::new() String::new()
} else { } else {
add_text_to_text_view( add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_string", key = key, result = format!("{item:?}")));
&self.text_view,
&flg!(
"saving_loading_invalid_string",
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value default_value
}; };
} }
@ -136,13 +129,7 @@ impl LoadSaveStruct {
default_value default_value
} }
} else { } else {
add_text_to_text_view( add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_int", key = key, result = format!("{item:?}")));
&self.text_view,
&flg!(
"saving_loading_invalid_int",
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value default_value
}; };
} }
@ -159,23 +146,11 @@ impl LoadSaveStruct {
} else if text == "true" || text == "1" { } else if text == "true" || text == "1" {
true true
} else { } else {
add_text_to_text_view( add_text_to_text_view(&self.text_view, &flg!("saving_loading_decode_problem_bool", key = key, result = item[0].to_string()));
&self.text_view,
&flg!(
"saving_loading_decode_problem_bool",
generate_translation_hashmap(vec![("key", key), ("result", item[0].to_string())])
),
);
default_value default_value
} }
} else { } else {
add_text_to_text_view( add_text_to_text_view(&self.text_view, &flg!("saving_loading_invalid_bool", key = key, result = format!("{item:?}")));
&self.text_view,
&flg!(
"saving_loading_invalid_bool",
generate_translation_hashmap(vec![("key", key), ("result", format!("{item:?}"))])
),
);
default_value default_value
}; };
} }
@ -186,10 +161,7 @@ impl LoadSaveStruct {
// Bool, int, string // Bool, int, string
pub fn save_var<T: ToString>(&mut self, key: String, value: &T) { pub fn save_var<T: ToString>(&mut self, key: String, value: &T) {
if self.loaded_items.contains_key(&key) { if self.loaded_items.contains_key(&key) {
add_text_to_text_view( add_text_to_text_view(&self.text_view, &flg!("saving_loading_saving_same_keys", key = key.clone()));
&self.text_view,
&flg!("saving_loading_saving_same_keys", generate_translation_hashmap(vec![("key", key.clone())])),
);
} }
self.loaded_items.insert(key, vec![value.to_string()]); self.loaded_items.insert(key, vec![value.to_string()]);
@ -224,10 +196,7 @@ impl LoadSaveStruct {
if !config_dir.is_dir() { if !config_dir.is_dir() {
add_text_to_text_view( add_text_to_text_view(
text_view_errors, text_view_errors,
&flg!( &flg!("saving_loading_folder_config_instead_file", path = config_dir.to_string_lossy().to_string()),
"saving_loading_folder_config_instead_file",
generate_translation_hashmap(vec![("path", config_dir.to_string_lossy().to_string())])
),
); );
return None; return None;
} }
@ -236,7 +205,8 @@ impl LoadSaveStruct {
text_view_errors, text_view_errors,
&flg!( &flg!(
"saving_loading_failed_to_create_configuration_folder", "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; return None;
@ -249,7 +219,8 @@ impl LoadSaveStruct {
text_view_errors, text_view_errors,
&flg!( &flg!(
"saving_loading_failed_to_create_config_file", "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; return None;
@ -262,10 +233,7 @@ impl LoadSaveStruct {
// Don't show errors when there is no configuration file when starting app // Don't show errors when there is no configuration file when starting app
add_text_to_text_view( add_text_to_text_view(
text_view_errors, text_view_errors,
&flg!( &flg!("saving_loading_failed_to_read_config_file", path = config_file.to_string_lossy().to_string()),
"saving_loading_failed_to_read_config_file",
generate_translation_hashmap(vec![("path", config_file.to_string_lossy().to_string())])
),
); );
} }
return None; return None;
@ -278,7 +246,8 @@ impl LoadSaveStruct {
text_view_errors, text_view_errors,
&flg!( &flg!(
"saving_loading_failed_to_create_config_file", "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; return None;
@ -299,7 +268,8 @@ impl LoadSaveStruct {
text_view_errors, text_view_errors,
&flg!( &flg!(
"saving_loading_failed_to_read_data_from_file", "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; return;
@ -314,23 +284,14 @@ impl LoadSaveStruct {
} else if !header.is_empty() { } else if !header.is_empty() {
self.loaded_items.entry(header.clone()).or_default().push(line.to_string()); self.loaded_items.entry(header.clone()).or_default().push(line.to_string());
} else { } else {
add_text_to_text_view( add_text_to_text_view(text_view_errors, &flg!("saving_loading_orphan_data", data = line, line = index.to_string()));
text_view_errors,
&flg!(
"saving_loading_orphan_data",
generate_translation_hashmap(vec![("data", line.to_string()), ("index", index.to_string())])
),
);
} }
} }
let (_, hashmap_sl) = create_hash_map(); let (_, hashmap_sl) = create_hash_map();
for setting in self.loaded_items.keys() { for setting in self.loaded_items.keys() {
if !hashmap_sl.contains_key(setting) { if !hashmap_sl.contains_key(setting) {
add_text_to_text_view( add_text_to_text_view(text_view_errors, &flg!("saving_loading_not_valid", data = setting.clone()));
text_view_errors,
&flg!("saving_loading_not_valid", generate_translation_hashmap(vec![("data", setting.to_string())])),
);
} }
} }
@ -368,20 +329,12 @@ impl LoadSaveStruct {
if data_saved { if data_saved {
add_text_to_text_view( add_text_to_text_view(
text_view_errors, text_view_errors,
flg!( flg!("saving_loading_saving_success", name = config_file.to_string_lossy().to_string()).as_str(),
"saving_loading_saving_success",
generate_translation_hashmap(vec![("name", config_file.to_string_lossy().to_string())])
)
.as_str(),
); );
} else { } else {
add_text_to_text_view( add_text_to_text_view(
text_view_errors, text_view_errors,
flg!( flg!("saving_loading_saving_failure", name = config_file.to_string_lossy().to_string()).as_str(),
"saving_loading_saving_failure",
generate_translation_hashmap(vec![("name", config_file.to_string_lossy().to_string())])
)
.as_str(),
); );
} }
} }