diff --git a/Makefile b/Makefile index 2c2aa5d..3555e84 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +export PATH := $(PWD):$(PATH) + all: true @@ -19,3 +21,4 @@ install: mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps #cp -vf data/pika-drivers.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/ #cp -vf data/com.pika.drivers.desktop $(DESTDIR)/usr/share/applications/ + makepot $(DESTDIR)/usr/share/locale diff --git a/makepot b/makepot new file mode 100755 index 0000000..0a75270 --- /dev/null +++ b/makepot @@ -0,0 +1,9 @@ +#! /bin/bash + +set -e + +for i in po/*.po +do + mkdir -p "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES + msgfmt -v $i -o "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES/pika-first-setup-gtk4.mo +done \ No newline at end of file diff --git a/po/en_US.po b/po/en_US.po new file mode 100644 index 0000000..f7fb881 --- /dev/null +++ b/po/en_US.po @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2024-02-09 17:48+0300\n" +"PO-Revision-Date: 2024-02-09 17:55+0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.4\n" +"X-Poedit-Basepath: .\n" + +msgid "pikaos_installer" +msgstr "PikaOS Installer" \ No newline at end of file diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index e301a21..61468eb 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/build_ui.rs b/src/build_ui.rs index 9583138..64fa83a 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::path::Path; use crate::save_window_size::save_window_size; @@ -27,7 +29,7 @@ use crate::partitioning_page::partitioning_page; // build ui function linked to app startup above pub fn build_ui(app: &adw::Application) { // setup glib - gtk::glib::set_prgname(Some("PikaOS Installer")); + gtk::glib::set_prgname(Some(gettext("pikaos_installer"))); glib::set_application_name("PikaOS Installer"); let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4"); diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index a397e6a..8a49c67 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -7,6 +7,7 @@ use glib::*; use gtk::*; use crate::config::{DISTRO_ICON}; +use gettextrs::{gettext, LocaleCategory}; 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 4e0b23b..a9dd891 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -8,6 +8,8 @@ use adw::{prelude::*, subclass::prelude::*, *}; use glib::{clone, subclass::Signal, Properties}; use gtk::{glib, Orientation::Horizontal}; +use gettextrs::{gettext, LocaleCategory}; + // ANCHOR: custom_button // Object holding the state #[derive(Properties, Default)] diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index ba552c8..3121e3f 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the efi_error page let efi_error_main_box = gtk::Box::builder() diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 3491a0e..9b10dfd 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn eula_page(content_stack: >k::Stack) { // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 744841c..d148f93 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -10,6 +10,8 @@ use gtk::*; use vte::prelude::*; use vte::*; +use gettextrs::{gettext, LocaleCategory}; + use crate::done_page::done_page; use std::process::Command; diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 9f1082a..42dd38a 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 504bbf4..2712301 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::env; use std::io::BufRead; use std::io::BufReader; @@ -226,6 +228,11 @@ pub fn language_page(content_stack: >k::Stack) { .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8") .spawn() .expect("locale failed to start"); + gettextrs::setlocale(LocaleCategory::LcAll, lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8"); + if gettext("pikaos_installer") == "pikaos_installer" { + println!("Warning: Current LANG is not supported, using fallback Locale."); + gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8"); + } content_stack.set_visible_child_name("eula_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { diff --git a/src/main.rs b/src/main.rs index b61937c..6a943e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,7 +48,7 @@ fn main() { gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain"); // Fallback if no translation present - if gettext("first_setup_initial_box_text_title") == "first_setup_initial_box_text_title" { + if gettext("pikaos_installer") == "pikaos_installer" { println!("Warning: Current LANG is not supported, using fallback Locale."); gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8"); } diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 4d60a02..fe9659d 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,6 +7,8 @@ use glib::*; use gtk::*; use std::thread; +use gettextrs::{gettext, LocaleCategory}; + use std::cell::{RefCell}; use std::rc::Rc; diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index a88835d..58d7802 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -7,6 +7,8 @@ use glob::glob; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use crate::automatic_partitioning::automatic_partitioning; use crate::install_page::install_page; use crate::manual_partitioning::manual_partitioning; diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index 727f6e8..f594bb3 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index a429f38..56e37f9 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -7,6 +7,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the welcome page let welcome_main_box = gtk::Box::builder()