From d591023d69b162f083e0594ebdb897fbb9071b5c Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Mon, 10 Jan 2022 18:51:39 +0530 Subject: [PATCH] Update README Want to trigger doc.rs build again. --- Cargo.toml | 2 +- README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 2 ++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2e68128..f6c2af8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ki18n" description = "A crate to use KF5I18n from rust." author = ["Ayush Singh "] -version = "1.1.0" +version = "1.1.1" edition = "2021" links = "KF5I18n" license = "MIT" diff --git a/README.md b/README.md index 3bcb9cd..e2d5214 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,79 @@ The crate searches from KF5I18n using either the environment variables (`KF_VERS `KF_INCLUDE_PATH` and `KF_LIBRARY_PATH`) if they are set or uses `kf5-config` to find the paths. +## Example +```rust +use cstr::cstr; +use qmetaobject::prelude::*; +use ki18n::klocalizedcontext::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(); +} +``` +# KI18n Crate for Rust +[![Crates.io](https://img.shields.io/crates/v/ki18n)](https://crates.io/crates/ki18n) +[![Documentation](https://docs.rs/ki18n/badge.svg)](https://docs.rs/ki18n/) + +## Introduction +KI18n is a cross-platform internationalization framework used by KDE applications. This crate +is meant to allow using KI18n with Rust and [qmetaobject-rs](https://github.com/woboq/qmetaobject-rs) crate. + +## Motivation +I love KDE. I have been using it as my primary DE for quite a while. I also like Rust Programming Language. +Currently, it is nearly impossible to use any KDE frameworks from Rust without some C++ FFI. While FFI is +never easy, complexity with C++ is exponentially more than plain C due to the Object-Oriented nature of C++, +which is entirely different from Rust's somewhat functional design. + +If possible, I would like the Tier-1 KDE Frameworks to be usable from pragmatic Rust in a somewhat natural +fashion. I am currently interested in KDE frameworks that are usable with QML. + +## Requirements +This crate requires KF5I18n to be installed or at least present in the system. +### Ubuntu +``` shell +sudo apt install libkf5i18n-dev +```rust +## Arch Linux +``` shell +sudo pacman -S ki18n +``` + +## Custom Location for KF5I18n +The crate searches from KF5I18n using either the environment variables (`KF_VERSION`, +`KF_INCLUDE_PATH` and `KF_LIBRARY_PATH`) if they are set or uses `kf5-config` to find the paths. + +## Features +- `qmetaobject` : Enables some methods that require qmetaobject. Most people will need this. + ## Example ```rust use cstr::cstr; diff --git a/src/lib.rs b/src/lib.rs index 7197886..4250ceb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,8 @@ //! The crate searches from KF5I18n using either the environment variables (`KF_VERSION`, //! `KF_INCLUDE_PATH` and `KF_LIBRARY_PATH`) if they are set or uses `kf5-config` to find the paths. //! +//! # Features +//! - `qmetaobject` : Enables some methods that require qmetaobject. Most people will need this. //! //! # Example //! ```no_run