From 89f24f14b5c49a8b83df34db6feb30e641b74e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Sun, 12 Dec 2021 12:02:53 +0100 Subject: [PATCH] Use translated strings in more places (#498) --- czkawka_core/src/similar_images.rs | 38 ++++++------ czkawka_gui/src/connect_about_buttons.rs | 1 + czkawka_gui/src/connect_button_delete.rs | 31 +++++----- czkawka_gui/src/connect_button_hardlink.rs | 22 +++---- czkawka_gui/src/connect_button_move.rs | 12 ++-- czkawka_gui/src/connect_button_save.rs | 3 +- czkawka_gui/src/connect_button_search.rs | 2 +- czkawka_gui/src/connect_change_language.rs | 2 +- .../src/connect_selection_of_directories.rs | 10 +-- czkawka_gui/src/connect_settings.rs | 31 +++++----- .../src/connect_similar_image_size_change.rs | 13 ++-- czkawka_gui/src/help_functions.rs | 14 ++--- czkawka_gui/src/main.rs | 2 +- czkawka_gui/src/opening_selecting_records.rs | 3 - i18n/en/czkawka_gui.ftl | 53 ++++++++++++++++ i18n/pl/czkawka_gui.ftl | 61 +++++++++++++++++-- instructions/Translations.md | 7 +-- 17 files changed, 203 insertions(+), 102 deletions(-) diff --git a/czkawka_core/src/similar_images.rs b/czkawka_core/src/similar_images.rs index cc660a3..ceeb636 100644 --- a/czkawka_core/src/similar_images.rs +++ b/czkawka_core/src/similar_images.rs @@ -903,25 +903,25 @@ pub fn get_string_from_similarity(similarity: &Similarity, hash_size: u8) -> Str panic!() } Similarity::Similar(h) => { - #[cfg(debug_assertions)] - { - if *h <= SIMILAR_VALUES[index_preset][0] { - format!("{} {}", fl!("core_similarity_very_high"), *h) - } else if *h <= SIMILAR_VALUES[index_preset][1] { - format!("{} {}", fl!("core_similarity_high"), *h) - } else if *h <= SIMILAR_VALUES[index_preset][2] { - format!("{} {}", fl!("core_similarity_medium"), *h) - } else if *h <= SIMILAR_VALUES[index_preset][3] { - format!("{} {}", fl!("core_similarity_small"), *h) - } else if *h <= SIMILAR_VALUES[index_preset][4] { - format!("{} {}", fl!("core_similarity_very_small"), *h) - } else if *h <= SIMILAR_VALUES[index_preset][5] { - format!("{} {}", fl!("core_similarity_minimal"), *h) - } else { - panic!(); - } - } - #[cfg(not(debug_assertions))] + // #[cfg(debug_assertions)] + // { + // if *h <= SIMILAR_VALUES[index_preset][0] { + // format!("{} {}", fl!("core_similarity_very_high"), *h) + // } else if *h <= SIMILAR_VALUES[index_preset][1] { + // format!("{} {}", fl!("core_similarity_high"), *h) + // } else if *h <= SIMILAR_VALUES[index_preset][2] { + // format!("{} {}", fl!("core_similarity_medium"), *h) + // } else if *h <= SIMILAR_VALUES[index_preset][3] { + // format!("{} {}", fl!("core_similarity_small"), *h) + // } else if *h <= SIMILAR_VALUES[index_preset][4] { + // format!("{} {}", fl!("core_similarity_very_small"), *h) + // } else if *h <= SIMILAR_VALUES[index_preset][5] { + // format!("{} {}", fl!("core_similarity_minimal"), *h) + // } else { + // panic!(); + // } + // } + // #[cfg(not(debug_assertions))] { if *h <= SIMILAR_VALUES[index_preset][0] { fl!("core_similarity_very_high") diff --git a/czkawka_gui/src/connect_about_buttons.rs b/czkawka_gui/src/connect_about_buttons.rs index bd5778b..e533e80 100644 --- a/czkawka_gui/src/connect_about_buttons.rs +++ b/czkawka_gui/src/connect_about_buttons.rs @@ -10,6 +10,7 @@ pub fn connect_about_buttons(gui_data: &GuiData) { let button_donation = gui_data.about.button_donation.clone(); button_donation.connect_clicked(move |_| { open::that_in_background(SPONSOR_SITE); + // TODO find way to handle errors when opening this sites // if let Err(e) = open::that(SPONSOR_SITE) { // println!("Failed to open sponsor site: {}, reason {}", SPONSOR_SITE, e) // }; diff --git a/czkawka_gui/src/connect_button_delete.rs b/czkawka_gui/src/connect_button_delete.rs index 4df9591..584a3e9 100644 --- a/czkawka_gui/src/connect_button_delete.rs +++ b/czkawka_gui/src/connect_button_delete.rs @@ -9,7 +9,6 @@ use gtk::{Align, CheckButton, Dialog, ResponseType, TextView}; use crate::gui_data::GuiData; use crate::help_functions::*; use crate::notebook_enums::*; -use crate::validate_notebook_data; // TODO add support for checking if really symlink doesn't point to correct directory/file @@ -24,7 +23,7 @@ pub fn connect_button_delete(gui_data: &GuiData) { } pub async fn delete_things(gui_data: GuiData) { - validate_notebook_data(&gui_data); // TODO, disable this - only used as test if ever + // validate_notebook_data(&gui_data); let notebook_main = gui_data.main_notebook.notebook_main.clone(); let window_main = gui_data.window_main.clone(); @@ -102,12 +101,12 @@ pub async fn check_if_can_delete_files(check_button_settings_confirm_deletion: & } fn create_dialog_ask_for_deletion(window_main: >k::Window) -> (Dialog, CheckButton) { - let dialog = gtk::Dialog::builder().title("Delete confirmation").transient_for(window_main).modal(true).build(); - let button_ok = dialog.add_button("Ok", ResponseType::Ok); + let dialog = gtk::Dialog::builder().title(&fl!("delete_title_dialog")).transient_for(window_main).modal(true).build(); + let button_ok = dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); - let label: gtk::Label = gtk::Label::new(Some("Are you sure that you want to delete files?")); - let check_button: gtk::CheckButton = gtk::CheckButton::with_label("Ask next time"); + let label: gtk::Label = gtk::Label::new(Some(&fl!("delete_question_label"))); + let check_button: gtk::CheckButton = gtk::CheckButton::with_label(&fl!("dialogs_ask_next_time")); check_button.set_active(true); check_button.set_halign(Align::Center); @@ -122,13 +121,13 @@ fn create_dialog_ask_for_deletion(window_main: >k::Window) -> (Dialog, CheckBu } fn create_dialog_group_deletion(window_main: >k::Window) -> (Dialog, CheckButton) { - let dialog = gtk::Dialog::builder().title("Confirmation of deleting all files in group").transient_for(window_main).modal(true).build(); - let button_ok = dialog.add_button("Ok", ResponseType::Ok); + let dialog = gtk::Dialog::builder().title(&fl!("delete_all_files_in_group_title")).transient_for(window_main).modal(true).build(); + let button_ok = dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); - let label: gtk::Label = gtk::Label::new(Some("In some groups there are selected all records.")); - let label2: gtk::Label = gtk::Label::new(Some("Are you sure that you want to delete them?")); - let check_button: gtk::CheckButton = gtk::CheckButton::with_label("Ask next time"); + let label: gtk::Label = gtk::Label::new(Some(&fl!("delete_all_files_in_group_label1"))); + let label2: gtk::Label = gtk::Label::new(Some(&fl!("delete_all_files_in_group_label2"))); + let check_button: gtk::CheckButton = gtk::CheckButton::with_label(&fl!("dialogs_ask_next_time")); check_button.set_active(true); check_button.set_halign(Align::Center); @@ -290,7 +289,7 @@ pub fn empty_folder_remover(tree_view: >k::TreeView, column_file_name: i32, co } } if error_happened { - messages += format!("Failed to remove folder {}/{} because folder doesn't exists, you don't have permissions or isn't empty.\n", path, name).as_str() + messages += format!("{} {}/{} {}\n", fl!("delete_folder_failed_1"), path, name, fl!("delete_folder_failed_2")).as_str() } } @@ -334,14 +333,14 @@ pub fn basic_remove(tree_view: >k::TreeView, column_file_name: i32, column_pat Ok(_) => { model.remove(&iter); } - Err(e) => messages += format!("Failed to remove file {}/{}, reason {}\n", path, name, e).as_str(), + Err(e) => messages += format!("{} {}/{}, reason {}\n", fl!("delete_file_failed"), path, name, e).as_str(), } } else { match trash::delete(format!("{}/{}", path, name)) { Ok(_) => { model.remove(&iter); } - Err(e) => messages += format!("Failed to remove file {}/{}, reason {}\n", path, name, e).as_str(), + Err(e) => messages += format!("{} {}/{}, reason {}\n", fl!("delete_file_failed"), path, name, e).as_str(), } } } @@ -402,10 +401,10 @@ pub fn tree_remove(tree_view: >k::TreeView, column_file_name: i32, column_path for file_name in vec_file_name { if !use_trash { if let Err(e) = fs::remove_file(format!("{}/{}", path.clone(), file_name.clone())) { - messages += format!("Failed to remove file {}/{}, reason {}\n", path, file_name, e).as_str() + messages += format!("{} {}/{}, reason {}\n", fl!("delete_file_failed"), path, file_name, e).as_str() } } else if let Err(e) = trash::delete(format!("{}/{}", path.clone(), file_name.clone())) { - messages += format!("Failed to remove file {}/{}, reason {}\n", path, file_name, e).as_str() + messages += format!("{} {}/{}, reason {}\n", fl!("delete_file_failed"), path, file_name, e).as_str() } vec_path_to_delete.push((path.clone(), file_name.clone())); diff --git a/czkawka_gui/src/connect_button_hardlink.rs b/czkawka_gui/src/connect_button_hardlink.rs index fb1dd9c..8e8ad1a 100644 --- a/czkawka_gui/src/connect_button_hardlink.rs +++ b/czkawka_gui/src/connect_button_hardlink.rs @@ -181,7 +181,7 @@ pub fn hardlink_symlink(tree_view: >k::TreeView, column_file_name: i32, column dbg!(&symhardlink_data); for file_to_hardlink in symhardlink_data.files_to_symhardlink { if let Err(e) = make_hard_link(&PathBuf::from(&symhardlink_data.original_data), &PathBuf::from(&file_to_hardlink)) { - add_text_to_text_view(text_view_errors, format!("Failed to hardlink {}, reason {}", file_to_hardlink, e).as_str()); + add_text_to_text_view(text_view_errors, format!("{} {}, reason {}", fl!("hardlink_failed"), file_to_hardlink, e).as_str()); continue; } } @@ -190,21 +190,21 @@ pub fn hardlink_symlink(tree_view: >k::TreeView, column_file_name: i32, column 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, format!("Failed to remove file {} when creating symlink, reason {}", file_to_symlink, e).as_str()); + add_text_to_text_view(text_view_errors, format!("{} {}, reason {}", fl!("delete_file_failed"), file_to_symlink, e).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, format!("Failed to remove file {} when creating symlink, reason {}", file_to_symlink, e).as_str()); + add_text_to_text_view(text_view_errors, format!("{} {}, reason {}", fl!("delete_file_failed"), file_to_symlink, e).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, format!("Failed to remove file {} when creating symlink, reason {}", file_to_symlink, e).as_str()); + add_text_to_text_view(&text_view_errors, format!("{} {}, reason {}", fl!("delete_file_failed"), file_to_symlink, e).as_str()); continue; }; } @@ -220,12 +220,12 @@ pub fn hardlink_symlink(tree_view: >k::TreeView, column_file_name: i32, column fn create_dialog_non_group(window_main: >k::Window) -> Dialog { let dialog = gtk::Dialog::builder().title("Invalid selection with some groups").transient_for(window_main).modal(true).build(); - let button_ok = dialog.add_button("Ok", ResponseType::Ok); + let button_ok = dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); - let label: gtk::Label = gtk::Label::new(Some("In some groups there is only 1 record selected and it will be ignored.")); - let label2: gtk::Label = gtk::Label::new(Some("To be able to hard/sym link this files, at least 2 results in group needs to be selected.")); - let label3: gtk::Label = gtk::Label::new(Some("First in group is recognized as original and is not changed but second and later are modified.")); + let label: gtk::Label = gtk::Label::new(Some(&fl!("hard_sym_invalid_selection_label_1"))); + let label2: gtk::Label = gtk::Label::new(Some(&fl!("hard_sym_invalid_selection_label_2"))); + let label3: gtk::Label = gtk::Label::new(Some(&fl!("hard_sym_invalid_selection_label_3"))); button_ok.grab_focus(); @@ -323,11 +323,11 @@ pub async fn check_if_can_link_files(check_button_settings_confirm_link: >k::C } fn create_dialog_ask_for_linking(window_main: >k::Window) -> (Dialog, CheckButton) { - let dialog = gtk::Dialog::builder().title("Link confirmation").transient_for(window_main).modal(true).build(); - let button_ok = dialog.add_button("Ok", ResponseType::Ok); + let dialog = gtk::Dialog::builder().title(&fl!("hard_sym_link_title_dialog")).transient_for(window_main).modal(true).build(); + let button_ok = dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); - let label: gtk::Label = gtk::Label::new(Some("Are you sure that you want to link this files?")); + let label: gtk::Label = gtk::Label::new(Some(&fl!("hard_sym_link_label"))); let check_button: gtk::CheckButton = gtk::CheckButton::with_label("Ask next time"); check_button.set_active(true); check_button.set_halign(Align::Center); diff --git a/czkawka_gui/src/connect_button_move.rs b/czkawka_gui/src/connect_button_move.rs index fbcaa69..78d0dec 100644 --- a/czkawka_gui/src/connect_button_move.rs +++ b/czkawka_gui/src/connect_button_move.rs @@ -59,12 +59,12 @@ fn move_things(tree_view: >k::TreeView, column_file_name: i32, column_path: i3 reset_text_view(text_view_errors); let chooser = gtk::FileChooserDialog::builder() - .title("Choose folder to which you want to move duplicated files") + .title(&fl!("move_files_title_dialog")) .action(gtk::FileChooserAction::SelectFolder) .transient_for(window_main) .modal(true) .build(); - chooser.add_button("Ok", ResponseType::Ok); + chooser.add_button(&fl!("general_ok_button"), ResponseType::Ok); chooser.add_button(&fl!("general_close_button"), ResponseType::Cancel); chooser.set_select_multiple(false); @@ -77,7 +77,7 @@ fn move_things(tree_view: >k::TreeView, column_file_name: i32, column_path: i3 if response_type == gtk::ResponseType::Ok { let folders = file_chooser.filenames(); if folders.len() != 1 { - add_text_to_text_view(&text_view_errors, format!("Only 1 path must be selected to be able to copy there duplicated files, found {:?}", folders).as_str()); + add_text_to_text_view(&text_view_errors, format!("{} {:?}", &fl!("move_files_choose_more_than_1_path"), folders).as_str()); } else { let folder = folders[0].clone(); if let Some(column_color) = column_color { @@ -161,19 +161,19 @@ fn move_files_common(selected_rows: &[TreePath], model: >k::ListStore, column_ 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, &fs_extra::dir::CopyOptions::new()) { - messages += format!("Failed to move folder, reason {}\n", e).as_str(); + messages += format!("{}, reason {}\n", fl!("move_folder_failed"), e).as_str(); continue 'next_result; } } else { if let Err(e) = fs_extra::file::move_file(&thing, &destination_file, &fs_extra::file::CopyOptions::new()) { - messages += format!("Failed to move file, reason {}\n", e).as_str(); + messages += format!("{}, reason {}\n", fl!("move_file_failed"), e).as_str(); continue 'next_result; } } model.remove(&iter); moved_files += 1; } - entry_info.set_text(format!("Properly moved {}/{} files/folders", moved_files, selected_rows.len()).as_str()); + entry_info.set_text(format!("{} {}/{} {}", fl!("move_stats_1"), moved_files, selected_rows.len(), fl!("move_stats_2")).as_str()); text_view_errors.buffer().unwrap().set_text(messages.as_str()); } diff --git a/czkawka_gui/src/connect_button_save.rs b/czkawka_gui/src/connect_button_save.rs index 31e674a..f508c2c 100644 --- a/czkawka_gui/src/connect_button_save.rs +++ b/czkawka_gui/src/connect_button_save.rs @@ -6,6 +6,7 @@ use gtk::prelude::*; use gtk::{Button, Entry}; use czkawka_core::common_traits::SaveResults; +use czkawka_core::fl; use crate::gui_data::GuiData; use crate::notebook_enums::*; @@ -86,7 +87,7 @@ pub fn connect_button_save(gui_data: &GuiData) { } fn post_save_things(file_name: &str, type_of_tab: &NotebookMainEnum, shared_buttons: &Rc>>>, entry_info: &Entry, buttons_save: &Button) { - entry_info.set_text(format!("Saved results to file {}", file_name).as_str()); + entry_info.set_text(format!("{} {}", fl!("save_results_to_file"), file_name).as_str()); // Set state { buttons_save.hide(); diff --git a/czkawka_gui/src/connect_button_search.rs b/czkawka_gui/src/connect_button_search.rs index f2782b4..47ba56d 100644 --- a/czkawka_gui/src/connect_button_search.rs +++ b/czkawka_gui/src/connect_button_search.rs @@ -454,7 +454,7 @@ pub fn connect_button_search( }); } else { set_buttons(&mut *shared_buttons.borrow_mut().get_mut(&NotebookMainEnum::SameMusic).unwrap(), &buttons_array, &buttons_names); - entry_info.set_text("ERROR: You must select at least one checkbox with music searching types."); + entry_info.set_text(&fl!("search_not_choosing_any_music")); show_dialog.store(false, Ordering::Relaxed); } } diff --git a/czkawka_gui/src/connect_change_language.rs b/czkawka_gui/src/connect_change_language.rs index 7ff0bb7..1d6193c 100644 --- a/czkawka_gui/src/connect_change_language.rs +++ b/czkawka_gui/src/connect_change_language.rs @@ -29,7 +29,7 @@ fn change_language(gui_data: &GuiData) { } gui_data.update_language(); - // Try to use default OS + // Try to use default OS language // let requested_languages = DesktopLanguageRequester::requested_languages(); // let localizers = vec![("czkawka_gui", crate::localizer::localizer())]; // diff --git a/czkawka_gui/src/connect_selection_of_directories.rs b/czkawka_gui/src/connect_selection_of_directories.rs index 214660e..e8fe2c6 100644 --- a/czkawka_gui/src/connect_selection_of_directories.rs +++ b/czkawka_gui/src/connect_selection_of_directories.rs @@ -78,10 +78,10 @@ pub fn connect_selection_of_directories(gui_data: &GuiData) { } fn add_chosen_directories(window_main: &Window, tree_view: &TreeView, excluded_items: bool) { - let folders_to = if excluded_items { "Folders to exclude" } else { "Folders to include" }; + let folders_to = if excluded_items { fl!("exclude_folders_dialog_title") } else { fl!("include_folders_dialog_title") }; - let chooser = gtk::FileChooserDialog::builder().title(folders_to).action(gtk::FileChooserAction::SelectFolder).transient_for(window_main).modal(true).build(); - chooser.add_button("Ok", ResponseType::Ok); + let chooser = gtk::FileChooserDialog::builder().title(&folders_to).action(gtk::FileChooserAction::SelectFolder).transient_for(window_main).modal(true).build(); + chooser.add_button(&fl!("general_ok_button"), ResponseType::Ok); chooser.add_button(&fl!("general_close_button"), ResponseType::Cancel); chooser.set_select_multiple(true); @@ -104,8 +104,8 @@ fn add_chosen_directories(window_main: &Window, tree_view: &TreeView, excluded_i } fn add_manually_directories(window_main: &Window, tree_view: &TreeView) { - let dialog = gtk::Dialog::builder().title("Add directory manually").transient_for(window_main).modal(true).build(); - dialog.add_button("Ok", ResponseType::Ok); + let dialog = gtk::Dialog::builder().title(&fl!("include_manually_directories_dialog_title")).transient_for(window_main).modal(true).build(); + dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); let entry: gtk::Entry = gtk::Entry::new(); diff --git a/czkawka_gui/src/connect_settings.rs b/czkawka_gui/src/connect_settings.rs index a518265..866c953 100644 --- a/czkawka_gui/src/connect_settings.rs +++ b/czkawka_gui/src/connect_settings.rs @@ -1,5 +1,6 @@ use czkawka_core::common_messages::Messages; use czkawka_core::duplicate::HashType; +use czkawka_core::fl; use directories_next::ProjectDirs; use gtk::prelude::*; use gtk::{LabelBuilder, ResponseType, Window}; @@ -89,7 +90,7 @@ pub fn connect_settings(gui_data: &GuiData) { let entry_settings_cache_file_minimal_size = gui_data.settings.entry_settings_cache_file_minimal_size.clone(); button_settings_duplicates_clear_cache.connect_clicked(move |_| { - let dialog = create_clear_cache_dialog("duplicates", &settings_window); + let dialog = create_clear_cache_dialog(fl!("cache_clear_duplicates_title"), &settings_window); dialog.show_all(); let text_view_errors = text_view_errors.clone(); @@ -117,7 +118,7 @@ pub fn connect_settings(gui_data: &GuiData) { } } - messages.messages.push("Properly cleared cache".to_string()); + messages.messages.push(fl!("cache_properly_cleared")); text_view_errors.buffer().unwrap().set_text(messages.create_messages_text().as_str()); } } @@ -131,7 +132,7 @@ pub fn connect_settings(gui_data: &GuiData) { let text_view_errors = gui_data.text_view_errors.clone(); button_settings_similar_images_clear_cache.connect_clicked(move |_| { - let dialog = create_clear_cache_dialog("similar images", &settings_window); + let dialog = create_clear_cache_dialog(fl!("cache_clear_similar_images_title"), &settings_window); dialog.show_all(); let text_view_errors = text_view_errors.clone(); @@ -149,7 +150,7 @@ pub fn connect_settings(gui_data: &GuiData) { } } - messages.messages.push("Properly cleared cache".to_string()); + messages.messages.push(fl!("cache_properly_cleared")); text_view_errors.buffer().unwrap().set_text(messages.create_messages_text().as_str()); } dialog.close(); @@ -162,7 +163,7 @@ pub fn connect_settings(gui_data: &GuiData) { let text_view_errors = gui_data.text_view_errors.clone(); button_settings_similar_videos_clear_cache.connect_clicked(move |_| { - let dialog = create_clear_cache_dialog("similar videos", &settings_window); + let dialog = create_clear_cache_dialog(fl!("cache_clear_similar_videos_title"), &settings_window); dialog.show_all(); let text_view_errors = text_view_errors.clone(); @@ -174,7 +175,7 @@ pub fn connect_settings(gui_data: &GuiData) { czkawka_core::similar_videos::save_hashes_to_file(&cache_entries, &mut messages); } - messages.messages.push("Properly cleared cache".to_string()); + messages.messages.push(fl!("cache_properly_cleared")); text_view_errors.buffer().unwrap().set_text(messages.create_messages_text().as_str()); } dialog.close(); @@ -184,17 +185,15 @@ pub fn connect_settings(gui_data: &GuiData) { } } -fn create_clear_cache_dialog(title_str: &str, window_settings: &Window) -> gtk::Dialog { - let dialog = gtk::Dialog::builder().title(format!("Clearing {} cache", title_str).as_str()).transient_for(window_settings).build(); - dialog.add_button("OK", ResponseType::Ok); - dialog.add_button("Cancel", ResponseType::Cancel); +fn create_clear_cache_dialog(title_str: String, window_settings: &Window) -> gtk::Dialog { + let dialog = gtk::Dialog::builder().title(&title_str).transient_for(window_settings).build(); + dialog.add_button(&fl!("general_ok_button"), ResponseType::Ok); + dialog.add_button(&fl!("general_close_button"), ResponseType::Cancel); - let label = LabelBuilder::new().label(format!("Do you want to clear {} cache from outdated entries?", title_str).as_str()).build(); - let label2 = LabelBuilder::new().label("This operation will remove all cache entries which points to invalid files.").build(); - let label3 = LabelBuilder::new().label("This may speedup a little loading/saving to cache.").build(); - let label4 = LabelBuilder::new() - .label("WARNING: Operation will remove all cached data from unplugged external drives, so hash will need to be generated again.") - .build(); + let label = LabelBuilder::new().label(&fl!("cache_clear_message_label_1")).build(); + let label2 = LabelBuilder::new().label(&fl!("cache_clear_message_label_2")).build(); + let label3 = LabelBuilder::new().label(&fl!("cache_clear_message_label_3")).build(); + let label4 = LabelBuilder::new().label(&fl!("cache_clear_message_label_4")).build(); let internal_box = get_dialog_box_child(&dialog); internal_box.add(&label); diff --git a/czkawka_gui/src/connect_similar_image_size_change.rs b/czkawka_gui/src/connect_similar_image_size_change.rs index 1304f05..f091d97 100644 --- a/czkawka_gui/src/connect_similar_image_size_change.rs +++ b/czkawka_gui/src/connect_similar_image_size_change.rs @@ -1,10 +1,13 @@ use gtk::prelude::*; -use czkawka_core::similar_images::SIMILAR_VALUES; +use czkawka_core::similar_images::{get_string_from_similarity, Similarity, SIMILAR_VALUES}; use crate::gui_data::GuiData; pub fn connect_similar_image_size_change(gui_data: &GuiData) { + let label_similar_images_minimal_similarity = gui_data.main_notebook.label_similar_images_minimal_similarity.clone(); + label_similar_images_minimal_similarity.set_text(&get_string_from_similarity(&Similarity::Similar(SIMILAR_VALUES[0][5]), 8)); + { let radio_button_similar_hash_size_8 = gui_data.main_notebook.radio_button_similar_hash_size_8.clone(); let label_similar_images_minimal_similarity = gui_data.main_notebook.label_similar_images_minimal_similarity.clone(); @@ -12,7 +15,7 @@ pub fn connect_similar_image_size_change(gui_data: &GuiData) { radio_button_similar_hash_size_8.connect_toggled(move |_| { scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[0][5] as f64); scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[0][5] as f64); - label_similar_images_minimal_similarity.set_text(" Minimal "); + label_similar_images_minimal_similarity.set_text(&get_string_from_similarity(&Similarity::Similar(SIMILAR_VALUES[0][5]), 8)); }); } { @@ -22,7 +25,7 @@ pub fn connect_similar_image_size_change(gui_data: &GuiData) { radio_button_similar_hash_size_16.connect_toggled(move |_| { scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[1][5] as f64); scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[1][5] as f64); - label_similar_images_minimal_similarity.set_text(" Very Small "); + label_similar_images_minimal_similarity.set_text(&get_string_from_similarity(&Similarity::Similar(SIMILAR_VALUES[1][5]), 16)); }); } { @@ -32,7 +35,7 @@ pub fn connect_similar_image_size_change(gui_data: &GuiData) { radio_button_similar_hash_size_32.connect_toggled(move |_| { scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[2][5] as f64); scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[2][5] as f64); - label_similar_images_minimal_similarity.set_text(" Small "); + label_similar_images_minimal_similarity.set_text(&get_string_from_similarity(&Similarity::Similar(SIMILAR_VALUES[2][5]), 32)); }); } { @@ -42,7 +45,7 @@ pub fn connect_similar_image_size_change(gui_data: &GuiData) { radio_button_similar_hash_size_64.connect_toggled(move |_| { scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[3][5] as f64); scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[3][5] as f64); - label_similar_images_minimal_similarity.set_text(" Medium "); + label_similar_images_minimal_similarity.set_text(&get_string_from_similarity(&Similarity::Similar(SIMILAR_VALUES[3][5]), 64)); }); } } diff --git a/czkawka_gui/src/help_functions.rs b/czkawka_gui/src/help_functions.rs index 411db4d..c38e5b0 100644 --- a/czkawka_gui/src/help_functions.rs +++ b/czkawka_gui/src/help_functions.rs @@ -10,12 +10,12 @@ use czkawka_core::common_messages::Messages; use czkawka_core::duplicate::DuplicateFinder; use czkawka_core::empty_files::EmptyFiles; use czkawka_core::empty_folder::EmptyFolder; -use czkawka_core::invalid_symlinks; use czkawka_core::invalid_symlinks::InvalidSymlinks; use czkawka_core::same_music::SameMusic; use czkawka_core::similar_images::SimilarImages; use czkawka_core::similar_videos::SimilarVideos; use czkawka_core::temporary::Temporary; +use czkawka_core::{fl, invalid_symlinks}; use crate::notebook_enums::{NotebookMainEnum, NUMBER_OF_NOTEBOOK_MAIN_TABS}; @@ -357,7 +357,7 @@ pub fn split_path(path: &Path) -> (String, String) { pub fn print_text_messages_to_text_view(text_messages: &Messages, text_view: >k::TextView) { let mut messages: String = String::from(""); if !text_messages.messages.is_empty() { - messages += format!("############### MESSAGES({}) ###############\n", text_messages.messages.len()).as_str(); + messages += format!("############### {}({}) ###############\n", fl!("text_view_messages"), text_messages.messages.len()).as_str(); } for text in &text_messages.messages { messages += text.as_str(); @@ -367,7 +367,7 @@ pub fn print_text_messages_to_text_view(text_messages: &Messages, text_view: > // messages += "\n"; // } if !text_messages.warnings.is_empty() { - messages += format!("############### WARNINGS({}) ###############\n", text_messages.warnings.len()).as_str(); + messages += format!("############### {}({}) ###############\n", fl!("text_view_warnings"), text_messages.warnings.len()).as_str(); } for text in &text_messages.warnings { messages += text.as_str(); @@ -377,7 +377,7 @@ pub fn print_text_messages_to_text_view(text_messages: &Messages, text_view: > // messages += "\n"; // } if !text_messages.errors.is_empty() { - messages += format!("############### ERRORS({}) ###############\n", text_messages.errors.len()).as_str(); + messages += format!("############### {}({}) ###############\n", fl!("text_view_errors"), text_messages.errors.len()).as_str(); } for text in &text_messages.errors { messages += text.as_str(); @@ -423,10 +423,10 @@ pub fn hide_all_buttons(buttons_array: &[Widget]) { } } -pub fn get_text_from_invalid_symlink_cause(error: &invalid_symlinks::ErrorType) -> &str { +pub fn get_text_from_invalid_symlink_cause(error: &invalid_symlinks::ErrorType) -> String { match error { - invalid_symlinks::ErrorType::InfiniteRecursion => "Infinite recursion", - invalid_symlinks::ErrorType::NonExistentFile => "Non existent destination file", + invalid_symlinks::ErrorType::InfiniteRecursion => fl!("invalid_symlink_infinite_recursion"), + invalid_symlinks::ErrorType::NonExistentFile => fl!("invalid_symlink_non_existent_destination"), } } diff --git a/czkawka_gui/src/main.rs b/czkawka_gui/src/main.rs index f5ba92f..2ff621e 100644 --- a/czkawka_gui/src/main.rs +++ b/czkawka_gui/src/main.rs @@ -74,7 +74,7 @@ mod taskbar_progress_win; mod tests; fn main() { - let application = gtk::Application::builder().application_id("com.github.qarmin").build(); + let application = gtk::Application::builder().application_id("pl.qarmin.czkawka").build(); application.connect_activate(|application| { let mut gui_data: GuiData = GuiData::new_with_application(application); diff --git a/czkawka_gui/src/opening_selecting_records.rs b/czkawka_gui/src/opening_selecting_records.rs index 6daa122..be45bd4 100644 --- a/czkawka_gui/src/opening_selecting_records.rs +++ b/czkawka_gui/src/opening_selecting_records.rs @@ -83,9 +83,6 @@ fn handle_tree_keypress(tree_view: >k::TreeView, key_code: u32, name_column: i } pub fn select_function_duplicates(_tree_selection: >k::TreeSelection, tree_model: >k::TreeModel, tree_path: >k::TreePath, _is_path_currently_selected: bool) -> bool { - // let name = tree_model.value(&tree_model.iter(tree_path).unwrap(),ColumnsDuplicates::Name as i32).get::().unwrap(); - // let path = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsDuplicates::Path as i32).get::().unwrap(); - // let modification = tree_model.value(&tree_model.iter(tree_path).unwrap(),ColumnsDuplicates::Modification as i32).get::().unwrap(); let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsDuplicates::Color as i32).get::().unwrap(); if color == HEADER_ROW_COLOR { diff --git a/i18n/en/czkawka_gui.ftl b/i18n/en/czkawka_gui.ftl index 8a8f77f..3dff9f5 100644 --- a/i18n/en/czkawka_gui.ftl +++ b/i18n/en/czkawka_gui.ftl @@ -374,6 +374,59 @@ saving_loading_loading_success = Properly loaded configuration from file progress_current_stage = Current Stage:{" "} progress_all_stages = All Stages:{" "} +# Invalid symlinks +invalid_symlink_infinite_recursion = Infinite recursion +invalid_symlink_non_existent_destination = Non existent destination file + # Other searching_for_data = Searching data, it may take a while, please wait... +text_view_messages = MESSAGES +text_view_warnings = WARNINGS +text_view_errors = ERRORS +# Various dialog +dialogs_ask_next_time = Ask next time +reason_of_error = reason + +delete_file_failed = Failed to remove file + +delete_title_dialog = Delete confirmation +delete_question_label = Are you sure that you want to delete files? +delete_all_files_in_group_title = Confirmation of deleting all files in group +delete_all_files_in_group_label1 = In some groups there are selected all records. +delete_all_files_in_group_label2 = Are you sure that you want to delete them? +delete_folder_failed_1 = Failed to remove folder +delete_folder_failed_2 = because folder doesn't exists, you don't have permissions or isn't empty. + +hardlink_failed = Failed to hardlink +hard_sym_invalid_selection_title_dialog = Invalid selection with some groups +hard_sym_invalid_selection_label_1 = In some groups there is only 1 record selected and it will be ignored. +hard_sym_invalid_selection_label_2 = To be able to hard/sym link this files, at least 2 results in group needs to be selected. +hard_sym_invalid_selection_label_3 = First in group is recognized as original and is not changed but second and later are modified. +hard_sym_link_title_dialog = Link confirmation +hard_sym_link_label = Are you sure that you want to link this files? + +move_folder_failed = Failed to move folder +move_file_failed = Failed to move file +move_files_title_dialog = Choose folder to which you want to move duplicated files +move_files_choose_more_than_1_path = Only 1 path must be selected to be able to copy there duplicated files, found +move_stats_1 = Properly moved +move_stats_2 = items + +save_results_to_file = Saved results to file + +search_not_choosing_any_music = ERROR: You must select at least one checkbox with music searching types. + +include_folders_dialog_title = Folders to include +exclude_folders_dialog_title = Folders to exclude + +include_manually_directories_dialog_title = Add directory manually + +cache_properly_cleared = Properly cleared cache +cache_clear_duplicates_title = Clearing duplicates cache +cache_clear_similar_images_title = Clearing similar images cache +cache_clear_similar_videos_title = Clearing similar videos cache +cache_clear_message_label_1 = Do you want to clear cache from outdated entries? +cache_clear_message_label_2 = This operation will remove all cache entries which points to invalid files. +cache_clear_message_label_3 = This may speedup a little loading/saving to cache. +cache_clear_message_label_4 = WARNING: Operation will remove all cached data from unplugged external drives, so hash will need to be generated again. diff --git a/i18n/pl/czkawka_gui.ftl b/i18n/pl/czkawka_gui.ftl index 816abe8..069b62e 100644 --- a/i18n/pl/czkawka_gui.ftl +++ b/i18n/pl/czkawka_gui.ftl @@ -356,11 +356,64 @@ progress_analyzed_partial_hash = Przeanalizowano częściowy hash progress_current_stage = Aktualny Etap:{" "} progress_all_stages = Wszystkie Etapy:{" "} - -# Other -searching_for_data = Przeszukiwanie dysku, może to potrwać chwilę, proszę czekać... - # Saving loading saving_loading_saving_success = Zapisano konfigurację do pliku saving_loading_reset_configuration = Przywrócono domyślą konfigurację. saving_loading_loading_success = Poprawnie załadowano konfigurację z pliku + +# Invalid symlinks +invalid_symlink_infinite_recursion = Nieskończona rekurencja +invalid_symlink_non_existent_destination = Nie istniejący docelowy plik + +# Other +searching_for_data = Przeszukiwanie dysku, może to potrwać chwilę, proszę czekać... +text_view_messages = WIADOMOŚCI +text_view_warnings = OSTRZEŻENIA +text_view_errors = BŁĘDY + +# Various dialog +dialogs_ask_next_time = Pytaj następnym razem +reason_of_error = powód + +delete_file_failed = Nie udało się usunąć pliku + +delete_title_dialog = Potwierdzenie usunięcia +delete_question_label = Czy na pewno usunąć te pliki? +delete_all_files_in_group_title = Potwierdzenie usunięcia wszystkich plików w grupie +delete_all_files_in_group_label1 = W niektórych grupach zaznaczono wszystkie rekordy. +delete_all_files_in_group_label2 = Czy na pewno je usunąć? +delete_folder_failed_1 = Nie udało się usunąć folderu +delete_folder_failed_2 = ponieważ nie istnieje, uprawnienia nie są wystarczające lub nie jest pusty. + +hardlink_failed = Nie udało się utworzyć twardego dowiązania +hard_sym_invalid_selection_title_dialog = Niepoprawne zaznaczenie w niektórych grupach +hard_sym_invalid_selection_label_1 = W niektórych grupach zaznaczono tylko 1 rekord który zostanie zignorowany. +hard_sym_invalid_selection_label_2 = Aby móc używać dowiązań, należy zaznaczyć przynajmniej 2 obiekty w danej grupie. +hard_sym_invalid_selection_label_3 = Pierwszy pozostaje nienaruszony a drugi i kolejne są dowiązywane do tego pierwszego. +hard_sym_link_title_dialog = Potwierdzenie dowiązania +hard_sym_link_label = Czy na pewno dowiązać te pliki? + +move_folder_failed = Nie można przenieść folderu +move_file_failed = Nie można przenieść pliku +move_files_title_dialog = Wybierz folder do którego zostaną przeniesione pliki +move_files_choose_more_than_1_path = Można przenieść elementy tylko do 1 folderu, zaznaczono +move_stats_1 = Poprawnie przeniesiono +move_stats_2 = elementów + +save_results_to_file = Zapisano wyniki do pliku + +search_not_choosing_any_music = BŁĄD: Musisz zaznaczyć przynajmniej jeden pole, według którego będą wyszukiwane podobne pliki muzyczne. + +include_folders_dialog_title = Foldery do przeszukiwania +exclude_folders_dialog_title = Foldery do ignorowania + +include_manually_directories_dialog_title = Dodaj katalogi ręcznie + +cache_properly_cleared = Poprawnie wyczyszczono pamięc podręczną +cache_clear_duplicates_title = Czyszczenie pamięci podręcznej duplikatów +cache_clear_similar_images_title = Czyszczenie pamięci podręcznej podobnych obrazów +cache_clear_similar_videos_title = Czyszczenie pamięci podręcznej podobnych plików Wideo +cache_clear_message_label_1 = Czy na pewno chcesz oczyścić pamięć podręczną z przestarzałych wpisów? +cache_clear_message_label_2 = Ta operacja usunie wszystkie rekordy, które wskazują na nieistniejące pliki. +cache_clear_message_label_3 = Może spowodować to przyspieszenie ładowania i zapisywania danych do pamięci w trakcie skanowania. +cache_clear_message_label_4 = OSTRZEŻENIE: Usunięte zostaną wszystkie rekordy z odpiętych dyskach zewnętrznych i konieczne będzie ich ponowne sprawdzenie po podpięciu. diff --git a/instructions/Translations.md b/instructions/Translations.md index 5df4d6f..75086aa 100644 --- a/instructions/Translations.md +++ b/instructions/Translations.md @@ -59,9 +59,4 @@ Next new record must be added to array. combo_box_text: "Polski (pl)", short_text: "pl", }, -``` - - - - - +``` \ No newline at end of file