Trait leptos_i18n::Locale

source ·
pub trait Locale: 'static + Default + Clone + Copy {
    type Keys: LocaleKeys<Locale = Self>;

    // Required methods
    fn from_str(s: &str) -> Option<Self>;
    fn as_str(self) -> &'static str;

    // Provided methods
    fn find_locale<T: AsRef<str>>(accepted_langs: &[T]) -> Self { ... }
    fn get_keys(self) -> &'static Self::Keys { ... }
}
Expand description

Trait implemented the enum representing the supported locales of the application

Most functions of this crate are generic of type implementing this trait

Required Associated Types§

source

type Keys: LocaleKeys<Locale = Self>

The associated struct containing the translations

Required Methods§

source

fn from_str(s: &str) -> Option<Self>

Try to match the given str to a locale and returns it.

source

fn as_str(self) -> &'static str

Return a static str that represent the locale.

Provided Methods§

source

fn find_locale<T: AsRef<str>>(accepted_langs: &[T]) -> Self

Given a slice of accepted languages sorted in preferred order, return the locale that fit the best the request.

source

fn get_keys(self) -> &'static Self::Keys

Return the keys based on self

Object Safety§

This trait is not object safe.

Implementors§