diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ac8918..5b27b392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## 2024-09-24 - [0.1.22] + +### Bug fixes + +- Fix translations checker not detecting translation macros inside macro + calls (regression from v0.1.21). + ## 2024-08-27 - [0.1.21] ### Bug fixes @@ -507,6 +514,7 @@ version to `0.1` during installation. - Added all ISO-639-1 and ISO-639-2 languages. +[0.1.22]: https://github.com/mondeja/leptos-fluent/compare/v0.1.21...v0.1.22 [0.1.21]: https://github.com/mondeja/leptos-fluent/compare/v0.1.20...v0.1.21 [0.1.20]: https://github.com/mondeja/leptos-fluent/compare/v0.1.19...v0.1.20 [0.1.19]: https://github.com/mondeja/leptos-fluent/compare/v0.1.18...v0.1.19 diff --git a/Cargo.lock b/Cargo.lock index a57ed92f..884cc542 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1794,7 +1794,7 @@ dependencies = [ [[package]] name = "leptos-fluent" -version = "0.1.21" +version = "0.1.22" dependencies = [ "current_locale", "directories", @@ -1857,7 +1857,7 @@ dependencies = [ [[package]] name = "leptos-fluent-macros" -version = "0.1.21" +version = "0.1.22" dependencies = [ "cfg-expr 0.15.8", "current_platform", diff --git a/leptos-fluent-macros/Cargo.toml b/leptos-fluent-macros/Cargo.toml index a6ce4ac6..b3b14c4b 100644 --- a/leptos-fluent-macros/Cargo.toml +++ b/leptos-fluent-macros/Cargo.toml @@ -2,7 +2,7 @@ name = "leptos-fluent-macros" description = "Macros for leptos-fluent" edition.workspace = true -version = "0.1.21" +version = "0.1.22" license = "MIT" documentation.workspace = true repository.workspace = true diff --git a/leptos-fluent-macros/src/translations_checker/tr_macros.rs b/leptos-fluent-macros/src/translations_checker/tr_macros.rs index 9010b115..63105c2c 100644 --- a/leptos-fluent-macros/src/translations_checker/tr_macros.rs +++ b/leptos-fluent-macros/src/translations_checker/tr_macros.rs @@ -303,6 +303,11 @@ impl<'ast> TranslationsMacrosVisitor { impl<'ast> Visit<'ast> for TranslationsMacrosVisitor { fn visit_macro(&mut self, node: &'ast syn::Macro) { self.visit_maybe_macro_tokens_stream(&node.to_token_stream()); + for token in node.tokens.clone() { + if let proc_macro2::TokenTree::Group(group) = token { + self.visit_maybe_macro_tokens_stream(&group.stream()); + } + } syn::visit::visit_macro(self, node); } @@ -642,4 +647,40 @@ mod tests { ] ); } + + #[test] + fn tr_in_move_tr_params() { + let content = quote! { + #[component] + fn App() -> impl IntoView { + let download_svg_msg = + move_tr!("download-filetype", {"filetype" => tr!("svg")}); + let download_colored_svg_msg = + move_tr!("download-filetype", {"filetype" => tr!("colored-svg")}); + let download_pdf_msg = + move_tr!("download-filetype", {"filetype" => tr!("pdf")}); + let download_jpg_msg = + move_tr!("download-filetype", {"filetype" => tr!("jpg")}); + let download_png_msg = + move_tr!("download-filetype", {"filetype" => tr!("png")}); + } + }; + let tr_macros = tr_macros_from_file_content(&content.to_string()); + + assert_eq!( + tr_macros, + vec![ + tr_macro!( + "move_tr", + "download-filetype", + vec!["filetype".to_string()] + ), + tr_macro!("tr", "svg", Vec::new()), + tr_macro!("tr", "colored-svg", Vec::new()), + tr_macro!("tr", "pdf", Vec::new()), + tr_macro!("tr", "jpg", Vec::new()), + tr_macro!("tr", "png", Vec::new()), + ] + ); + } } diff --git a/leptos-fluent/Cargo.toml b/leptos-fluent/Cargo.toml index f4eb5a47..95906613 100644 --- a/leptos-fluent/Cargo.toml +++ b/leptos-fluent/Cargo.toml @@ -2,7 +2,7 @@ name = "leptos-fluent" description = "Fluent framework for internationalization of Leptos applications" edition.workspace = true -version = "0.1.21" +version = "0.1.22" license = "MIT" documentation.workspace = true repository.workspace = true