pub struct LocalizationOptions { /* private fields */ }Expand description
Resource files registered with the host.
Two sources, merged in this order (later wins):
- a resource directory of
<culture>.jsonfiles, relative to the application base (locales/by default foradd_localization()), read at startup so operators can adjust translations without a rebuild; - explicit
(culture, json)entries compiled into the binary withinclude_str!— the single-executable form.
Implementations§
Source§impl LocalizationOptions
impl LocalizationOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
The conventional layout (locales/<culture>.json) with no compiled-in
entries. This is what HostBuilder::add_localization() uses.
Sourcepub fn none() -> Self
pub fn none() -> Self
No resource directory and no resources.
Use it for explicit-only resources
(LocalizationOptions::none().resources(...)) or to disable localization.
Sourcepub fn resource_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn resource_dir(self, dir: impl Into<PathBuf>) -> Self
Read <culture>.json files from dir.
Relative paths resolve against the application base, like
appsettings.json. Self::new sets this to "locales".
Trait Implementations§
Source§impl Clone for LocalizationOptions
impl Clone for LocalizationOptions
Source§impl Debug for LocalizationOptions
impl Debug for LocalizationOptions
Auto Trait Implementations§
impl Forget for LocalizationOptions
impl Freeze for LocalizationOptions
impl Move for LocalizationOptions
impl RefUnwindSafe for LocalizationOptions
impl Send for LocalizationOptions
impl Sync for LocalizationOptions
impl Unpin for LocalizationOptions
impl UnsafeUnpin for LocalizationOptions
impl UnwindSafe for LocalizationOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more