Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,6 @@ repos:
-A,
deprecated,
]
- id: clippy
alias: clippy-hydrate
name: clippy-hydrate
args:
[
--features=hydrate,
--exclude=leptos-fluent-ssr-hydrate-axum-example,
--workspace,
--,
-D,
warnings,
-D,
clippy::perf,
-D,
clippy::print_stdout,
-D,
clippy::explicit_iter_loop,
-D,
clippy::uninlined_format_args,
-D,
clippy::semicolon_if_nothing_returned,
-A,
deprecated,
]
- repo: https://github.com/mondeja/rust-pc-hooks
rev: v1.3.0
hooks:
Expand Down
4 changes: 0 additions & 4 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions book/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ leptos-fluent = "0.2"
## SSR

For server side rendering apps install **leptos-fluent** and enable
the `hydrate`, `ssr` and `actix`/`axum` features in their respective
features set.
`ssr` and `actix` / `axum` features in their respective features set.

```toml
[dependencies]
leptos-fluent = "0.2"
axum = { version = "0.8", optional = true }

[features]
hydrate = [
"leptos-fluent/hydrate",
]
ssr = [
"leptos-fluent/ssr",
"leptos-fluent/axum", # actix and axum are supported
Expand All @@ -53,7 +49,6 @@ leptos-fluent = { version = "0.2", features = ["system"] }
## Features

- **Server Side Rendering**: `ssr`
- **Hydration**: `hydrate`
- **Actix Web integration**: `actix`
- **Axum integration**: `axum`
- **Nightly toolchain**: `nightly`
Expand Down
1 change: 0 additions & 1 deletion examples/ssr-hydrate-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ wasm-bindgen.workspace = true
[features]
hydrate = [
"leptos/hydrate",
"leptos-fluent/hydrate",
]
ssr = [
"dep:actix-files",
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-hydrate-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ wasm-bindgen.workspace = true

[features]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate", "leptos-fluent/hydrate"]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:axum",
"dep:tokio",
Expand Down
1 change: 0 additions & 1 deletion leptos-fluent-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ leptos-fluent.workspace = true
nightly = ["proc-macro2/span-locations"]
system = []
tracing = ["dep:tracing"]
hydrate = []
ssr = []
actix = []
axum = []
Expand Down
2 changes: 0 additions & 2 deletions leptos-fluent-macros/src/exprpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ pub(crate) fn evaluate_exprpath(
cfg!(feature = "nightly")
} else if *f == "ssr" {
cfg!(feature = "ssr")
} else if *f == "hydrate" {
cfg!(feature = "hydrate")
} else if *f == "system" {
cfg!(feature = "system")
} else if *f == "tracing" {
Expand Down
42 changes: 15 additions & 27 deletions leptos-fluent-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,19 @@ pub fn leptos_fluent(
None => quote! { "" },
};

// TODO: optimize checking if empty at compile time when literal
let effect_quote = quote! {
::leptos::prelude::Effect::new(move |_| {
if #set_language_to_data_file_quote.is_empty() {
return;
let effect_quote =
if set_language_to_data_file_quote.to_string() == "\"\"" {
quote! {}
} else {
quote! {
::leptos::prelude::Effect::new(move |_| {
::leptos_fluent::data_file::set(
#set_language_to_data_file_quote,
&#get_language_quote.id.to_string(),
);
});
}
::leptos_fluent::data_file::set(
#set_language_to_data_file_quote,
&#get_language_quote.id.to_string(),
);
});
};
};

match param.expr {
Some(ref expr) => {
Expand Down Expand Up @@ -373,10 +374,10 @@ pub fn leptos_fluent(
None => quote! { "" },
};

if initial_language_from_data_file_quote.to_string() == "\"\"" {
return quote! {};
}
let effect_quote = quote! {
if #initial_language_from_data_file_quote.is_empty() {
return;
}
if let Some(l) = ::leptos_fluent::data_file::get(
#initial_language_from_data_file_quote
) {
Expand Down Expand Up @@ -825,18 +826,6 @@ pub fn leptos_fluent(
let sync_language_with_session_storage_quote = quote!();

let initial_language_from_url_param_quote: proc_macro2::TokenStream = {
#[cfg(all(feature = "hydrate", not(feature = "ssr")))]
let hydrate_rerender_quote = quote! {
::leptos::prelude::Effect::new(move |prev: Option<()>| {
if prev.is_none() {
#set_language_quote;
}
});
};

#[cfg(all(not(feature = "hydrate"), not(feature = "ssr")))]
let hydrate_rerender_quote = quote! {};

#[cfg(not(feature = "ssr"))]
let set_to_local_storage_quote: proc_macro2::TokenStream = {
let effect_quote = quote! {
Expand Down Expand Up @@ -941,7 +930,6 @@ pub fn leptos_fluent(
if let Some(l) = ::leptos_fluent::url::param::get(#url_param_quote) {
lang = ::leptos_fluent::l(&l, &LANGUAGES);
if let Some(l) = lang {
#hydrate_rerender_quote
#set_to_local_storage_quote
#set_to_session_storage_quote
#set_to_cookie_quote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn I18n(children: Children) -> impl IntoView {
locales: "../../../../examples/csr-minimal/locales",
#[cfg(feature = "ssr")]
check_translations: "../../../../leptos-fluent-macros/tests/ui/leptos_fluent/fail/check_translations_cfg_feature.rs",
#[cfg(all(not(feature = "ssr"), feature = "hydrate"))]
#[cfg(all(not(feature = "ssr"), not(debug_assertions)))]
check_translations: "../../../../leptos-fluent-macros/tests/ui/leptos_fluent/fail/check_translations_cfg_feature.rs",
}
}
Expand Down
1 change: 0 additions & 1 deletion leptos-fluent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ system = [
]
nightly = ["leptos-fluent-macros/nightly"]
tracing = ["leptos-fluent-macros/tracing", "dep:tracing"]
hydrate = ["leptos-fluent-macros/hydrate"]
ssr = ["leptos-fluent-macros/ssr"]
actix = ["leptos-fluent-macros/actix"]
axum = ["leptos-fluent-macros/axum"]
Expand Down
4 changes: 0 additions & 4 deletions leptos-fluent/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions leptos-fluent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
//! axum = { version = "0.8", optional = true }
//!
//! [features]
//! hydrate = [
//! "leptos-fluent/hydrate",
//! ]
//! ssr = [
//! "leptos-fluent/ssr",
//! "leptos-fluent/axum", # actix and axum are supported
Expand Down Expand Up @@ -231,7 +228,6 @@
//! ## Features
//!
//! - **Server Side Rendering**: `ssr`
//! - **Hydration**: `hydrate`
//! - **Actix Web integration**: `actix`
//! - **Axum integration**: `axum`
//! - **Nightly toolchain**: `nightly`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ app-helpers = { path = "../../app-helpers" }

[features]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate", "leptos-fluent/hydrate"]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:actix-files",
"dep:actix-web",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ hydrate = [
"leptos/hydrate",
"dep:console_error_panic_hook",
"dep:wasm-bindgen",
"leptos-fluent/hydrate",
]
ssr = [
"dep:axum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ app-helpers = { path = "../../app-helpers" }

[features]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate", "leptos-fluent/hydrate"]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:actix-files",
"dep:actix-web",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ hydrate = [
"leptos/hydrate",
"dep:console_error_panic_hook",
"dep:wasm-bindgen",
"leptos-fluent/hydrate",
]
ssr = [
"dep:axum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ app-helpers = { path = "../../app-helpers" }

[features]
csr = ["leptos/csr"]
hydrate = ["leptos/hydrate", "leptos-fluent/hydrate"]
hydrate = ["leptos/hydrate"]
ssr = [
"dep:actix-files",
"dep:actix-web",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ hydrate = [
"leptos/hydrate",
"dep:console_error_panic_hook",
"dep:wasm-bindgen",
"leptos-fluent/hydrate",
]
ssr = [
"dep:axum",
Expand Down
Loading