Struct perseus::i18n::FsTranslationsManager
source · pub struct FsTranslationsManager { /* private fields */ }
Expand description
The default translations manager. This will store static files in the specified location on disk, which should be suitable for the majority of use-cases, though users who want to store translations somewhere other than on the filesystem should use an alternative implementation. 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 (a dummy translations manager).
Note that this will cache translations upon initialization, meaning source files cannot be updated while the system is running.
Implementations§
source§impl FsTranslationsManager
impl FsTranslationsManager
sourcepub async fn new(
root_path: String,
locales_to_cache: Vec<String>,
file_ext: String
) -> Self
pub async fn new( root_path: String, locales_to_cache: Vec<String>, file_ext: String ) -> Self
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§
source§impl Clone for FsTranslationsManager
impl Clone for FsTranslationsManager
source§fn clone(&self) -> FsTranslationsManager
fn clone(&self) -> FsTranslationsManager
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more