some translation

This commit is contained in:
Ward from fusion-voyager-3 2024-06-21 20:22:27 +03:00
parent 65d6d42e8b
commit 43fef2198a
3 changed files with 48 additions and 26 deletions

View File

@ -1,3 +1,24 @@
{ {
"hello": "Wassup!" "application_name": "Fedora Kernel Manager",
"developer_name": "Cosmo",
"banner_text_no_internet": "Warning: No internet connection",
"banner_text_url_error": "Kernel Database URL Error: Please Restart!",
"loading_label_label": "Downloading Database...",
"kernel_branch_expander_row_subtitle": "Kernel Branch",
"browse_kernels_button_tooltip_text": "Browse Kernel for select branch",
"config_kernel_button_tooltip_text": "Configure Sched_EXT settings",
"config_kernel_button_tooltip_text_no_scx": "Currently running kernel doesn't support Sched-EXT",
"null_checkbutton_label": "No branch selected",
"db_load_complete": "DB load complete!",
"db_downloading": "Downloading & Parsing package DB for",
"db_download_complete": "Download Complete!",
"db_init_script_run_p1": "Running",
"db_init_script_run_p2": "init script.",
"db_init_script_successful": "init script successful.",
"db_init_script_failed": "init script failed!",
"unknown": "Unknown",
"disabled": "Disabled",
"get_current_scheduler_sched_ext_detected": "sched_ext is detected, getting scx scheduler",
"kernel_badge_branch_label": "Kernel Branch",
"kernel_badge_branch_label": "Latest Version"
} }

View File

