mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
C++ Interpreter: Add support for setting the translation domain
This maps straight to the Rust API.
This commit is contained in:
parent
9f0c3c94a9
commit
fa2cf8c28a
3 changed files with 23 additions and 0 deletions
|
@ -980,6 +980,13 @@ public:
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the domain used for translations.
|
||||||
|
void set_translation_domain(std::string_view domain)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_interpreter_component_compiler_set_translation_domain(
|
||||||
|
&inner, slint::private_api::string_to_slice(domain));
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the include paths the component compiler is currently configured with.
|
/// Returns the include paths the component compiler is currently configured with.
|
||||||
slint::SharedVector<slint::SharedString> include_paths() const
|
slint::SharedVector<slint::SharedString> include_paths() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -284,6 +284,12 @@ SCENARIO("Component Compiler")
|
||||||
REQUIRE(compiler.style() == "fluent");
|
REQUIRE(compiler.style() == "fluent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("configure translation domain")
|
||||||
|
{
|
||||||
|
// Make sure this compiles.
|
||||||
|
compiler.set_translation_domain("cpptests");
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("Compile failure from source")
|
SECTION("Compile failure from source")
|
||||||
{
|
{
|
||||||
auto result = compiler.build_from_source("Syntax Error!!", "");
|
auto result = compiler.build_from_source("Syntax Error!!", "");
|
||||||
|
|
|
@ -704,6 +704,16 @@ pub unsafe extern "C" fn slint_interpreter_component_compiler_set_style(
|
||||||
compiler.as_component_compiler_mut().set_style(std::str::from_utf8(&style).unwrap().to_string())
|
compiler.as_component_compiler_mut().set_style(std::str::from_utf8(&style).unwrap().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_interpreter_component_compiler_set_translation_domain(
|
||||||
|
compiler: &mut ComponentCompilerOpaque,
|
||||||
|
translation_domain: Slice<u8>,
|
||||||
|
) {
|
||||||
|
compiler
|
||||||
|
.as_component_compiler_mut()
|
||||||
|
.set_translation_domain(std::str::from_utf8(&translation_domain).unwrap().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn slint_interpreter_component_compiler_get_style(
|
pub unsafe extern "C" fn slint_interpreter_component_compiler_get_style(
|
||||||
compiler: &ComponentCompilerOpaque,
|
compiler: &ComponentCompilerOpaque,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue