Skip to main content

BuildOptions

Struct BuildOptions 

Source
pub struct BuildOptions {
    pub locales_folder: String,
    pub output_file_path: String,
    pub ftl_output: FtlOutputOptions,
    pub indentation: String,
    pub default_language: String,
    pub format: bool,
    pub prefix: String,
    pub deny_duplicate_keys: bool,
    pub lint_level: LintLevel,
    pub use_isolating: bool,
}

Fields§

§locales_folder: String

The path to the folder containing the locales.

Defaults to “locales”.

§output_file_path: String

The path to the file where the generated code will be written. It is recommended to use a path inside of src/ and to include the file in the project so that you get warnings for unused translation messages.

Defaults to “src/l10n.rs”.

§ftl_output: FtlOutputOptions

The the ftl output options, which let you configure how the output ftl files are generated and accessed.

§indentation: String

The indentation used in the generated file.

Defaults to four spaces.

§default_language: String

The default language to use for the L10n enum. An error is thrown during build if the default language is not found in the locales.

It defaults to “en”

§format: bool

Whether to format the generated file or not (uses rustfmt).

Defaults to true.

§prefix: String

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

Defaults to "msg_".

§deny_duplicate_keys: bool

Whether to return an error if duplicate message keys are found within the same language.

Defaults to true.

§lint_level: LintLevel

How strictly the comments in your .ftl files are checked.

Defaults to LintLevel::Warn.

§use_isolating: bool

Whether the generated code wraps interpolated variables in Unicode bidi isolation marks (FSI U+2068 / PDI U+2069).

This is the safe default for text rendered in a bidi-aware context such as a web UI, and is required for correct rendering when a right-to-left locale is used or user-provided text is interpolated.

Defaults to true.

Implementations§

Source§

impl BuildOptions

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn without_format(self) -> Self

Source

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

Set the prefix prepended to every generated message accessor’s name. See BuildOptions::prefix.

Source

pub fn with_allow_duplicate_keys(self) -> Self

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 Unicode bidi isolation marks around interpolated variables in the generated code. See BuildOptions::use_isolating.

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.