From d8f86754b88333a2c18c70169ad7058275137777 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Thu, 23 Feb 2023 17:14:28 +0100 Subject: [PATCH] Add missing commas in macros for localizations (#143) * Add missing commas in macros for localizations * Add testing code --------- Co-authored-by: kangalioo --- .../framework_usage/commands/localization.rs | 18 +++++++++++++++++- macros/src/choice_parameter.rs | 2 +- macros/src/command/slash.rs | 4 ++-- macros/src/util.rs | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/framework_usage/commands/localization.rs b/examples/framework_usage/commands/localization.rs index 50fede19cdb5..7242f35d8a95 100644 --- a/examples/framework_usage/commands/localization.rs +++ b/examples/framework_usage/commands/localization.rs @@ -9,18 +9,28 @@ pub enum WelcomeChoice { "de", "Willkommen auf unserem coolen Server! Frag mich, falls du Hilfe brauchst" )] + #[name_localized( + "es", + "¡Bienvenido a nuestro genial servidor! Pregúntame si necesitas ayuda" + )] A, #[name = "Welcome to the club, you're now a good person. Well, I hope."] #[name_localized( "de", "Willkommen im Club, du bist jetzt ein guter Mensch. Naja, hoffentlich." )] + #[name_localized( + "es", + "Bienvenido al club, ahora eres una buena persona. Bueno, eso espero." + )] B, #[name = "I hope that you brought a controller to play together!"] #[name_localized("de", "Ich hoffe du hast einen Controller zum Spielen mitgebracht!")] + #[name_localized("es", "Espero que hayas traído un mando para jugar juntos.")] C, #[name = "Hey, do you want a coffee?"] #[name_localized("de", "Hey, willst du einen Kaffee?")] + #[name_localized("es", "Oye, ¿Quieres un café?")] D, } @@ -28,16 +38,22 @@ pub enum WelcomeChoice { #[poise::command( slash_command, name_localized("de", "begrüßen"), - description_localized("de", "Einen Nutzer begrüßen") + name_localized("es", "saludar"), + description_localized("de", "Einen Nutzer begrüßen"), + description_localized("es", "Saludar a un usuario") )] pub async fn welcome( ctx: Context<'_>, #[name_localized("de", "nutzer")] #[description_localized("de", "Der zu begrüßende Nutzer")] + #[name_localized("es", "usuario")] + #[description_localized("es", "El usuario a saludar")] #[description = "The user to welcome"] user: serenity::User, #[name_localized("de", "nachricht")] #[description_localized("de", "Die versendete Nachricht")] + #[name_localized("es", "mensaje")] + #[description_localized("es", "El mensaje enviado")] #[description = "The message to send"] message: WelcomeChoice, ) -> Result<(), Error> { diff --git a/macros/src/choice_parameter.rs b/macros/src/choice_parameter.rs index edffa22382d4..43cafda5ad1e 100644 --- a/macros/src/choice_parameter.rs +++ b/macros/src/choice_parameter.rs @@ -94,7 +94,7 @@ pub fn choice_parameter(input: syn::DeriveInput) -> Result Result>) -> proc_macro2::TokenStre let (keys, values): (Vec, Vec) = v.into_iter().map(|x| (x.0, x.1)).unzip(); quote::quote! { std::collections::HashMap::from([ - #( (#keys.to_string(), #values.to_string()) )* + #( (#keys.to_string(), #values.to_string()) ),* ]) } }