Added Methods for KLocalizedString.
This commit is contained in:
parent
736d5c5a26
commit
4c2f78d2bb
|
@ -15,6 +15,8 @@ build = "build.rs"
|
||||||
cpp = "0.5"
|
cpp = "0.5"
|
||||||
qmetaobject = "0.2"
|
qmetaobject = "0.2"
|
||||||
qttypes = "0.2"
|
qttypes = "0.2"
|
||||||
|
# qmetaobject = { path="../qmetaobject-rs/qmetaobject" }
|
||||||
|
# qttypes = { path="../qmetaobject-rs/qttypes" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cpp_build = "0.5"
|
cpp_build = "0.5"
|
||||||
|
|
|
@ -37,4 +37,45 @@ impl KLocalizedString {
|
||||||
return KLocalizedString::applicationDomain();
|
return KLocalizedString::applicationDomain();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the languages for which translations will be made.
|
||||||
|
/// Returned languages are ordered with decreasing priority.
|
||||||
|
pub fn languages() -> QStringList {
|
||||||
|
cpp!(unsafe [] -> QStringList as "QStringList" {
|
||||||
|
return KLocalizedString::languages();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the languages for which translations will be made.
|
||||||
|
/// This overrides the languages provided by the locale. Languages should be ordered with decreasing priority.
|
||||||
|
/// TODO: Add Test
|
||||||
|
pub fn set_languages(languages: &QStringList) {
|
||||||
|
cpp!(unsafe [languages as "QStringList"] {
|
||||||
|
KLocalizedString::setLanguages(languages);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clear override languages.
|
||||||
|
/// This clears the override languages, going back to those provided by the locale.
|
||||||
|
/// TODO: Add Test.
|
||||||
|
pub fn clear_languages() {
|
||||||
|
cpp!(unsafe [] {
|
||||||
|
KLocalizedString::clearLanguages();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Load locales for a domain from a specific location.
|
||||||
|
/// This is useful for resources which have their translation files outside of the usual $XDG_DATA_DIRS/locales location.
|
||||||
|
pub fn add_domain_locale_dir(domain: QByteArray, path: QString) {
|
||||||
|
cpp!(unsafe [domain as "QByteArray", path as "QString"] {
|
||||||
|
KLocalizedString::addDomainLocaleDir(domain, path);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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 {
|
||||||
|
cpp!(unsafe [language as "QString"] -> bool as "bool" {
|
||||||
|
return KLocalizedString::isApplicationTranslatedInto(language);
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,3 +11,6 @@ fn application_domain() {
|
||||||
|
|
||||||
assert_eq!(domain.to_str().unwrap(), "KI18n");
|
assert_eq!(domain.to_str().unwrap(), "KI18n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn languages() {}
|
||||||
|
|
Loading…
Reference in a new issue