pub struct FsTranslationsManager { /* private fields */ }
Expand description

The default translations manager. This will store static files in the specified location on disk. This should be suitable for nearly all development and serverful use-cases. Serverless is another matter though (more development needs to be done). This mandates that translations be stored as files named as the locale they describe (e.g. ‘en-US.ftl’, ‘en-US.json’, etc.).

As this is used as the default translations manager by most apps, this also supports not using i18n at all.

Implementations

Creates a new filesystem translations manager. You should provide a path like /translations here. You should also provide the locales you want to cache, which will have their translations stored in memory. Any supported locales not specified here will not be cached, and must have their translations read from disk on every request. If fetching translations for any of the given locales fails, this will panic (locales to be cached should always be hardcoded).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Creates a new instance of this translations manager, as a dummy for apps that aren’t using i18n at all. This may seem pointless, but it’s needed for trait completeness and to support certain engine middleware use-cases. In general, this should simply create an empty instance of the manager, and all other functions should do nothing if it is empty. Read more

Gets the translations in string format for the given locale (avoids deserialize-then-serialize). If i18n is disabled, this should return a translator for the given locale with no translation string. Read more

Gets a translator for the given locale. If i18n is disabled, this should return an empty string.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.