Bundle translations (#6661)

This currently doesn't have public API to enable it yet.

TODO:
 - Error handling in the compiler
 - Public API in the compiler configuration
 - Documentation
This commit is contained in:
Olivier Goffart 2024-10-29 15:07:15 +01:00 committed by GitHub
parent 2f62c60e3c
commit 95f5685789
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 1163 additions and 15 deletions

View file

@ -190,6 +190,15 @@ pub enum Expression {
},
EmptyComponentFactory,
/// A reference to bundled translated string
TranslationReference {
/// An expression of type array of strings
format_args: Box<Expression>,
string_index: usize,
/// The `n` value to use for the plural form if it is a plural form
plural: Option<Box<Expression>>,
},
}
impl Expression {
@ -306,6 +315,7 @@ impl Expression {
}
Self::MinMax { ty, .. } => ty.clone(),
Self::EmptyComponentFactory => Type::ComponentFactory,
Self::TranslationReference { .. } => Type::String,
}
}
}
@ -388,6 +398,12 @@ macro_rules! visit_impl {
$visitor(rhs);
}
Expression::EmptyComponentFactory => {}
Expression::TranslationReference { format_args, plural, string_index: _ } => {
$visitor(format_args);
if let Some(plural) = plural {
$visitor(plural);
}
}
}
};
}