diff --git a/Cargo.toml b/Cargo.toml index 7a9781d..2ff0572 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,10 @@ name = "ki18n-rs" version = "0.1.0" edition = "2018" links = "KF5I18n" +license-file = "LICENSE.txt" +readme = "README.md" +repository = "https://github.com/Ayush1325/ki18n-rs" +keywords = ["ki18n", "kde", "localization"] [dependencies] cpp = "0.5" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..159d711 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,19 @@ +Copyright (c) 2021 Ayush Singh + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..41a7b26 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# 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(); +} +```