Skip to content

Commit cadf96d

Browse files
authored
Allow to access leptos_fluent! parameter values at runtime (#170)
1 parent c72bc79 commit cadf96d

File tree

11 files changed

+374
-102
lines changed

11 files changed

+374
-102
lines changed

.gitattributes

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Cargo.lock -diff
33

44
# READMEs are autogenerated other files
5-
/README.md -diff
6-
/leptos-fluent-macros/README.md -diff
7-
/leptos-fluent/README.md -diff
8-
book/mdbook-admonish.css -diff
5+
/README.md -diff linguist-generated
6+
/leptos-fluent-macros/README.md -diff linguist-generated
7+
/leptos-fluent/README.md -diff linguist-generated
8+
/book/mdbook-admonish.css -diff linguist-generated
99

1010
# Don't export/archive these files
1111
.github export-ignore

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## Unreleased - [0.1.6]
4+
5+
### New features
6+
7+
- Add `provide_meta_context` parameter to `leptos_fluent!` to provide meta
8+
information about the macro caller arguments. Use, for example,
9+
`leptos_fluent::i18n().meta().unwrap().cookie_name` to get the value
10+
`cookie_name` used as parameter for the macro.
11+
312
## 2024-06-26 - [0.1.5]
413

514
### New features
@@ -310,6 +319,7 @@ version to `0.1` during installation.
310319

311320
- Added all ISO-639-1 and ISO-639-2 languages.
312321

322+
[0.1.6]: https://github.com/mondeja/leptos-fluent/compare/v0.1.5...master
313323
[0.1.5]: https://github.com/mondeja/leptos-fluent/compare/v0.1.4...v0.1.5
314324
[0.1.4]: https://github.com/mondeja/leptos-fluent/compare/v0.1.3...v0.1.4
315325
[0.1.3]: https://github.com/mondeja/leptos-fluent/compare/v0.1.2...v0.1.3

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/system-gtk/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
// Connect to "activate" signal of `app`
2222
app.connect_activate(build_ui);
2323

24-
leptos_fluent! {{
24+
let i18n = leptos_fluent! {{
2525
translations: [TRANSLATIONS],
2626
locales: "./locales",
2727
check_translations: "./src/**/*.rs",
@@ -30,8 +30,14 @@ fn main() {
3030
initial_language_from_system_to_data_file: true,
3131
set_language_to_data_file: true,
3232
data_file_key: "leptos-fluent-gtk-example",
33+
provide_meta_context: true,
3334
}};
3435

36+
#[allow(clippy::print_stdout)]
37+
{
38+
println!("Macro parameters: {:?}", i18n.meta().unwrap());
39+
}
40+
3541
// Run the application
3642
app.run();
3743
}

leptos-fluent-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "leptos-fluent-macros"
33
description = "Macros for leptos-fluent"
44
edition.workspace = true
5-
version = "0.1.5"
5+
version = "0.1.6"
66
license = "MIT"
77
documentation.workspace = true
88
repository.workspace = true

leptos-fluent-macros/src/files_tracker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub(crate) fn build_files_tracker_quote(
3939
}
4040
if let Some(languages_file_path) = &languages_path {
4141
files_tracker_str.push_str(&format!(
42-
"let languages = include_bytes!(\"{}\");",
42+
"let l = include_bytes!(\"{}\");",
4343
&escape_string(languages_file_path)
4444
));
4545
}
4646
if let Some(core_locales_file_path) = &core_locales_path {
4747
files_tracker_str.push_str(&format!(
48-
"let core_locales = include_bytes!(\"{}\");",
48+
"let c = include_bytes!(\"{}\");",
4949
&escape_string(core_locales_file_path)
5050
));
5151
}

0 commit comments

Comments
 (0)