mirror of
https://github.com/italicsjenga/valence.git
synced 2025-01-11 07:11:30 +11:00
Add translation keys to block kind
This commit is contained in:
parent
9c67978e06
commit
cd110c3cbb
|
@ -64,6 +64,17 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
|||
|
||||
let max_state_id = blocks.iter().map(|b| b.max_state_id()).max().unwrap();
|
||||
|
||||
let kind_to_translation_key_arms = blocks
|
||||
.iter()
|
||||
.map(|b| {
|
||||
let kind = ident(b.name.to_pascal_case());
|
||||
let translation_key = &b.translation_key;
|
||||
quote! {
|
||||
Self::#kind => #translation_key,
|
||||
}
|
||||
})
|
||||
.collect::<TokenStream>();
|
||||
|
||||
let state_to_kind_arms = blocks
|
||||
.iter()
|
||||
.map(|b| {
|
||||
|
@ -551,6 +562,12 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn translation_key(self) -> &'static str {
|
||||
match self {
|
||||
#kind_to_translation_key_arms
|
||||
}
|
||||
}
|
||||
|
||||
/// An array of all block kinds.
|
||||
pub const ALL: [Self; #block_kind_count] = [#(Self::#block_kind_variants,)*];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue