mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Pass the translation domain to the runtime
For rust, it uses the crate name, for others, it needs to be passed in the comment line
This commit is contained in:
parent
b997d1e8b5
commit
ce25fb65a6
9 changed files with 34 additions and 3 deletions
|
@ -77,6 +77,9 @@ pub struct CompilerConfiguration {
|
|||
|
||||
/// expose the accessible role and properties
|
||||
pub accessibility: bool,
|
||||
|
||||
/// The domain used as one of the parameter to the translate function
|
||||
pub translation_domain: Option<String>,
|
||||
}
|
||||
|
||||
impl CompilerConfiguration {
|
||||
|
@ -128,6 +131,7 @@ impl CompilerConfiguration {
|
|||
inline_all_elements,
|
||||
scale_factor,
|
||||
accessibility: true,
|
||||
translation_domain: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -525,6 +525,11 @@ impl Expression {
|
|||
return Expression::Invalid;
|
||||
};
|
||||
|
||||
let domain = ctx
|
||||
.type_loader
|
||||
.and_then(|tl| tl.compiler_config.translation_domain.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
let subs = node.Expression().map(|n| {
|
||||
Expression::from_expression_node(n.clone(), ctx).maybe_convert_to(
|
||||
Type::String,
|
||||
|
@ -541,7 +546,7 @@ impl Expression {
|
|||
arguments: vec![
|
||||
Expression::StringLiteral(string),
|
||||
Expression::StringLiteral(String::new()), // TODO
|
||||
Expression::StringLiteral(String::new()), // TODO
|
||||
Expression::StringLiteral(domain),
|
||||
Expression::Array { element_ty: Type::String, values: subs.collect() },
|
||||
],
|
||||
source_location: Some(node.to_source_location()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue