From 90941b2eb1277b25277e6b3dcb8d71b99134685c Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 21:30:41 +0300 Subject: [PATCH] RR: Begin Translation Process for few stacks and use err id based problem detection in manual partitioning --- po/en_US.po | 42 +++++++++++++++- src/automatic_partitioning/mod.rs | 2 +- src/build_ui.rs | 6 +-- src/done_page/mod.rs | 2 +- src/drive_mount_row/imp.rs | 4 +- src/efi_error_page/mod.rs | 2 +- src/eula_page/mod.rs | 2 +- src/install_page/mod.rs | 2 +- src/keyboard_page/mod.rs | 2 +- src/manual_partitioning/mod.rs | 82 ++++++++++++------------------- src/partitioning_page/mod.rs | 16 +++--- src/timezone_page/mod.rs | 18 +++---- src/welcome_page/mod.rs | 10 ++-- 13 files changed, 106 insertions(+), 84 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index f7fb881..cbd9793 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -13,4 +13,44 @@ msgstr "" "X-Poedit-Basepath: .\n" msgid "pikaos_installer" -msgstr "PikaOS Installer" \ No newline at end of file +msgstr "PikaOS Installer" + +msgid "welcome_to_pikaos" +msgstr "Welcome to PikaOS" + +msgid "use_pikaos_in_live_media" +msgstr "Use PikaOS in Live media" + +msgid "install_distro_to_system" +msgstr "Install Distro to System" + +msgid "welcome" +msgstr "Welcome" + +msgid "back" +msgstr "Back" + +msgid "next" +msgstr "Next" + +msgid "select_a_timezone" +msgstr "Select a timezone" + +msgid "please_select_timezone" +msgstr "Please select a Time Zone for the system to use" + +msgid "no_timezone_select" +msgstr "No Time Zone selected" + +msgid "timezone" +msgstr "Time Zone" + +msgid "choose_install_method" +msgstr "Choose an install method" + +msgid "manual_partition_drive" +msgstr "Manually Partition The Drive" + +msgid "auto_partition_drive" +msgstr "Automatically Partition\nThe Drive" + diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 61468eb..85eada3 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; diff --git a/src/build_ui.rs b/src/build_ui.rs index 64fa83a..e7279cd 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::path::Path; @@ -30,7 +30,7 @@ use crate::partitioning_page::partitioning_page; pub fn build_ui(app: &adw::Application) { // setup glib gtk::glib::set_prgname(Some(gettext("pikaos_installer"))); - glib::set_application_name("PikaOS Installer"); + glib::set_application_name(&gettext("pikaos_installer")); let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4"); // Widget Bank @@ -67,7 +67,7 @@ pub fn build_ui(app: &adw::Application) { let window = adw::ApplicationWindow::builder() // The text on the titlebar - .title("PikaOS Installer") + .title(gettext("pikaos_installer")) // link it to the application "app" .application(app) // Add the box called "_main_box" to it diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index 8a49c67..f969cdd 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use crate::config::{DISTRO_ICON}; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::path::Path; use std::process::Command; diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index a9dd891..5cb2baf 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -8,7 +8,7 @@ use adw::{prelude::*, subclass::prelude::*, *}; use glib::{clone, subclass::Signal, Properties}; use gtk::{glib, Orientation::Horizontal}; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; // ANCHOR: custom_button // Object holding the state @@ -123,7 +123,7 @@ impl ObjectImpl for DriveMountRow { .width_request(53) .height_request(53) .valign(gtk::Align::Start) - .icon_name("edit-delete") + .icon_name("user-trash") .halign(gtk::Align::End) .build(); diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index 3121e3f..ce9de09 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the efi_error page diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 9b10dfd..293ede4 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn eula_page(content_stack: >k::Stack) { // create the bottom box for next and back buttons diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index d148f93..d3157e4 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -10,7 +10,7 @@ use gtk::*; use vte::prelude::*; use vte::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use crate::done_page::done_page; diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 42dd38a..3d394dd 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index fe9659d..03a1214 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use std::thread; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::cell::{RefCell}; use std::rc::Rc; @@ -116,6 +116,7 @@ fn create_mount_row( closure_local!(@strong partition_method_manual_error_label ,@strong partition_method_manual_valid_label, @strong row as _row => move |_row: DriveMountRow| { listbox_clone.remove(&_row); partition_method_manual_error_label.set_label(""); + partition_method_manual_error_label.set_widget_name(""); partition_method_manual_error_label.set_visible(false); partition_method_manual_valid_label.set_label(""); partition_method_manual_valid_label.set_visible(false); @@ -458,8 +459,8 @@ fn partition_err_check( } if empty_mountpoint == false { - if &partition_method_manual_error_label.label() - == "Some drives don't have a mountpoint configured." + if &partition_method_manual_error_label.widget_name() + == "err1" { partition_method_manual_error_label.set_visible(false); } @@ -475,11 +476,10 @@ fn partition_err_check( partition_method_manual_error_label .set_label("Multiple drives were mounted to the same mountpoint."); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err0"); } } else { - if partition_method_manual_error_label.label() - == "Multiple drives were mounted to the same mountpoint." - { + if &partition_method_manual_error_label.widget_name() == "err0" { partition_method_manual_error_label.set_visible(false); } } @@ -487,6 +487,7 @@ fn partition_err_check( if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label .set_label("Some drives don't have a mountpoint configured."); + partition_method_manual_error_label.set_widget_name("err1"); partition_method_manual_error_label.set_visible(true); } } @@ -495,10 +496,11 @@ fn partition_err_check( if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label .set_label("There's a drive row without a partition."); + partition_method_manual_error_label.set_widget_name("err2"); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label() == "There's a drive row without a partition." + if partition_method_manual_error_label.widget_name() == "err2" { partition_method_manual_error_label.set_visible(false); } @@ -541,12 +543,10 @@ fn partition_err_check( + ") Must at least be 512MBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err3"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /boot/efi (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err3" { partition_method_manual_error_label.set_visible(false); } } @@ -559,12 +559,10 @@ fn partition_err_check( + ") Must at be FAT32/vFAT"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err4"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /boot/efi (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err4" { partition_method_manual_error_label.set_visible(false); } } @@ -578,12 +576,10 @@ fn partition_err_check( + ") Must at least be 1000MBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err5"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /boot (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err5" { partition_method_manual_error_label.set_visible(false); } } @@ -595,12 +591,10 @@ fn partition_err_check( + ") Cannot be FAT32/vFAT"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err6"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /boot (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err6" { partition_method_manual_error_label.set_visible(false); } } @@ -614,16 +608,14 @@ fn partition_err_check( + ") Must at least be 25GBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err7") } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to / (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err7" { partition_method_manual_error_label.set_visible(false); } } - if partition_fs == "vfat" || partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { + if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: The partition mounted to / (/dev/".to_owned() @@ -631,12 +623,10 @@ fn partition_err_check( + ") Has an Invalid Filesystem"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err8"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to / (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err8" { partition_method_manual_error_label.set_visible(false); } } @@ -650,29 +640,25 @@ fn partition_err_check( + ") Must at least be 10GBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err9"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /home (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err9" { partition_method_manual_error_label.set_visible(false); } } - if partition_fs == "vfat" { + if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition - + ") Cannot be FAT32/vFAT"), + + ") Has an Invalid Filesystem"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err10"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /home (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err10" { partition_method_manual_error_label.set_visible(false); } } @@ -686,12 +672,10 @@ fn partition_err_check( + " Is not a swap partition"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err11"); } } else { - if partition_method_manual_error_label - .label() - .contains(" Is not a swap partition") - { + if &partition_method_manual_error_label.widget_name() == "err11" { partition_method_manual_error_label.set_visible(false); } } @@ -708,12 +692,10 @@ fn partition_err_check( + " Is not a valid mountpoint"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err12"); } } else { - if partition_method_manual_error_label - .label() - .contains(" Is not a valid mountpoint") - { + if &partition_method_manual_error_label.widget_name() == "err12" { partition_method_manual_error_label.set_visible(false); } } diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 58d7802..0f525a2 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -7,7 +7,7 @@ use glob::glob; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use crate::automatic_partitioning::automatic_partitioning; use crate::install_page::install_page; @@ -42,7 +42,7 @@ pub fn partitioning_page( // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -51,7 +51,7 @@ pub fn partitioning_page( .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -81,7 +81,7 @@ pub fn partitioning_page( // the header text for the partitioning page let partitioning_header_text = gtk::Label::builder() - .label("Choose an install method") + .label(gettext("choose_install_method")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -125,7 +125,7 @@ pub fn partitioning_page( .build(); let manual_method_button_content_image = gtk::Image::builder() - .icon_name("input-tablet") + .icon_name("org.gnome.Settings") .pixel_size(128) .margin_top(15) .margin_bottom(15) @@ -134,7 +134,7 @@ pub fn partitioning_page( .build(); let manual_method_button_content_text = gtk::Label::builder() - .label("Manually Partition The Drive") + .label(gettext("manual_partition_drive")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -151,7 +151,7 @@ pub fn partitioning_page( .build(); let automatic_method_button_content_image = gtk::Image::builder() - .icon_name("media-playlist-shuffle") + .icon_name("builder") .pixel_size(128) .margin_top(15) .margin_bottom(15) @@ -160,7 +160,7 @@ pub fn partitioning_page( .build(); let automatic_method_button_content_text = gtk::Label::builder() - .label("Automatically Partition\nThe Drive") + .label(gettext("auto_partition_drive")) .margin_top(0) .margin_bottom(15) .margin_start(15) diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index f594bb3..e071e28 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; @@ -27,7 +27,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -36,7 +36,7 @@ pub fn timezone_page(content_stack: >k::Stack) { .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -66,7 +66,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // the header text for the timezone page let timezone_header_text = gtk::Label::builder() - .label("Select a timezone") + .label(gettext("select_a_timezone")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -78,7 +78,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // the header icon for the timezone icon let timezone_header_icon = gtk::Image::builder() - .icon_name("clock") + .icon_name("alarm-clock") .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) @@ -106,7 +106,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // text above timezone selection box let timezone_selection_text = gtk::Label::builder() - .label("Please select a Time Zone for the system to use") + .label(gettext("please_select_timezone")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -117,11 +117,11 @@ pub fn timezone_page(content_stack: >k::Stack) { timezone_selection_text.add_css_class("medium_sized_text"); let timezone_selection_expander_row = adw::ExpanderRow::builder() - .title("No Time Zone selected") + .title(gettext("no_timezone_select")) .build(); let null_checkbutton = gtk::CheckButton::builder() - .label("No Time Zone selected") + .label(gettext("no_timezone_select")) .build(); let timezone_selection_expander_row_viewport = @@ -213,7 +213,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // / Content stack appends //// Add the timezone_main_box as page: timezone_page, Give it nice title - content_stack.add_titled(&timezone_main_box, Some("timezone_page"), "Time Zone"); + content_stack.add_titled(&timezone_main_box, Some("timezone_page"), &gettext("timezone")); let timezone_data_buffer_clone = timezone_data_buffer.clone(); diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 56e37f9..ea34407 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -7,7 +7,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the welcome page @@ -22,7 +22,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) // the header text for the welcome page let welcome_header_text = gtk::Label::builder() - .label("Welcome to PikaOS") + .label(gettext("welcome_to_pikaos")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -64,7 +64,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) .build(); let live_media_button_content_text = gtk::Label::builder() - .label("Use PikaOS in Live media") + .label(gettext("use_pikaos_in_live_media")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -86,7 +86,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) .build(); let install_media_button_content_text = gtk::Label::builder() - .label("Install Distro to System") + .label(gettext("install_distro_to_system")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -160,7 +160,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) // / Content stack appends //// Add the welcome_main_box as page: welcome_page, Give it nice title - content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome"); + content_stack.add_titled(&welcome_main_box, Some("welcome_page"), &gettext("welcome")); install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page"))); live_media_button.connect_clicked(clone!(@weak window => move |_| window.close()));