ki18n-rs/README.md
Ayush Singh 0c350fc91c Added README and LICENSE.
Also added some metadata to the Cargo.toml
2021-11-01 15:53:52 +05:30

42 lines
1.3 KiB
Markdown

# 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](https://github.com/woboq/qmetaobject-rs) crate.
# Example
```rust
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();
}
```