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:
Olivier Goffart 2023-04-27 13:07:43 +02:00 committed by Olivier Goffart
parent b997d1e8b5
commit ce25fb65a6
9 changed files with 34 additions and 3 deletions

View file

@ -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,
}
}
}

View file

@ -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()),