RR: Begin Translation Process

This commit is contained in:
Ward from fusion-voyager-3 2024-02-18 20:28:14 +03:00
parent 11c64b6979
commit cfcebe2d7b
17 changed files with 60 additions and 2 deletions

View File

@ -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

9
makepot Executable file
View File

@ -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

16
po/en_US.po Normal file
View File

@ -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"

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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)]

View File

@ -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: &gtk::Stack) {
// the header box for the efi_error page
let efi_error_main_box = gtk::Box::builder()

View File

@ -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: &gtk::Stack) {
// create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder()

View File

@ -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;

View File

@ -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;

View File

@ -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: &gtk::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 |_| {

View File

@ -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");
}

View File

@ -7,6 +7,8 @@ use glib::*;
use gtk::*;
use std::thread;
use gettextrs::{gettext, LocaleCategory};
use std::cell::{RefCell};
use std::rc::Rc;

View File

@ -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;

View File

@ -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;

View File

@ -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: &gtk::Stack) {
// the header box for the welcome page
let welcome_main_box = gtk::Box::builder()