From 2cdd13d145724664f15e45e3103b0f0fd0901822 Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Wed, 15 Dec 2021 22:24:45 +0530 Subject: [PATCH] Added Methods for KLocalizedString --- .gitignore | 1 + src/klocalizedstring.rs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 96ef6c0..b471067 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target Cargo.lock +.idea diff --git a/src/klocalizedstring.rs b/src/klocalizedstring.rs index 29d1100..998304d 100644 --- a/src/klocalizedstring.rs +++ b/src/klocalizedstring.rs @@ -73,9 +73,24 @@ impl KLocalizedString { } /// Check whether the translation catalog file in the given language for the set application translation domain exists. - pub fn is_application_translated_into(language: &QString) -> bool { + pub fn is_application_translated_into(language: QString) -> bool { cpp!(unsafe [language as "QString"] -> bool as "bool" { return KLocalizedString::isApplicationTranslatedInto(language); }) } + + /// Find a path to the localized file for the given original path. + /// This is intended mainly for non-text resources (images, sounds, etc). Text resources should be handled in more specific ways. + pub fn localized_file_path(file_path: QString) -> QString { + cpp!(unsafe [file_path as "QString"] -> QString as "QString" { + return KLocalizedString::localizedFilePath(file_path); + }) + } + + /// Remove accelerator marker from a UI text label. + pub fn remove_accelerator_marker(label: QString) -> QString{ + cpp!(unsafe [label as "QString"] -> QString as "QString" { + return KLocalizedString::removeAcceleratorMarker(label); + }) + } }