@ -15,8 +15,8 @@ use std::rc::Rc;
use std::{thread, time}; use std::{thread, time};
pub fn build_ui(app: &adw::Application) { pub fn build_ui(app: &adw::Application) {
gtk::glib::set_prgname(Some("Fedora Kernel Manager")); gtk::glib::set_prgname(Some(t!("application_name").to_string()));
glib::set_application_name("Fedora Kernel Manager"); glib::set_application_name(&t!("application_name").to_string());
let internet_connected = Rc::new(RefCell::new(false)); let internet_connected = Rc::new(RefCell::new(false));
let selected_kernel_branch: Rc<RefCell<KernelBranch>> = Rc::new(RefCell::new(KernelBranch { let selected_kernel_branch: Rc<RefCell<KernelBranch>> = Rc::new(RefCell::new(KernelBranch {
@ -52,7 +52,7 @@ pub fn build_ui(app: &adw::Application) {
// The main loop executes the asynchronous block // The main loop executes the asynchronous block
internet_loop_context.spawn_local(clone!(@weak window_banner => async move { internet_loop_context.spawn_local(clone!(@weak window_banner => async move {
while let Ok(state) = internet_loop_receiver.recv().await { while let Ok(state) = internet_loop_receiver.recv().await {
let banner_text = "Warning: No internet connection"; let banner_text = t!("banner_text_no_internet").to_string();
if state == true { if state == true {
*internet_connected_status.borrow_mut()=true; *internet_connected_status.borrow_mut()=true;
if window_banner.title() == banner_text { if window_banner.title() == banner_text {
@ -60,8 +60,8 @@ pub fn build_ui(app: &adw::Application) {
} }
} else { } else {
*internet_connected_status.borrow_mut()=false; *internet_connected_status.borrow_mut()=false;
if window_banner.title() != "Kernel Database URL Error: Please Restart!" { if window_banner.title() != t!("banner_text_url_error").to_string() {
window_banner.set_title(banner_text); window_banner.set_title(&banner_text);
window_banner.set_revealed(true) window_banner.set_revealed(true)
} }
} }
@ -71,7 +71,7 @@ pub fn build_ui(app: &adw::Application) {
let window_headerbar = adw::HeaderBar::builder() let window_headerbar = adw::HeaderBar::builder()
.title_widget( .title_widget(
&adw::WindowTitle::builder() &adw::WindowTitle::builder()
.title("Fedora Kernel Manager") .title(t!("application_name"))
.build(), .build(),
) )
.build(); .build();
@ -121,11 +121,12 @@ pub fn build_ui(app: &adw::Application) {
let credits_window = adw::AboutWindow::builder() let credits_window = adw::AboutWindow::builder()
.application_icon(APP_ICON) .application_icon(APP_ICON)
.application_name("Fedora Kernel Manager") .application_name(t!("application_name"))
.transient_for(&window) .transient_for(&window)
.version(VERSION) .version(VERSION)
.hide_on_close(true) .hide_on_close(true)
.developer_name("Cosmo") .developer_name(t!("developer_name"))
.license_type(License::Gpl20)
.issue_url(APP_GITHUB.to_owned() + "/issues") .issue_url(APP_GITHUB.to_owned() + "/issues")
.build(); .build();

View File

@ -45,7 +45,7 @@ pub fn content(
.hexpand(true) .hexpand(true)
.valign(Align::Start) .valign(Align::Start)
.halign(Align::Center) .halign(Align::Center)
.label("Downloading Database...") .label(t!("loading_label_label"))
.build(); .build();
let loading_box = gtk::Box::builder() let loading_box = gtk::Box::builder()
@ -85,7 +85,7 @@ pub fn content(
.build(); .build();
let kernel_branch_expander_row = adw::ExpanderRow::builder() let kernel_branch_expander_row = adw::ExpanderRow::builder()
.subtitle("Kernel Branch") .subtitle(t!("kernel_branch_expander_row_subtitle"))
.build(); .build();
kernel_branch_expander_row.add_row(&kernel_branch_expandable( kernel_branch_expander_row.add_row(&kernel_branch_expandable(
@ -124,7 +124,7 @@ pub fn content(
.margin_end(10) .margin_end(10)
.height_request(50) .height_request(50)
.width_request(50) .width_request(50)
.tooltip_text("Browse Kernel for select branch") .tooltip_text(t!("browse_kernels_button_tooltip_text"))
.hexpand(true) .hexpand(true)
.build(); .build();
browse_kernels_button.add_css_class("circular"); browse_kernels_button.add_css_class("circular");
@ -146,7 +146,7 @@ pub fn content(
.margin_end(10) .margin_end(10)
.height_request(50) .height_request(50)
.width_request(50) .width_request(50)
.tooltip_text("Configure Sched_EXT settings") .tooltip_text(t!("config_kernel_button_tooltip_text"))
.sensitive(is_scx_kernel()) .sensitive(is_scx_kernel())
.hexpand(true) .hexpand(true)
.build(); .build();
@ -154,7 +154,7 @@ pub fn content(
if !is_scx_kernel() { if !is_scx_kernel() {
config_kernel_button config_kernel_button
.set_tooltip_text(Some("Currently running kernel doesn't support Sched-EXT")); .set_tooltip_text(Some(&t!("config_kernel_button_tooltip_text_no_scx").to_string()));
} }
config_kernel_button.connect_clicked(clone!(@weak content_stack, @weak window => move |_| { config_kernel_button.connect_clicked(clone!(@weak content_stack, @weak window => move |_| {
@ -225,7 +225,7 @@ fn kernel_branch_expandable(
branch_container.add_css_class("boxed-list"); branch_container.add_css_class("boxed-list");
let null_checkbutton = gtk::CheckButton::builder() let null_checkbutton = gtk::CheckButton::builder()
.label("No branch selected") .label(t!("null_checkbutton_label"))
.build(); .build();
let get_kernel_branches_loop_context = MainContext::default(); let get_kernel_branches_loop_context = MainContext::default();
@ -268,11 +268,11 @@ fn kernel_branch_expandable(
}; };
*db_load_complete.borrow_mut() = true; *db_load_complete.borrow_mut() = true;
println!("DB load complete!") println!("{}", t!("db_load_complete"))
} }
} }
_ => { _ => {
window_banner.set_title("Kernel Database URL Error: Please Restart!"); window_banner.set_title(t!("banner_text_url_error"));
window_banner.set_revealed(true); window_banner.set_revealed(true);
loading_box.set_visible(false); loading_box.set_visible(false);
} }
@ -387,7 +387,7 @@ fn get_kernel_branches() -> Result<Vec<KernelBranch>, reqwest::Error> {
.to_owned() .to_owned()
.unwrap() .unwrap()
.to_string(); .to_string();
println!("Downloading & Parsing package DB for {}.", &branch_name); println!("{} {}.",t!("db_downloading"), &branch_name);
let branch_db = let branch_db =
reqwest::blocking::get(branch["db_url"].as_str().to_owned().unwrap().to_string())? reqwest::blocking::get(branch["db_url"].as_str().to_owned().unwrap().to_string())?
.text() .text()
@ -398,11 +398,11 @@ fn get_kernel_branches() -> Result<Vec<KernelBranch>, reqwest::Error> {
init_script: branch_init_script, init_script: branch_init_script,
db: branch_db, db: branch_db,
}; };
println!("Download Complete!"); println!("{}", t!("db_download_complete"));
println!("Running {} init script.", &branch.name); println!("{} {} {}", t!("db_init_script_run_p1"), &branch.name, t!("db_init_script_run_p2"));
match cmd!("bash", "-c", &branch.init_script).run() { match cmd!("bash", "-c", &branch.init_script).run() {
Ok(t) => println!("{} init script successful.", &branch.name), Ok(t) => println!("{} {}", &branch.name, t!("db_init_script_successful")),
_ => println!("{} init script failed.", &branch.name), _ => println!("{} {}", &branch.name, t!("db_init_script_failed")),
}; };
kernel_branches_array.push(branch) kernel_branches_array.push(branch)
} }
@ -417,7 +417,7 @@ pub fn get_running_kernel_info() -> RunningKernelInfo {
.output() .output()
{ {
Ok(t) => String::from_utf8(t.stdout).unwrap().trim().to_owned(), Ok(t) => String::from_utf8(t.stdout).unwrap().trim().to_owned(),
Err(_) => "Unknown".to_string(), Err(_) => t!("unknown").to_string(),
}; };
let version = match linux_version::linux_kernel_version() { let version = match linux_version::linux_kernel_version() {
@ -428,7 +428,7 @@ pub fn get_running_kernel_info() -> RunningKernelInfo {
format!("{}.{}.{}", t.major, t.minor, t.patch) format!("{}.{}.{}", t.major, t.minor, t.patch)
} }
} }
Err(_) => "Unknown".to_string(), Err(_) => t!("unknown").to_string(),
}; };
let info = RunningKernelInfo { let info = RunningKernelInfo {
@ -450,7 +450,7 @@ fn is_scx_kernel() -> bool {
} }
pub fn get_current_scheduler(version: String) -> String { pub fn get_current_scheduler(version: String) -> String {
if is_scx_kernel() { if is_scx_kernel() {
println!("sched_ext is detected, getting scx scheduler"); println!("{}", t!("get_current_scheduler_sched_ext_detected"));
let scx_sched = match fs::read_to_string("/sys/kernel/sched_ext/root/ops") { let scx_sched = match fs::read_to_string("/sys/kernel/sched_ext/root/ops") {
Ok(t) => t, Ok(t) => t,
Err(_) => "disabled".to_string(), Err(_) => "disabled".to_string(),
@ -509,7 +509,7 @@ fn create_kernel_badges(
} }
badge_box.append(&create_kernel_badge( badge_box.append(&create_kernel_badge(
"Kernel Branch", &t!("kernel_badge_branch_label").to_string(),
&selected_kernel_branch_clone.name, &selected_kernel_branch_clone.name,
"background-accent-bg", "background-accent-bg",
&kernel_badges_size_group, &kernel_badges_size_group,