Skip to main content

BuildOptions

Struct BuildOptions 

Source
pub struct BuildOptions { /* private fields */ }
Expand description

Configuration for the build-time code generation performed by build_from_locales_folder and try_build_from_locales_folder.

Start from BuildOptions::default and adjust it with the with_* / without_* builder methods:

let options = BuildOptions::default()
    .with_locales_folder("locales")
    .with_lint_level(LintLevel::Deny);

The fields are private on purpose: this lets new options be added in a minor release without breaking direct struct construction in your build script. Every option has a corresponding builder method.

Implementations§

Source§

impl BuildOptions

Source

pub fn with_locales_folder(self, locales_folder: &str) -> Self

Set the folder scanned for <lang-id>/<resource>.ftl files. Defaults to "locales".

Source

pub fn with_output_file_path(self, output_file_path: &str) -> Self

Set the path the generated Rust file is written to. Keeping it inside src/ (the default "src/l10n.rs") and committing it is what produces the unused-message warnings.

Source

pub fn with_indentation(self, indentation: &str) -> Self

Set the indentation used in the generated file. Defaults to four spaces.

Only takes effect together with without_format: formatting is on by default, and rustfmt re-indents the generated file back to its own style (4 spaces), silently undoing this option.

Source

pub fn with_ftl_output(self, opts: FtlOutputOptions) -> Self

Set how the joined FTL is emitted (single embedded file vs. one file per language). See FtlOutputOptions.

Source

pub fn with_default_language(self, lang: &str) -> Self

Set the default locale — the single source of truth for every message’s typed signature. A build error is raised if it has no subfolder in the locales folder. Defaults to "en".

Source

pub fn without_format(self) -> Self

Do not run rustfmt on the generated file. Formatting is on by default.

Required for with_indentation to have any effect — rustfmt would otherwise re-indent the file back to its own style.

Source

pub fn with_prefix(self, prefix: &str) -> Self

Set the prefix prepended to every generated message accessor’s name, e.g. "msg_" produces msg_hello_world(). Defaults to "msg_".

Source

pub fn with_allow_duplicate_keys(self) -> Self

Allow duplicate message keys within a language instead of failing the build. Duplicates are denied by default.

Source

pub fn with_lint_level(self, level: LintLevel) -> Self

Set how strictly the comments in your .ftl files are checked. See LintLevel.

Source

pub fn without_bidi_isolation(self) -> Self

Disable the Unicode bidi isolation marks (FSI U+2068 / PDI U+2069) that the generated code otherwise wraps around interpolated variables.

Only do this if the generated strings are never rendered in a bidi-aware context, or you never use right-to-left locales or interpolate user-provided text.

Trait Implementations§

Source§

impl Default for BuildOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.