pub struct ItemI18n {
map: HashMap<ItemKey, String>,
fragments: HashMap<FragmentKey, String>,
}Expand description
To be used with ItemDesc::i18n
NOTE: there is a limitation to this manifest, as it uses ItemKey and ItemKey isn’t uniquely identifies Item, when it comes to modular items.
If modular weapon has the same primary component and the same hand-ness, we use the same model EVEN IF it has different secondary components, like Staff with Heavy core or Light core.
Translations currently do the same, but maybe they shouldn’t in which case we should either extend ItemKey or use new identifier. We could use ItemDefinitionId, but it’s very generic and cumbersome.
Fields§
§map: HashMap<ItemKey, String>maps ItemKey to i18n identifier
fragments: HashMap<FragmentKey, String>maps FragmentKey to i18n identifier
Used for optional templating for languages that can stomach them
Implementations§
Source§impl ItemI18n
impl ItemI18n
pub fn new_expect() -> Self
Sourcefn item_text_opt(&self, item_key: &ItemKey) -> Option<(Content, Content)>
fn item_text_opt(&self, item_key: &ItemKey) -> Option<(Content, Content)>
Returns (name, description) in Content form.
Sourcefn try_fragment(&self, fragment_key: &FragmentKey) -> Option<Content>
fn try_fragment(&self, fragment_key: &FragmentKey) -> Option<Content>
Tries to fetch a fragment from i18n manifest
Sourcefn try_key(&self, item_key: &ItemKey) -> Option<&String>
fn try_key(&self, item_key: &ItemKey) -> Option<&String>
Tries to fetch a key from i18n manifest, returns a i18n string, do with it what you need.
Sourcepub fn all_fragments(&self) -> impl Iterator<Item = (&FragmentKey, &String)>
pub fn all_fragments(&self) -> impl Iterator<Item = (&FragmentKey, &String)>
Returns all fragments, mainly for testing
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ItemI18n
impl<'de> Deserialize<'de> for ItemI18n
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ItemI18n
impl RefUnwindSafe for ItemI18n
impl Send for ItemI18n
impl Sync for ItemI18n
impl Unpin for ItemI18n
impl UnwindSafe for ItemI18n
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Data) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F,
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data) using
entity to marker mapping function§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more