#[non_exhaustive]pub struct MergeOptions {
pub output_encoding: OutputEncoding,
pub stamp_target_always: bool,
pub profile: Option<String>,
pub format_options: BTreeMap<String, String>,
}Expand description
Options for Filter::merge_with. The default is what Filter::merge does. They live here, once, and
every format that stamps a language, fills plurals or writes text honours them:
output_encoding:OutputEncoding::KeeporOutputEncoding::Utf8(throughenc::encode_text_with, so every text format that keeps its encoding in the skeleton gets it).stamp_target_always: by default a merge in which nothing is translated returns the original bytes (no target language stamp, no plural fill, no format conversion). Withtruethe target language is stamped and missing plural forms are filled even then, as Localization OS does. It only has an effect whenDocument::target_langis set.
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.output_encoding: OutputEncodingKeep the file’s encoding, or write UTF-8.
stamp_target_always: boolStamp the target language and fill plurals even when nothing is translated.
profile: Option<String>The profile the document is written for (see ExtractOptions::profile); format crates may switch on it.
format_options: BTreeMap<String, String>Merge-time format options, as for ExtractOptions::format_options (checked against the same keys).
Implementations§
Source§impl MergeOptions
impl MergeOptions
Sourcepub fn new() -> MergeOptions
pub fn new() -> MergeOptions
The defaults: keep the file’s encoding, no stamp when nothing is translated (what Filter::merge does).
Sourcepub fn with_output_encoding(
self,
output_encoding: OutputEncoding,
) -> MergeOptions
pub fn with_output_encoding( self, output_encoding: OutputEncoding, ) -> MergeOptions
Sets the output encoding.
Sourcepub fn with_stamp_target_always(self, stamp_target_always: bool) -> MergeOptions
pub fn with_stamp_target_always(self, stamp_target_always: bool) -> MergeOptions
Sets the stamp rule.
Sourcepub fn with_profile(self, profile: impl IntoOptionString) -> MergeOptions
pub fn with_profile(self, profile: impl IntoOptionString) -> MergeOptions
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 with_format_option(
self,
key: impl Into<String>,
value: impl ToString,
) -> MergeOptions
pub fn with_format_option( self, key: impl Into<String>, value: impl ToString, ) -> MergeOptions
Sets one format option ("<format>.<name>").
Sourcepub fn with_format_options(
self,
options: BTreeMap<String, String>,
) -> MergeOptions
pub fn with_format_options( self, options: BTreeMap<String, String>, ) -> MergeOptions
Replaces all format options.
Sourcepub fn any_translated(doc: &Document) -> bool
pub fn any_translated(doc: &Document) -> bool
True when the document has at least one segment with a target.
Sourcepub fn should_stamp(&self, doc: &Document) -> bool
pub fn should_stamp(&self, doc: &Document) -> bool
Should a format stamp the target language and fill plurals for this document? target_lang must be set (and
not blank) and something translated, or stamp_target_always. “Translated” is MergeOptions::any_translated;
a format with its own notion of a change uses MergeOptions::stamp_lang.