#[non_exhaustive]pub struct ExtractOptions {
pub source_lang: Option<String>,
pub target_lang: Option<String>,
pub granularity: Granularity,
pub include_locked: bool,
pub limits: Option<Limits>,
pub format_options: BTreeMap<String, String>,
pub profile: Option<String>,
}Expand description
Options for Filter::extract. Build them with ExtractOptions::new and the with_* methods
(ExtractOptions::new().with_target_lang("de-DE")); new options are added without breaking callers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.source_lang: Option<String>The source language (a BCP 47 tag, en, de-DE), when known.
target_lang: Option<String>The target language, when known.
granularity: GranularityParsers always extract one segment per unit; bilingua-seg applies the granularity afterwards.
include_locked: boolExtract text the format marks as not translatable as locked units (for context), instead of skipping it.
limits: Option<Limits>Safety limits for this call; None uses Limits::default (Localization OS’s numbers).
format_options: BTreeMap<String, String>Options only one format knows, as "<format>.<name>" to a text value ("ftl.translate_terms" to
"true"). Each filter declares its keys and their kind (Filter::format_option_keys); the bilingua
facade refuses a key no filter declares, or a value of the wrong kind, with Error::FormatOption.
Booleans are true/false/1/0/yes/no/on/off; integers are decimal.
profile: Option<String>A behaviour profile (profile): Some("locos") for the Localization OS adapter. None: Bilingua’s own
behaviour. The bilingua facade refuses a name it does not know.
Implementations§
Source§impl ExtractOptions
impl ExtractOptions
Sourcepub fn with_profile(self, profile: impl IntoOptionString) -> ExtractOptions
pub fn with_profile(self, profile: impl IntoOptionString) -> ExtractOptions
Switches a profile on ("locos"), or off with None.
Sourcepub fn is_profile(&self, name: &str) -> bool
pub fn is_profile(&self, name: &str) -> bool
True when this profile is on.
Sourcepub fn new() -> ExtractOptions
pub fn new() -> ExtractOptions
The defaults: no languages, sentence granularity, locked text skipped, Localization OS’s limits.
Sourcepub fn with_source_lang(self, lang: impl IntoOptionString) -> ExtractOptions
pub fn with_source_lang(self, lang: impl IntoOptionString) -> ExtractOptions
Sets (or with None clears) the source language; it picks the sentence rules.
Sourcepub fn with_target_lang(self, lang: impl IntoOptionString) -> ExtractOptions
pub fn with_target_lang(self, lang: impl IntoOptionString) -> ExtractOptions
Sets (or clears) the target language.
Sourcepub fn with_granularity(self, granularity: Granularity) -> ExtractOptions
pub fn with_granularity(self, granularity: Granularity) -> ExtractOptions
Sets the granularity.
Sourcepub fn with_include_locked(self, include_locked: bool) -> ExtractOptions
pub fn with_include_locked(self, include_locked: bool) -> ExtractOptions
Extracts locked text as locked units, for context.
Sourcepub fn with_limits(self, limits: impl Into<Option<Limits>>) -> ExtractOptions
pub fn with_limits(self, limits: impl Into<Option<Limits>>) -> ExtractOptions
Limits for this call (Limits or Option<Limits>; None is the defaults).
Sourcepub fn with_format_option(
self,
key: impl Into<String>,
value: impl ToString,
) -> ExtractOptions
pub fn with_format_option( self, key: impl Into<String>, value: impl ToString, ) -> ExtractOptions
Sets one format option ("<format>.<name>"); the value is text (true, 42, name=Name).
Sourcepub fn with_format_options(
self,
options: BTreeMap<String, String>,
) -> ExtractOptions
pub fn with_format_options( self, options: BTreeMap<String, String>, ) -> ExtractOptions
Replaces all format options.
Sourcepub fn format_option(&self, key: &str) -> Option<&str>
pub fn format_option(&self, key: &str) -> Option<&str>
A format option as text, if set.
Sourcepub fn format_flag(&self, key: &str) -> Option<bool>
pub fn format_flag(&self, key: &str) -> Option<bool>
A format option as a boolean (true, 1, yes, on are true; false, 0, no, off are false; any
other text or no entry gives None).
Sourcepub fn format_int(&self, key: &str) -> Option<i64>
pub fn format_int(&self, key: &str) -> Option<i64>
A format option as an integer (None when unset or not a decimal integer).