A crate to use KF5I18n from Rust.
Find a file
Ayush Singh 6f74d864e3 init_from_engine now returns the object.
Also added method to get the underlying c++ object. Not sure how well it
actually works since not much of KLocalizedContext is actually supposed
to be used from C++.
2021-11-07 12:17:33 +05:30
.github/workflows Fix Display in github action 2021-11-01 21:35:16 +05:30
src init_from_engine now returns the object. 2021-11-07 12:17:33 +05:30
tests Added Documentation. 2021-11-01 18:02:04 +05:30
.gitignore Initial Commit. 2021-11-01 15:01:02 +05:30
build.rs Using Qt include path for QtCore. 2021-11-01 21:21:56 +05:30
Cargo.toml Added license in Cargo.toml 2021-11-07 12:03:23 +05:30
LICENSE.txt Added README and LICENSE. 2021-11-01 15:53:52 +05:30
README.md Added README and LICENSE. 2021-11-01 15:53:52 +05:30

KI18n Crate for Rust

KI18n is a cross-platform internationalization framework used by KDE applications. This crate is meant to allow using KI18n with Rust and qmetaobject-rs crate.

Example

use cstr::cstr;
use qmetaobject::prelude::*;
use ki18n_rs::KLocalizedContext;

fn main() {
  let mut engine = QmlEngine::new();
  KLocalizedContext::init_from_engine(&engine);
  engine.load_data(r#"
    import QtQuick 2.6
    import QtQuick.Controls 2.0 as Controls
    import QtQuick.Layouts 1.2
    import org.kde.kirigami 2.13 as Kirigami
    
    // Base element, provides basic features needed for all kirigami applications
    Kirigami.ApplicationWindow {
        // ID provides unique identifier to reference this element
        id: root
    
        // Window title
        // i18nc is useful for adding context for translators, also lets strings be changed for different languages
        title: i18nc("@title:window", "Hello World")
    
        // Initial page to be loaded on app load
        pageStack.initialPage: Kirigami.Page {
    
            Controls.Label {
                // Center label horizontally and vertically within parent element
                anchors.centerIn: parent
                text: i18n("Hello World!")
            }
        }
    }
  "#.into());
  engine.exec();
}