Fix translation for luks

This commit is contained in:
Ward from fusion-voyager-3 2024-08-21 01:58:58 +03:00
parent c34958f256
commit 825f1d117e
4 changed files with 81 additions and 49 deletions

7
Cargo.lock generated
View File

@ -934,6 +934,7 @@ dependencies = [
"rust-i18n", "rust-i18n",
"serde", "serde",
"serde_json", "serde_json",
"strfmt",
"sys-locale", "sys-locale",
"time", "time",
"vte4", "vte4",
@ -1227,6 +1228,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "strfmt"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a8348af2d9fc3258c8733b8d9d8db2e56f54b2363a4b5b81585c7875ed65e65"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"

View File

@ -19,3 +19,4 @@ serde = { version = "1.0", features = ["derive"] }
gnome-desktop = "0.4.2" gnome-desktop = "0.4.2"
rust-i18n = "3.0.1" rust-i18n = "3.0.1"
sys-locale = "0.3.1" sys-locale = "0.3.1"
strfmt = "0.2.4"

View File

@ -1,49 +1,32 @@
{ {
"application_name": "PikaOS Installer", "application_name": "PikaOS Installer",
"welcome_page_subtitle": "Welcome to PikaOS", "welcome_page_subtitle": "Welcome to PikaOS IV",
"live_media_button_label": "Use PikaOS in Live media", "live_media_button_label": "Use PikaOS in Live Media",
"install_media_button_label": "Install Distro to System", "install_media_button_label": "Install Distro to System",
"welcome_page_title": "Welcome", "welcome_page_title": "Welcome",
"back": "Back", "back": "Back",
"next": "Next", "next": "Next",
"timezone_page_subtitle": "Select a Timezone", "timezone_page_subtitle": "Select a Timezone",
"please_select_timezone": "Please select a Time Zone for the system to use", "please_select_timezone": "Please select a Time Zone for The System to Use",
"no_timezone_select": "No Time Zone selected", "no_timezone_select": "No Time Zone selected",
"timezone_page_title": "Time Zone", "timezone_page_title": "Time Zone",
"partitioning_page_subtitle": "Choose an install method", "partitioning_page_subtitle": "Choose a Disk Partitioning Method",
"manual_method_button_label": "Manually Partition The Drive", "manual_method_button_label": "Manually Partition The Drive",
"automatic_method_button_label": "Automatically Partition\nThe Drive", "automatic_method_button_label": "Automatically Partition\nThe Drive",
"manual_partitioning_page_title": "Manual Disk Partitioning", "manual_partitioning_page_title": "Manual Disk Partitioning",
"manual_partitioning_page_subtitle": "Use This Page to Create a Custom Filesystem Table for PikaOS to install into.\nNotes:\n - This Installer Doesn't Erase Any Data Automatically, Format Your Drives MANUALLY Via The Disk Utility.\n - To Add a linux-swap Partition Set Mountpoint to [SWAP]", "manual_partitioning_page_subtitle": "Use This Page to Create a Custom Filesystem Table for PikaOS to install into.\nNotes:\n - This Installer Doesn't Erase Any Data Automatically, Format Your Drives MANUALLY Via The Disk Utility.\n - To Add a linux-swap Partition Set Mountpoint to [SWAP]",
"fstab_status_valid": "Filesystem Table Status: All entries are valid!",
"partition_row_subtitle_needs_mapper": "This partition needs a mapper!", "partition_row_subtitle_needs_mapper": "This partition needs a mapper!",
"fstab_multiple_part_mountpoint_err": "Filesystem Table Error: Multiple partitions are configured to the same mountpoint!",
"fstab_no_mountpoint_err": "Filesystem Table Error: One or more partitions don't have a mountpoint configured!",
"fstab_no_partition_err": "Filesystem Table Error: One or more entries don't have a partition configured!",
"fstab_badfs": "Filesystem Table Error: Invalid filesystem: (/dev/",
"partition_row_subtitle_efi_fs_small": "EFI Must at least be 512MBs!",
"partition_row_subtitle_efi_fs_bad": "EFI Must be FAT32/vFAT",
"partition_row_subtitle_boot_fs_small": "Boot Must at least be 1GBs!",
"partition_row_subtitle_boot_fs_bad": "Boot Must be EXT4",
"partition_row_subtitle_root_fs_small": "Root Must at least be 26GBs!",
"partition_row_subtitle_root_fs_bad": "Root Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs",
"fstab_badfs_swap": "Swap must be linux-swap",
"fstab_bad_mountpoint": "Filesystem Table Error: Invalid mountpoint: (",
"fstab_bad_mountpoint_msg": ") Is not a valid mountpoint!",
"language_page_title": "Select a Language", "language_page_title": "Select a Language",
"language_page_subtitle": "Please Select a Locale for The System to Use", "language_page_subtitle": "Please Select a Locale for The System to Use",
"no_locale_selected": "No Locale selected", "no_locale_selected": "No Locale Selected",
"language": "Language", "language": "Language",
"keyboard_page_subtitle": "Select a keyboard", "keyboard_page_subtitle": "Select a keyboard",
"please_select_keyboard": "Please select a Keyboard layout for the system to use", "please_select_keyboard": "Please select a Keyboard layout for the system to use",
"no_keyboard_selected": "No Keyboard Layout selected", "no_keyboard_selected": "No Keyboard Layout selected",
"keyboard_test_entry_title": "Test Your Keyboard here!", "keyboard_test_entry_title": "Test Your Keyboard here!",
"keyboard_page_title": "Keyboard", "keyboard_page_title": "Keyboard",
"luks_password_for": "LUKS Password for ", "crypttab_dialog_response_crypttab_dialog_boot": "Unlock on Boot Manually",
"luks_how_should": "How should ", "crypttab_dialog_response_crypttab_dialog_auto": "Unlock Automatically with Root Unlock",
"be_added_crypttab": " be added to /etc/crypttab?",
"unlock_boot_manually": "Unlock on boot manually",
"unlock_boot_manual": "Automatic Unlock with root unlock",
"sit_back_relax": "Sit back, Relax, and watch the show.", "sit_back_relax": "Sit back, Relax, and watch the show.",
"language_detail": "Language:", "language_detail": "Language:",
"timezone_detail": "Timezone:", "timezone_detail": "Timezone:",
@ -98,8 +81,25 @@
"advanced_home_seperation_selection_checkbutton_partition_label": "Yes, via a Partition", "advanced_home_seperation_selection_checkbutton_partition_label": "Yes, via a Partition",
"advanced_home_seperation_selection_checkbutton_none_label": "No", "advanced_home_seperation_selection_checkbutton_none_label": "No",
"fs_unknown": "Unknown", "fs_unknown": "Unknown",
"drive_mount_add_button_label": "Add A Custom FIlesystem Entry", "drive_mount_add_button_label": "Add A Custom Filesystem Entry",
"open_disk_utility_button_label": "Open Disk Partitioning Utility", "open_disk_utility_button_label": "Open Disk Partitioning Utility",
"filesystem_table_refresh_button_label": "Refresh Filesystem Table", "filesystem_table_refresh_button_label": "Refresh Filesystem Table",
"filesystem_table_validate_button_label": "Validate Filesystem Table" "filesystem_table_validate_button_label": "Validate Filesystem Table",
"crypttab_password_entry_row_title": "LUKS Password for {LUKS_NAME}",
"crypttab_dialog_heading": "Select an Unlock Method {LUKS_NAME} Crypt Entry",
"crypttab_password_status_label_label_checking": "Verifying LUKS Password...",
"crypttab_password_status_label_label_wrong_password": "Error: Incorrect Password",
"partition_row_subtitle_efi_fs_small": "EFI Must at least be 512MBs!",
"partition_row_subtitle_efi_fs_bad": "EFI Must be FAT32/vFAT",
"partition_row_subtitle_boot_fs_small": "Boot Must at least be 1GBs!",
"partition_row_subtitle_boot_fs_bad": "Boot Must be EXT4",
"partition_row_subtitle_root_fs_small": "Root Must at least be 26GBs!",
"partition_row_subtitle_root_fs_bad": "Root Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs",
"partition_row_subtitle_swap_fs_bad": "Swap must be linux-swap",
"partition_method_manual_mountpoint_duplicate_label_label": "Filesystem Table Error: Multiple Partitions Are Configured to The Same Mountpoint!",
"partition_method_manual_mountpoint_empty_error_label_label": "Filesystem Table Error: One or More Partitions Don't Have a Mountpoint configured!",
"partition_method_manual_partition_empty_error_label_label": "Filesystem Table Error: One or More Entries Don't Have a Partition configured!",
"partition_method_manual_mountpoint_invalid_error_label_label": "Filesystem Table Error: One or More Entries Are Configured to an Invalid Mountpoint!",
"partition_method_manual_valid_label_label": "Filesystem Table is Valid!"
} }

View File

@ -28,8 +28,7 @@ pub fn manual_partitioning_page(
manual_partitioning_page.set_back_visible(true); manual_partitioning_page.set_back_visible(true);
manual_partitioning_page.set_next_visible(true); manual_partitioning_page.set_next_visible(true);
manual_partitioning_page.set_back_sensitive(true); manual_partitioning_page.set_back_sensitive(true);
//manual_partitioning_page.set_next_sensitive(false); manual_partitioning_page.set_next_sensitive(false);
manual_partitioning_page.set_next_sensitive(true);
let partition_array_refcell = Rc::new(RefCell::new(get_partitions())); let partition_array_refcell = Rc::new(RefCell::new(get_partitions()));
let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default()); let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default());
@ -80,14 +79,12 @@ pub fn manual_partitioning_page(
); );
let open_disk_utility_button = gtk::Button::builder() let open_disk_utility_button = gtk::Button::builder()
.label(t!("open_disk_utility_button_label"))
.margin_top(10) .margin_top(10)
.margin_end(5) .margin_end(5)
.halign(gtk::Align::Start) .halign(gtk::Align::Start)
.build(); .build();
let filesystem_table_refresh_button = gtk::Button::builder() let filesystem_table_refresh_button = gtk::Button::builder()
.label(t!("filesystem_table_refresh_button_label"))
.margin_top(10) .margin_top(10)
.margin_end(5) .margin_end(5)
.halign(gtk::Align::Start) .halign(gtk::Align::Start)
@ -95,7 +92,6 @@ pub fn manual_partitioning_page(
filesystem_table_refresh_button.add_css_class("destructive-action"); filesystem_table_refresh_button.add_css_class("destructive-action");
let filesystem_table_validate_button = gtk::Button::builder() let filesystem_table_validate_button = gtk::Button::builder()
.label(t!("filesystem_table_validate_button_label"))
.margin_top(10) .margin_top(10)
.hexpand(true) .hexpand(true)
.halign(gtk::Align::End) .halign(gtk::Align::End)
@ -135,6 +131,13 @@ pub fn manual_partitioning_page(
.build(); .build();
partition_method_manual_mountpoint_duplicate_label.add_css_class("small_error_text"); partition_method_manual_mountpoint_duplicate_label.add_css_class("small_error_text");
let partition_method_manual_valid_label = gtk::Label::builder()
.halign(gtk::Align::Start)
.valign(gtk::Align::End)
.visible(false)
.build();
partition_method_manual_valid_label.add_css_class("small_valid_text");
utility_buttons_box.append(&open_disk_utility_button); utility_buttons_box.append(&open_disk_utility_button);
utility_buttons_box.append(&filesystem_table_refresh_button); utility_buttons_box.append(&filesystem_table_refresh_button);
utility_buttons_box.append(&filesystem_table_validate_button); utility_buttons_box.append(&filesystem_table_validate_button);
@ -207,6 +210,8 @@ pub fn manual_partitioning_page(
#[strong] #[strong]
partition_method_manual_fstab_entry_array_refcell, partition_method_manual_fstab_entry_array_refcell,
#[strong] #[strong]
manual_partitioning_page,
#[strong]
partition_method_manual_luks_enabled_refcell, partition_method_manual_luks_enabled_refcell,
#[strong] #[strong]
partition_method_manual_crypttab_entry_array_refcell, partition_method_manual_crypttab_entry_array_refcell,
@ -220,6 +225,8 @@ pub fn manual_partitioning_page(
partition_method_manual_partition_empty_error_label, partition_method_manual_partition_empty_error_label,
#[weak] #[weak]
partition_method_manual_mountpoint_duplicate_label, partition_method_manual_mountpoint_duplicate_label,
#[strong]
partition_method_manual_valid_label,
move |_| { move |_| {
let errored = Arc::new(AtomicBool::new(false)); let errored = Arc::new(AtomicBool::new(false));
@ -228,24 +235,23 @@ pub fn manual_partitioning_page(
(*partition_method_manual_crypttab_entry_array_refcell.borrow_mut()) = Vec::new(); (*partition_method_manual_crypttab_entry_array_refcell.borrow_mut()) = Vec::new();
let mut seen_mountpoints = HashSet::new(); let mut seen_mountpoints = HashSet::new();
let mut seen_partitions = HashSet::new(); let mut seen_partitions = HashSet::new();
let mut seen_crypts: Rc<RefCell<HashSet<String>>> = Rc::new(RefCell::new(HashSet::new())); let seen_crypts: Rc<RefCell<HashSet<String>>> = Rc::new(RefCell::new(HashSet::new()));
partition_method_manual_mountpoint_empty_error_label.set_visible(false); partition_method_manual_mountpoint_empty_error_label.set_visible(false);
partition_method_manual_mountpoint_invalid_error_label.set_visible(false); partition_method_manual_mountpoint_invalid_error_label.set_visible(false);
partition_method_manual_partition_empty_error_label.set_visible(false); partition_method_manual_partition_empty_error_label.set_visible(false);
partition_method_manual_mountpoint_duplicate_label.set_visible(false); partition_method_manual_mountpoint_duplicate_label.set_visible(false);
partition_method_manual_valid_label.set_visible(false);
for fs_entry in generate_filesystem_table_array(&drive_mounts_adw_listbox) { for fs_entry in generate_filesystem_table_array(&drive_mounts_adw_listbox) {
let fs_entry_clone0 = fs_entry.clone(); let fs_entry_clone0 = fs_entry.clone();
if subvol_partition_array_refcell.borrow().is_empty() { if subvol_partition_array_refcell.borrow().is_empty() {
if !seen_partitions.insert(fs_entry.clone().partition.part_name) { if !seen_partitions.insert(fs_entry.clone().partition.part_name) {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
filesystem_table_refresh_button.emit_by_name_with_values("clicked", &[]);
} }
} }
if fs_entry.mountpoint == "[SWAP]" && fs_entry.partition.part_fs != "linux-swap" { if fs_entry.mountpoint == "[SWAP]" && fs_entry.partition.part_fs != "linux-swap" {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
filesystem_table_refresh_button.emit_by_name_with_values("clicked", &[]);
} }
if fs_entry.mountpoint.is_empty() { if fs_entry.mountpoint.is_empty() {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
@ -290,13 +296,21 @@ pub fn manual_partitioning_page(
#[strong] #[strong]
partition_method_manual_crypttab_entry_array_refcell, partition_method_manual_crypttab_entry_array_refcell,
#[strong] #[strong]
manual_partitioning_page,
#[strong]
fs_entry_clone0, fs_entry_clone0,
#[strong] #[strong]
seen_crypts, seen_crypts,
#[strong]
partition_method_manual_valid_label,
async move { async move {
while let Ok(state) = check_delay_receiver.recv().await { while let Ok(state) = check_delay_receiver.recv().await {
if state.load(std::sync::atomic::Ordering::Relaxed) == false { if state.load(std::sync::atomic::Ordering::Relaxed) == false {
partition_method_manual_valid_label.set_visible(true);
set_crypttab_entries(&fs_entry_clone0, &seen_crypts, window.clone(), &partition_method_manual_crypttab_entry_array_refcell, &partition_method_manual_luks_enabled_refcell); set_crypttab_entries(&fs_entry_clone0, &seen_crypts, window.clone(), &partition_method_manual_crypttab_entry_array_refcell, &partition_method_manual_luks_enabled_refcell);
manual_partitioning_page.set_next_sensitive(true);
} else {
manual_partitioning_page.set_next_sensitive(false);
} }
} }
} }
@ -311,6 +325,7 @@ pub fn manual_partitioning_page(
content_box.append(&partition_method_manual_mountpoint_invalid_error_label); content_box.append(&partition_method_manual_mountpoint_invalid_error_label);
content_box.append(&partition_method_manual_partition_empty_error_label); content_box.append(&partition_method_manual_partition_empty_error_label);
content_box.append(&partition_method_manual_mountpoint_duplicate_label); content_box.append(&partition_method_manual_mountpoint_duplicate_label);
content_box.append(&partition_method_manual_valid_label);
// //
manual_partitioning_page.connect_closure( manual_partitioning_page.connect_closure(
@ -369,6 +384,14 @@ pub fn manual_partitioning_page(
partition_method_manual_partition_empty_error_label, partition_method_manual_partition_empty_error_label,
#[weak] #[weak]
partition_method_manual_mountpoint_duplicate_label, partition_method_manual_mountpoint_duplicate_label,
#[weak]
partition_method_manual_valid_label,
#[weak]
open_disk_utility_button,
#[weak]
filesystem_table_refresh_button,
#[weak]
filesystem_table_validate_button,
move |_, _| { move |_, _| {
manual_partitioning_page.set_page_title(t!("manual_partitioning_page_title")); manual_partitioning_page.set_page_title(t!("manual_partitioning_page_title"));
manual_partitioning_page.set_page_subtitle(t!("manual_partitioning_page_subtitle")); manual_partitioning_page.set_page_subtitle(t!("manual_partitioning_page_subtitle"));
@ -379,6 +402,11 @@ pub fn manual_partitioning_page(
partition_method_manual_mountpoint_invalid_error_label.set_label(&t!("partition_method_manual_mountpoint_invalid_error_label_label")); partition_method_manual_mountpoint_invalid_error_label.set_label(&t!("partition_method_manual_mountpoint_invalid_error_label_label"));
partition_method_manual_partition_empty_error_label.set_label(&t!("partition_method_manual_partition_empty_error_label_label")); partition_method_manual_partition_empty_error_label.set_label(&t!("partition_method_manual_partition_empty_error_label_label"));
partition_method_manual_mountpoint_duplicate_label.set_label(&t!("partition_method_manual_mountpoint_duplicate_label_label")); partition_method_manual_mountpoint_duplicate_label.set_label(&t!("partition_method_manual_mountpoint_duplicate_label_label"));
partition_method_manual_valid_label.set_label(&t!("partition_method_manual_valid_label_label"));
//
open_disk_utility_button.set_label(&t!("open_disk_utility_button_label"));
filesystem_table_refresh_button.set_label(&t!("filesystem_table_refresh_button_label"));
filesystem_table_validate_button.set_label(&t!("filesystem_table_validate_button_label"))
} }
)); ));
// //
@ -515,11 +543,11 @@ fn set_crypttab_entries(
let crypttab_password_status_label = gtk::Label::builder() let crypttab_password_status_label = gtk::Label::builder()
.build(); .build();
crypttab_password_listbox.add_css_class("boxed-list"); crypttab_password_listbox.add_css_class("boxed-list");
let crypttab_password = adw::PasswordEntryRow::builder() let crypttab_password_entry_row = adw::PasswordEntryRow::builder()
.title(t!("luks_password_for").to_string() + &fs_entry.partition.part_name) .title(strfmt::strfmt(&t!("crypttab_password_entry_row_title"), &std::collections::HashMap::from([("LUKS_NAME".to_string(), fs_entry.clone().partition.part_name)])).unwrap())
.build(); .build();
crypttab_password.set_show_apply_button(true); crypttab_password_entry_row.set_show_apply_button(true);
crypttab_password_listbox.append(&crypttab_password); crypttab_password_listbox.append(&crypttab_password_entry_row);
let crypttab_password_child_box = gtk::Box::new(Orientation::Vertical, 0); let crypttab_password_child_box = gtk::Box::new(Orientation::Vertical, 0);
crypttab_password_child_box.append(&crypttab_password_listbox); crypttab_password_child_box.append(&crypttab_password_listbox);
crypttab_password_child_box.append(&crypttab_password_status_label); crypttab_password_child_box.append(&crypttab_password_status_label);
@ -529,19 +557,15 @@ fn set_crypttab_entries(
.extra_child(&crypttab_password_child_box) .extra_child(&crypttab_password_child_box)
.width_request(400) .width_request(400)
.height_request(200) .height_request(200)
.heading( .heading(strfmt::strfmt(&t!("crypttab_password_entry_row_title"), &std::collections::HashMap::from([("LUKS_NAME".to_string(), fs_entry.clone().partition.part_name)])).unwrap())
t!("luks_how_should").to_string()
+ &fs_entry.partition.part_name
+ &t!("be_added_crypttab"),
)
.build(); .build();
crypttab_dialog crypttab_dialog
.add_response("crypttab_dialog_boot", &t!("unlock_boot_manually")); .add_response("crypttab_dialog_boot", &t!("crypttab_dialog_response_crypttab_dialog_boot"));
crypttab_dialog.add_response("crypttab_dialog_auto", &t!("unlock_boot_manual")); crypttab_dialog.add_response("crypttab_dialog_auto", &t!("crypttab_dialog_response_crypttab_dialog_auto"));
crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false); crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false);
crypttab_password.connect_apply(clone!( crypttab_password_entry_row.connect_apply(clone!(
#[weak] #[weak]
crypttab_password, crypttab_password_entry_row,
#[strong] #[strong]
fs_entry, fs_entry,
#[weak] #[weak]
@ -550,7 +574,7 @@ fn set_crypttab_entries(
crypttab_dialog, crypttab_dialog,
move |_| { move |_| {
let luks_manual_password_sender = luks_manual_password_sender.clone(); let luks_manual_password_sender = luks_manual_password_sender.clone();
let luks_password = crypttab_password.text().to_string(); let luks_password = crypttab_password_entry_row.text().to_string();
let fs_entry_clone1 = fs_entry.clone(); let fs_entry_clone1 = fs_entry.clone();
@ -599,7 +623,7 @@ fn set_crypttab_entries(
partition: part_name.clone(), partition: part_name.clone(),
map: part_name.replace("mapper/", ""), map: part_name.replace("mapper/", ""),
uuid: get_luks_uuid(&part_name), uuid: get_luks_uuid(&part_name),
password: Some(crypttab_password.text().to_string()), password: Some(crypttab_password_entry_row.text().to_string()),
}); });
} else { } else {
(*partition_method_manual_crypttab_entry_array_refcell_clone0 (*partition_method_manual_crypttab_entry_array_refcell_clone0