diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 80cc2534..a62ca05f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,7 +8,7 @@ on:
- master
env:
CARGO_TERM_COLOR: always
- CARGO_LEPTOS_VERSION: 0.2.21
+ CARGO_LEPTOS_VERSION: 0.2.22
jobs:
lib_test:
name: Test leptos_i18n package
diff --git a/Cargo.toml b/Cargo.toml
index 42126f11..8a85d8c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ members = [
"tests/json",
"tests/common",
"tests/namespaces",
+ "leptos_i18n_router",
]
exclude = ["examples", "tests"]
@@ -19,5 +20,24 @@ version = "0.5.0-rc1"
leptos_i18n_macro = { path = "./leptos_i18n_macro", default-features = false, version = "=0.5.0-rc1" }
leptos_i18n_parser = { path = "./leptos_i18n_parser", default-features = false, version = "=0.5.0-rc1" }
leptos_i18n = { path = "./leptos_i18n", version = "0.5.0-rc1" }
+leptos_i18n_router = { path = "./leptos_i18n_router", version = "0.5.0-rc1" }
+
+# leptos
+leptos = { version = "0.7.0" }
+leptos_router = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+
+# icu
+icu_locid = { version = "1.5" }
+icu_provider = { version = "1.5" }
+fixed_decimal = { version = "0.5" }
+icu_datagen = { version = "1.5" }
+icu_plurals = { version = "1.5", default-features = false }
+icu_datetime = { version = "1.5", default-features = false }
+icu_calendar = { version = "1.5", default-features = false }
+icu_list = { version = "1.5", default-features = false }
+icu_decimal = { version = "1.5", default-features = false }
+icu_locid_transform = { version = "1.5", default-features = false }
+
+# internal use
tests_common = { path = "./tests/common", version = "0.1.0" }
-leptos = { version = "0.7.0-rc1" }
diff --git a/docs/book/src/06_features.md b/docs/book/src/06_features.md
index 1203515e..5f6071bb 100644
--- a/docs/book/src/06_features.md
+++ b/docs/book/src/06_features.md
@@ -26,7 +26,7 @@ This feature must be enabled when building the client in csr mode
Set a cookie to remember the last chosen locale.
-#### `experimental-islands`
+#### `islands`
This feature is, as it's name says, experimental.
This make this lib somewhat usable when using `islands` with Leptos.
diff --git a/docs/book/src/usage/02_context.md b/docs/book/src/usage/02_context.md
index 95647feb..f3f1d0d8 100644
--- a/docs/book/src/usage/02_context.md
+++ b/docs/book/src/usage/02_context.md
@@ -126,7 +126,7 @@ The `I18nContextProvider` component accept multiple props, all optionnal (except
## Note on island
-If you use the `experimental-islands` feature from Leptos the `I18nContextProvider` loose two props: `cookie_options` and `ssr_lang_header_getter`, because they are not serializable. If you need them you can use the `init_context_with_options` function and provide the context yourself:
+If you use the `islands` feature from Leptos the `I18nContextProvider` loose two props: `cookie_options` and `ssr_lang_header_getter`, because they are not serializable. If you need them you can use the `init_context_with_options` function and provide the context yourself:
```rust
use leptos_i18n::init_i18n_context_with_options;
diff --git a/docs/book/src/usage/07_router.md b/docs/book/src/usage/07_router.md
index f4855a1c..5718eaef 100644
--- a/docs/book/src/usage/07_router.md
+++ b/docs/book/src/usage/07_router.md
@@ -1,22 +1,23 @@
# `I18nRoute`
-The `i18n` module generated from the `load_locales!()` macro export the `I18nRoute` component,
+You can use the `leptos_i18n_router` crate that export the `I18nRoute` component,
this component act exactly like a `leptos_router::Route` and take the same args, except for the path.
What it does is manage a prefix on the URL such that
```rust
-use crate::i18n::I18nRoute;
+use crate::i18n::Locale;
+use leptos_i18n_router::I118nRoute;
use leptos::prelude::*;
use leptos_router::*;
view! {
-
+ view=Outlet>
-
+ >
}
@@ -68,11 +69,11 @@ and the history will look like you directly navigated from `"/fr/counter"` to `"
You can use inside the `i18nRoute` the `i18n_path!` to create localized path segments:
```rust
-use leptos_i18n::i18n_path;
+use leptos_i18n_router::i18n_path;
-
+ view=Outlet>
-
+>
```
If you have `segment_path_name = "search"` for english, and `segment_path_name = "rechercher"` for french, the `I18nRoute` will produce 3 paths:
@@ -93,9 +94,9 @@ view! {
-
+ view=Outlet>
-
+ >
@@ -105,41 +106,21 @@ view! {
And the `Menu` component use localization, you could be suprised to see that sometimes there is a mismatch beetween the locale used by the `Menu` and the one inside the router.
This is due to the locale being read from the URL only when the `i18nRoute` is rendered. So the context may be initialized with another locale, and then hit the router that update it.
-You have multiple solutions, you can either use the `Menu` component inside the `i18nRoute`:
+One solution would be to use the `Menu` component inside the `i18nRoute`:
```rust
view! {
- view=|| view! {
}>
-
+ >
}
```
-
-Or you can use the `parse_locale_from_path` option on the `I18nContextProvider`:
-
-```rust
-view! {
-
-
-
-
-
-
-
-
-
-
-}
-```
-
-This option force the context to initialize itself with the locale from the URL. It is not enabled by default because the only time it is neededis this particular case.
-It expect the base_path argument you would pass to the `I18nRoute`.
diff --git a/examples/csr/counter/Cargo.toml b/examples/csr/counter/Cargo.toml
index 1dd35fe8..d35ebea6 100644
--- a/examples/csr/counter/Cargo.toml
+++ b/examples/csr/counter/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/counter_icu_datagen/Cargo.toml b/examples/csr/counter_icu_datagen/Cargo.toml
index 07dba1d0..9a6c0246 100644
--- a/examples/csr/counter_icu_datagen/Cargo.toml
+++ b/examples/csr/counter_icu_datagen/Cargo.toml
@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", default-features = false, features = [
"json_files",
"csr",
diff --git a/examples/csr/counter_plurals/Cargo.toml b/examples/csr/counter_plurals/Cargo.toml
index fae1140f..4b9abd57 100644
--- a/examples/csr/counter_plurals/Cargo.toml
+++ b/examples/csr/counter_plurals/Cargo.toml
@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr", "plurals"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/counter_ranges/Cargo.toml b/examples/csr/counter_ranges/Cargo.toml
index 3a8edaf6..a6656d86 100644
--- a/examples/csr/counter_ranges/Cargo.toml
+++ b/examples/csr/counter_ranges/Cargo.toml
@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/interpolation/Cargo.toml b/examples/csr/interpolation/Cargo.toml
index 980ad8cc..d3494816 100644
--- a/examples/csr/interpolation/Cargo.toml
+++ b/examples/csr/interpolation/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/namespaces/Cargo.toml b/examples/csr/namespaces/Cargo.toml
index 82fdaf75..cac3c96d 100644
--- a/examples/csr/namespaces/Cargo.toml
+++ b/examples/csr/namespaces/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/routing_csr/Cargo.toml b/examples/csr/routing_csr/Cargo.toml
index a2176d8a..6ae0b582 100644
--- a/examples/csr/routing_csr/Cargo.toml
+++ b/examples/csr/routing_csr/Cargo.toml
@@ -6,14 +6,15 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
+leptos_i18n_router = { path = "../../../leptos_i18n_router" }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
wasm-bindgen = { version = "0.2" }
-leptos_router = { version = "0.7.0-rc1" }
+leptos_router = { version = "0.7.0" }
[package.metadata.leptos-i18n]
default = "en"
diff --git a/examples/csr/routing_csr/src/app.rs b/examples/csr/routing_csr/src/app.rs
index be241b9b..3be33e25 100644
--- a/examples/csr/routing_csr/src/app.rs
+++ b/examples/csr/routing_csr/src/app.rs
@@ -1,5 +1,6 @@
use crate::i18n::*;
use leptos::prelude::*;
+use leptos_i18n_router::I18nRoute;
use leptos_router::{components::*, path};
#[component]
@@ -11,10 +12,10 @@ pub fn App() -> impl IntoView {
- }>
+ view=|| view! { }>
-
+ >
diff --git a/examples/csr/subcontext/Cargo.toml b/examples/csr/subcontext/Cargo.toml
index 08cfada5..6f24b412 100644
--- a/examples/csr/subcontext/Cargo.toml
+++ b/examples/csr/subcontext/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/subkeys/Cargo.toml b/examples/csr/subkeys/Cargo.toml
index 995f8aaf..88421f3b 100644
--- a/examples/csr/subkeys/Cargo.toml
+++ b/examples/csr/subkeys/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", features = ["csr"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1" }
diff --git a/examples/csr/yaml/Cargo.toml b/examples/csr/yaml/Cargo.toml
index 3bff3232..3f5f841b 100644
--- a/examples/csr/yaml/Cargo.toml
+++ b/examples/csr/yaml/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["csr"] }
-leptos_meta = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["csr"] }
+leptos_meta = { version = "0.7.0" }
leptos_i18n = { path = "../../../leptos_i18n", default-features = false, features = [
"csr",
"cookie",
diff --git a/examples/dynamic_load/axum_island/Cargo.toml b/examples/dynamic_load/axum_island/Cargo.toml
index f7098c36..47ef6f43 100644
--- a/examples/dynamic_load/axum_island/Cargo.toml
+++ b/examples/dynamic_load/axum_island/Cargo.toml
@@ -10,28 +10,29 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
-leptos = { version = "0.7.0-beta", features = ["experimental-islands"] }
+leptos = { version = "0.7.0-beta", features = ["islands"] }
leptos_meta = { version = "0.7.0-beta" }
leptos_axum = { version = "0.7.0-beta", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
- "experimental-islands",
+ "islands",
"dynamic_load",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/dynamic_load/hello_world_actix/Cargo.toml b/examples/dynamic_load/hello_world_actix/Cargo.toml
index 6dc9c068..9c276394 100644
--- a/examples/dynamic_load/hello_world_actix/Cargo.toml
+++ b/examples/dynamic_load/hello_world_actix/Cargo.toml
@@ -11,22 +11,23 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4.4", optional = true, features = ["macros"] }
-leptos = { version = "0.7.0-rc1" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_actix = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+leptos_actix = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
"dynamic_load",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/dynamic_load/hello_world_axum/Cargo.toml b/examples/dynamic_load/hello_world_axum/Cargo.toml
index a13f0c01..d78f8aa3 100644
--- a/examples/dynamic_load/hello_world_axum/Cargo.toml
+++ b/examples/dynamic_load/hello_world_axum/Cargo.toml
@@ -11,26 +11,27 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
leptos = { version = "0.7.0-beta" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+leptos_meta = { version = "0.7.0" }
+leptos_axum = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
"dynamic_load",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/dynamic_load/namespaces/Cargo.toml b/examples/dynamic_load/namespaces/Cargo.toml
index 7f0928cd..544b0504 100644
--- a/examples/dynamic_load/namespaces/Cargo.toml
+++ b/examples/dynamic_load/namespaces/Cargo.toml
@@ -11,26 +11,27 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
leptos = { version = "0.7.0-beta" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+leptos_meta = { version = "0.7.0" }
+leptos_axum = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
"dynamic_load",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/ssr/axum_island/Cargo.toml b/examples/ssr/axum_island/Cargo.toml
index aea0be7c..6ec0ca1d 100644
--- a/examples/ssr/axum_island/Cargo.toml
+++ b/examples/ssr/axum_island/Cargo.toml
@@ -10,27 +10,28 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
-leptos = { version = "0.7.0-rc1", features = ["experimental-islands"] }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0", features = ["islands"] }
+leptos_meta = { version = "0.7.0" }
+leptos_axum = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
- "experimental-islands",
+ "islands",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/ssr/hello_world_actix/Cargo.toml b/examples/ssr/hello_world_actix/Cargo.toml
index c7ad42a0..6567d401 100644
--- a/examples/ssr/hello_world_actix/Cargo.toml
+++ b/examples/ssr/hello_world_actix/Cargo.toml
@@ -11,21 +11,22 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4.4", optional = true, features = ["macros"] }
-leptos = { version = "0.7.0-rc1" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_actix = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+leptos_actix = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/ssr/hello_world_axum/Cargo.toml b/examples/ssr/hello_world_axum/Cargo.toml
index 1d93f51a..c200bb38 100644
--- a/examples/ssr/hello_world_axum/Cargo.toml
+++ b/examples/ssr/hello_world_axum/Cargo.toml
@@ -10,26 +10,27 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
-leptos = { version = "0.7.0-rc1" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+leptos_axum = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/ssr/routing_ssr/Cargo.toml b/examples/ssr/routing_ssr/Cargo.toml
index de368d95..3300626a 100644
--- a/examples/ssr/routing_ssr/Cargo.toml
+++ b/examples/ssr/routing_ssr/Cargo.toml
@@ -10,28 +10,29 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.7", optional = true }
-leptos = { version = "0.7.0-rc1" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+leptos_axum = { version = "0.7.0", optional = true }
leptos_i18n = { path = "../../../leptos_i18n", features = [
"track_locale_files",
] }
+leptos_i18n_router = { path = "../../../leptos_i18n_router" }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
simple_logger = "4"
tokio = { version = "1.35", features = ["rt-multi-thread"], optional = true }
log = "0.4"
tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true }
-
-leptos_router = { version = "0.7.0-rc1" }
+leptos_router = { version = "0.7.0" }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
@@ -45,6 +46,7 @@ ssr = [
"leptos_meta/ssr",
"leptos_i18n/axum",
"leptos_router/ssr",
+ "leptos_i18n_router/ssr",
]
[package.metadata.leptos-i18n]
diff --git a/examples/ssr/routing_ssr/src/app.rs b/examples/ssr/routing_ssr/src/app.rs
index f22b797a..2fd13758 100644
--- a/examples/ssr/routing_ssr/src/app.rs
+++ b/examples/ssr/routing_ssr/src/app.rs
@@ -1,5 +1,6 @@
use crate::i18n::*;
use leptos::prelude::*;
+use leptos_i18n_router::I18nRoute;
use leptos_router::{components::*, path};
#[component]
@@ -11,10 +12,10 @@ pub fn App() -> impl IntoView {
- }>
+ view=|| view! { }>
-
+ >
diff --git a/examples/ssr/workspace/client/Cargo.toml b/examples/ssr/workspace/client/Cargo.toml
index f236d861..b99d80d9 100644
--- a/examples/ssr/workspace/client/Cargo.toml
+++ b/examples/ssr/workspace/client/Cargo.toml
@@ -10,19 +10,20 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
actix-web = { version = "4.4", optional = true, features = ["macros"] }
-leptos = { version = "0.7.0-rc1" }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_actix = { version = "0.7.0-rc1", optional = true }
+leptos = { version = "0.7.0" }
+leptos_meta = { version = "0.7.0" }
+leptos_actix = { version = "0.7.0", optional = true }
leptos_i18n = { workspace = true, features = ["track_locale_files"] }
serde = { version = "1", features = ["derive"] }
console_error_panic_hook = { version = "0.1", optional = true }
-wasm-bindgen = { version = "0.2", optional = true }
+# wasm-bindgen = { version = "0.2", optional = true }
+wasm-bindgen = "=0.2.96"
[features]
default = ["hydrate", "ssr"]
hydrate = [
"dep:console_error_panic_hook",
- "dep:wasm-bindgen",
+ # "dep:wasm-bindgen",
"leptos/hydrate",
"leptos_i18n/hydrate",
]
diff --git a/examples/ssr/workspace/server/Cargo.toml b/examples/ssr/workspace/server/Cargo.toml
index 14671ef6..3d77ad9f 100644
--- a/examples/ssr/workspace/server/Cargo.toml
+++ b/examples/ssr/workspace/server/Cargo.toml
@@ -8,8 +8,8 @@ edition = "2021"
[dependencies]
actix-files = "0.6"
actix-web = { version = "4.4", features = ["macros"] }
-leptos = { version = "0.7.0-rc1", features = ["ssr"] }
-leptos_meta = { version = "0.7.0-rc1", features = ["ssr"] }
-leptos_actix = { version = "0.7.0-rc1" }
+leptos = { version = "0.7.0", features = ["ssr"] }
+leptos_meta = { version = "0.7.0", features = ["ssr"] }
+leptos_actix = { version = "0.7.0" }
serde = { version = "1", features = ["derive"] }
client = { path = "../client", default-features = false, features = ["ssr"] }
diff --git a/leptos_i18n/Cargo.toml b/leptos_i18n/Cargo.toml
index 0dc58a1c..91f955a2 100644
--- a/leptos_i18n/Cargo.toml
+++ b/leptos_i18n/Cargo.toml
@@ -11,38 +11,32 @@ readme = "../README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos-use = { version = "0.14.0-rc1", default-features = false, features = [
+leptos-use = { version = "0.14.0", default-features = false, features = [
"use_locales",
"use_cookie",
] }
leptos_i18n_macro = { workspace = true }
leptos = { workspace = true }
-leptos_meta = { version = "0.7.0-rc1" }
-leptos_router = { version = "0.7.0-rc1" }
+leptos_meta = { workspace = true }
codee = "0.2"
-# icu = { version = "1.5", features = ["sync"] }
-icu_locid = { version = "1.5" }
-icu_provider = { version = "1.5", optional = true, features = ["sync"] }
-icu_plurals = { version = "1.5", optional = true, default-features = false }
-icu_datetime = { version = "1.5", optional = true }
-icu_calendar = { version = "1.5", optional = true }
-icu_list = { version = "1.5", optional = true }
-icu_decimal = { version = "1.5", optional = true }
+icu_locid = { workspace = true }
+icu_provider = { workspace = true, optional = true, features = ["sync"] }
+icu_plurals = { workspace = true, optional = true }
+icu_datetime = { workspace = true, optional = true }
+icu_calendar = { workspace = true, optional = true }
+icu_list = { workspace = true, optional = true }
+icu_decimal = { workspace = true, optional = true }
typed-builder = "0.20"
-fixed_decimal = { version = "0.5", optional = true, features = ["ryu"] }
+fixed_decimal = { workspace = true, optional = true, features = ["ryu"] }
writeable = "0.5"
serde = "1.0"
-wasm-bindgen = "0.2.93"
async-once-cell = { version = "0.5.3", optional = true }
js-sys = { version = "0.3.70", optional = true }
serde-wasm-bindgen = { version = "0.6.5", optional = true }
futures = { version = "0.3.30", optional = true }
noop-waker = { version = "0.1.0", optional = true }
default-struct-builder = "0.5"
-
-# FIXME
-leptos_actix = { version = "0.7.0-rc1", optional = true }
-leptos_axum = { version = "0.7.0-rc1", optional = true }
+wasm-bindgen = "0.2.96"
[features]
default = ["cookie", "json_files", "icu_compiled_data"]
@@ -73,8 +67,8 @@ format_nums = [
"dep:icu_provider",
"leptos_i18n_macro/format_nums",
]
-actix = ["ssr", "leptos-use/actix", "dep:leptos_actix"]
-axum = ["ssr", "leptos-use/axum", "dep:leptos_axum"]
+actix = ["ssr", "leptos-use/actix"]
+axum = ["ssr", "leptos-use/axum"]
hydrate = [
"leptos/hydrate",
"leptos_i18n_macro/hydrate",
@@ -86,13 +80,9 @@ ssr = [
"leptos/ssr",
"leptos_meta/ssr",
"leptos-use/ssr",
- "leptos_router/ssr",
"leptos_i18n_macro/ssr",
]
-experimental-islands = [
- "leptos/experimental-islands",
- "leptos_i18n_macro/experimental-islands",
-]
+islands = ["leptos/islands", "leptos_i18n_macro/islands"]
nightly = ["leptos/nightly", "leptos_i18n_macro/nightly"]
dynamic_load = [
diff --git a/leptos_i18n/src/context.rs b/leptos_i18n/src/context.rs
index 34dd0b40..89d0e956 100644
--- a/leptos_i18n/src/context.rs
+++ b/leptos_i18n/src/context.rs
@@ -166,10 +166,6 @@ where
cookie_options: CookieOptions,
/// Options to pass to `leptos_use::use_locales`.
ssr_lang_header_getter: UseLocalesOptions,
- /// Try to parse the locale from the URL pathname, expect the basepath. (default to `None`).
- /// If `None` do nothing, if `Some(base_path)` strip the URL from `base_path` then expect to found a path segment that represent a locale.
- /// This is usefull when using the `I18nRoute` with usage of the context outside the router.
- parse_locale_from_path: Option>,
}
impl Default for I18nContextOptions<'_, L> {
@@ -179,7 +175,6 @@ impl Default for I18nContextOptions<'_, L> {
cookie_name: Cow::Borrowed(COOKIE_PREFERED_LANG),
cookie_options: Default::default(),
ssr_lang_header_getter: Default::default(),
- parse_locale_from_path: None,
}
}
}
@@ -192,7 +187,6 @@ pub fn init_i18n_context_with_options(options: I18nContextOptions)
cookie_name,
cookie_options,
ssr_lang_header_getter,
- parse_locale_from_path,
} = options;
let (lang_cookie, set_lang_cookie) = if ENABLE_COOKIE && enable_cookie {
leptos_use::use_cookie_with_options::(&cookie_name, cookie_options)
@@ -201,11 +195,8 @@ pub fn init_i18n_context_with_options(options: I18nContextOptions)
(lang_cookie.into(), set_lang_cookie)
};
- let initial_locale = fetch_locale::fetch_locale(
- lang_cookie.get_untracked(),
- ssr_lang_header_getter,
- parse_locale_from_path,
- );
+ let initial_locale =
+ fetch_locale::fetch_locale(lang_cookie.get_untracked(), ssr_lang_header_getter);
init_context_inner::(set_lang_cookie, initial_locale)
}
@@ -277,7 +268,7 @@ fn init_subcontext_with_options(
};
let fetch_locale_memo =
- fetch_locale::fetch_locale(None, ssr_lang_header_getter.unwrap_or_default(), None);
+ fetch_locale::fetch_locale(None, ssr_lang_header_getter.unwrap_or_default());
let parent_locale = use_context::>().map(|ctx| ctx.get_locale_untracked());
@@ -456,7 +447,6 @@ fn provide_i18n_context_component_inner(
cookie_name: Option>,
cookie_options: Option>,
ssr_lang_header_getter: Option,
- parse_locale_from_path: Option>,
children: impl FnOnce() -> Chil,
) -> impl IntoView {
#[cfg(all(feature = "dynamic_load", feature = "hydrate", not(feature = "ssr")))]
@@ -464,7 +454,7 @@ fn provide_i18n_context_component_inner(
#[cfg(all(feature = "dynamic_load", feature = "ssr"))]
let reg_ctx = crate::fetch_translations::RegisterCtx::::provide_context();
let options = fill_options!(
- I18nContextOptions::::default().parse_locale_from_path(parse_locale_from_path),
+ I18nContextOptions::::default(),
enable_cookie,
cookie_name,
cookie_options,
@@ -501,7 +491,6 @@ pub fn provide_i18n_context_component(
cookie_name: Option>,
cookie_options: Option>,
ssr_lang_header_getter: Option,
- parse_locale_from_path: Option>,
children: TypedChildren,
) -> impl IntoView {
provide_i18n_context_component_inner(
@@ -511,7 +500,6 @@ pub fn provide_i18n_context_component(
cookie_name,
cookie_options,
ssr_lang_header_getter,
- parse_locale_from_path,
children.into_inner(),
)
}
@@ -523,7 +511,6 @@ pub fn provide_i18n_context_component_island(
set_dir_attr_on_html: Option,
enable_cookie: Option,
cookie_name: Option>,
- parse_locale_from_path: Option>,
children: children::Children,
) -> impl IntoView {
provide_i18n_context_component_inner::(
@@ -533,7 +520,6 @@ pub fn provide_i18n_context_component_island(
cookie_name,
None,
None,
- parse_locale_from_path,
children,
)
}
diff --git a/leptos_i18n/src/fetch_locale.rs b/leptos_i18n/src/fetch_locale.rs
index 6683baa4..fdd203c5 100644
--- a/leptos_i18n/src/fetch_locale.rs
+++ b/leptos_i18n/src/fetch_locale.rs
@@ -1,44 +1,22 @@
-use std::borrow::Cow;
-
use leptos::prelude::*;
-use leptos_router::location::{BrowserUrl, LocationProvider, RequestUrl};
use leptos_use::UseLocalesOptions;
use crate::Locale;
-pub fn fetch_locale(
- current_cookie: Option,
- options: UseLocalesOptions,
- parse_locale_from_path: Option>,
-) -> Memo {
+pub fn fetch_locale(current_cookie: Option, options: UseLocalesOptions) -> Memo {
let accepted_locales = leptos_use::use_locales_with_options(options);
let accepted_locale =
Memo::new(move |_| accepted_locales.with(|accepted| L::find_locale(accepted)));
- let url_locale = get_locale_from_path::(parse_locale_from_path);
-
if cfg!(feature = "ssr") {
- fetch_locale_ssr(current_cookie, accepted_locale, url_locale)
+ fetch_locale_ssr(current_cookie, accepted_locale)
} else if cfg!(feature = "hydrate") {
fetch_locale_hydrate(current_cookie, accepted_locale)
} else {
- fetch_locale_csr(current_cookie, accepted_locale, url_locale)
+ fetch_locale_csr(current_cookie, accepted_locale)
}
}
-fn get_locale_from_path(parse_locale_from_path: Option>) -> Option {
- let base_path = parse_locale_from_path?;
- let url = if cfg!(feature = "ssr") {
- let req = use_context::().expect("no RequestUrl provided");
- req.parse().expect("could not parse RequestUrl")
- } else {
- let location = BrowserUrl::new().expect("could not access browser navigation");
- location.as_url().get_untracked()
- };
-
- crate::routing::get_locale_from_path(url.path(), &base_path)
-}
-
pub fn signal_once_then(
start: T,
then: Memo,
@@ -64,12 +42,8 @@ pub fn signal_maybe_once_then(
}
// ssr fetch
-fn fetch_locale_ssr(
- current_cookie: Option,
- accepted_locale: Memo,
- url_locale: Option,
-) -> Memo {
- signal_maybe_once_then(url_locale.or(current_cookie), accepted_locale)
+fn fetch_locale_ssr(current_cookie: Option, accepted_locale: Memo) -> Memo {
+ signal_maybe_once_then(current_cookie, accepted_locale)
}
// hydrate fetch
@@ -90,10 +64,6 @@ fn fetch_locale_hydrate(current_cookie: Option, accepted_locale: M
}
// csr fetch
-fn fetch_locale_csr(
- current_cookie: Option,
- accepted_locale: Memo,
- url_locale: Option,
-) -> Memo {
- signal_maybe_once_then(url_locale.or(current_cookie), accepted_locale)
+fn fetch_locale_csr(current_cookie: Option, accepted_locale: Memo) -> Memo {
+ signal_maybe_once_then(current_cookie, accepted_locale)
}
diff --git a/leptos_i18n/src/lib.rs b/leptos_i18n/src/lib.rs
index d729c067..67d1752d 100644
--- a/leptos_i18n/src/lib.rs
+++ b/leptos_i18n/src/lib.rs
@@ -131,7 +131,7 @@ mod langid;
mod locale_traits;
mod macro_helpers;
mod macros;
-mod routing;
+// mod routing;
mod scopes;
pub mod display;
@@ -165,10 +165,10 @@ pub mod __private {
pub mod fetch_translations {
pub use crate::fetch_translations::*;
}
+ // pub use crate::fetch_locale::get_locale_from_path_inner;
#[cfg(feature = "plurals")]
pub use crate::formatting::get_plural_rules;
pub use crate::macro_helpers::*;
- pub use crate::routing::{i18n_routing, make_i18n_segment, BaseRoute, I18nSegment};
pub use leptos_i18n_macro as macros_reexport;
}
@@ -208,7 +208,6 @@ pub mod reexports {
pub use icu_locid as locid;
}
pub use leptos;
- pub use leptos_router;
pub use serde;
pub use typed_builder;
pub use wasm_bindgen;
@@ -254,7 +253,7 @@ pub mod reexports {
/// Also note that this macro does NOT take the context as the first argument, instead it takes the name for the generated island.
///
/// If you need to pass variable args, you will have to make yourself an island that take those args.
-#[cfg(feature = "experimental-islands")]
+#[cfg(feature = "islands")]
#[macro_export]
macro_rules! ti {
($island_name: ident, $($tt:tt)*) => {
@@ -316,7 +315,7 @@ macro_rules! ti {
/// }
/// }
/// ```
-#[cfg(feature = "experimental-islands")]
+#[cfg(feature = "islands")]
#[macro_export]
macro_rules! make_i18n_island {
($island_name: ident, $($tt:tt)*) => {
diff --git a/leptos_i18n/src/macros.rs b/leptos_i18n/src/macros.rs
index 11689aac..9c29b64d 100644
--- a/leptos_i18n/src/macros.rs
+++ b/leptos_i18n/src/macros.rs
@@ -944,15 +944,3 @@ macro_rules! tu_plural_ordinal {
$crate::__private::macros_reexport::tu_plural_ordinal!{$($tt)*}
};
}
-
-/// Create a route segment that is possible to define based on a locale.
-///
-/// ```rust, ignore
-///
-/// ```
-#[macro_export]
-macro_rules! i18n_path {
- ($t:ty, $func:expr) => {{
- leptos_i18n::__private::make_i18n_segment::<$t, _>($func)
- }};
-}
diff --git a/leptos_i18n_build/Cargo.toml b/leptos_i18n_build/Cargo.toml
index 1f1ffa53..09517edd 100644
--- a/leptos_i18n_build/Cargo.toml
+++ b/leptos_i18n_build/Cargo.toml
@@ -10,9 +10,9 @@ readme = "../README.md"
[dependencies]
leptos_i18n_parser = { workspace = true }
-icu_datagen = { version = "1.5" }
-icu = { version = "1.5" }
-icu_provider = { version = "1.5" }
+icu_datagen = { workspace = true }
+icu_provider = { workspace = true }
+icu_locid = { workspace = true }
[features]
default = ["json_files"]
diff --git a/leptos_i18n_build/src/lib.rs b/leptos_i18n_build/src/lib.rs
index 77adc2f3..87845cf7 100644
--- a/leptos_i18n_build/src/lib.rs
+++ b/leptos_i18n_build/src/lib.rs
@@ -8,10 +8,10 @@ use std::path::PathBuf;
use std::rc::Rc;
pub use datakey::Options;
-use icu::locid::LanguageIdentifier;
use icu_datagen::baked_exporter::BakedExporter;
use icu_datagen::prelude::DataKey;
use icu_datagen::{DatagenDriver, DatagenProvider};
+use icu_locid::LanguageIdentifier;
use icu_provider::DataError;
use leptos_i18n_parser::parse_locales;
use leptos_i18n_parser::parse_locales::error::Result;
diff --git a/leptos_i18n_macro/Cargo.toml b/leptos_i18n_macro/Cargo.toml
index ad17f44f..a0d94a0f 100644
--- a/leptos_i18n_macro/Cargo.toml
+++ b/leptos_i18n_macro/Cargo.toml
@@ -21,8 +21,9 @@ proc-macro2 = "1"
quote = "1"
syn = "2.0"
toml = "0.8"
-icu = "1.5"
-fixed_decimal = { version = "0.5", features = ["ryu"] }
+icu_locid = { workspace = true }
+icu_locid_transform = { workspace = true, features = ["compiled_data"] }
+fixed_decimal = { workspace = true, features = ["ryu"] }
json5 = { version = "0.4", optional = true }
leptos_i18n_parser = { workspace = true, features = ["quote"] }
@@ -35,7 +36,7 @@ yaml_files = ["dep:serde_yaml", "leptos_i18n_parser/yaml_files"]
json5_files = ["dep:json5", "leptos_i18n_parser/json5_files"]
interpolate_display = []
track_locale_files = []
-experimental-islands = []
+islands = []
show_keys_only = []
dynamic_load = []
hydrate = []
diff --git a/leptos_i18n_macro/src/load_locales/mod.rs b/leptos_i18n_macro/src/load_locales/mod.rs
index 98f11271..10690256 100644
--- a/leptos_i18n_macro/src/load_locales/mod.rs
+++ b/leptos_i18n_macro/src/load_locales/mod.rs
@@ -9,7 +9,7 @@ pub mod ranges;
pub mod tracking;
pub mod warning;
-use icu::locid::LanguageIdentifier;
+use icu_locid::LanguageIdentifier;
use interpolate::Interpolation;
use leptos_i18n_parser::{
parse_locales::{
@@ -117,7 +117,7 @@ fn load_locales_inner(
quote!(td_display),
];
- let providers = if cfg!(feature = "experimental-islands") {
+ let providers = if cfg!(feature = "islands") {
macros_reexport.push(quote!(ti));
quote! {
use leptos::children::Children;
@@ -140,11 +140,6 @@ fn load_locales_inner(
/// Specify a name for the cookie, default to the library default.
#[prop(optional, into)]
cookie_name: Option>,
- /// Try to parse the locale from the URL pathname, expect the basepath. (default to `None`).
- /// If `None` do nothing, if `Some(base_path)` strip the URL from `base_path` then expect to found a path segment that represent a locale.
- /// This is usefull when using the `I18nRoute` with usage of the context outside the router.
- #[prop(optional, into)]
- parse_locale_from_path: Option>,
children: Children
) -> impl IntoView {
l_i18n_crate::context::provide_i18n_context_component_island::<#enum_ident>(
@@ -152,7 +147,6 @@ fn load_locales_inner(
set_dir_attr_on_html,
enable_cookie,
cookie_name,
- parse_locale_from_path,
children
)
}
@@ -206,11 +200,6 @@ fn load_locales_inner(
/// Options for getting the Accept-Language header, see `leptos_use::UseLocalesOptions`.
#[prop(optional)]
ssr_lang_header_getter: Option,
- /// Try to parse the locale from the URL pathname, expect the basepath. (default to `None`).
- /// If `None` do nothing, if `Some(base_path)` strip the URL from `base_path` then expect to found a path segment that represent a locale.
- /// This is usefull when using the `I18nRoute` with usage of the context outside the router.
- #[prop(optional, into)]
- parse_locale_from_path: Option>,
children: TypedChildren
) -> impl IntoView {
l_i18n_crate::context::provide_i18n_context_component::<#enum_ident, Chil>(
@@ -220,7 +209,6 @@ fn load_locales_inner(
cookie_name,
cookie_options,
ssr_lang_header_getter,
- parse_locale_from_path,
children
)
}
@@ -293,41 +281,7 @@ fn load_locales_inner(
#providers
}
- mod routing {
- use super::{l_i18n_crate, #enum_ident};
- use l_i18n_crate::reexports::leptos_router;
- use l_i18n_crate::reexports::leptos;
- use leptos::prelude::IntoView;
- use leptos_router::{SsrMode, MatchNestedRoutes, ChooseView, components::RouteChildren};
-
- #[l_i18n_crate::reexports::leptos::component(transparent)]
- #[allow(non_snake_case)]
- pub fn I18nRoute(
- /// The base path of this application.
- /// If you setup your i18n route such that the path is `/foo/:locale/bar`,
- /// the expected base path is `"foo"`, `"/foo"`, `"foo/"` or `"/foo/"`.
- /// Defaults to `"/"`.
- #[prop(default = "/")]
- base_path: &'static str,
- /// The view that should be shown when this route is matched. This can be any function
- /// that returns a type that implements [`IntoView`] (like `|| view! { "Show this"
})`
- /// or `|| view! { ` } or even, for a component with no props, `MyComponent`).
- /// If you use nested routes you can just set it to `view=Outlet`
- view: View,
- /// The mode that this route prefers during server-side rendering. Defaults to out-of-order streaming.
- #[prop(optional)]
- ssr: SsrMode,
- /// `children` may be empty or include nested routes.
- children: RouteChildren,
- ) -> impl MatchNestedRoutes + 'static + Send + Sync + Clone
- where View: ChooseView + 'static + Send + Sync, Chil: MatchNestedRoutes + 'static + Send + Sync + Clone,
- {
- l_i18n_crate::__private::i18n_routing::<#enum_ident, View, Chil>(base_path, children, ssr, view)
- }
- }
-
pub use providers::{I18nContextProvider, I18nSubContextProvider};
- pub use routing::I18nRoute;
pub use l_i18n_crate::Locale as I18nLocaleTrait;
#macros_reexport
@@ -425,7 +379,7 @@ fn create_locales_enum(
} else {
quote!()
};
- let ld = icu::locid_transform::LocaleDirectionality::new();
+ let ld = icu_locid_transform::LocaleDirectionality::new();
let locids = locales
.iter()
@@ -440,8 +394,8 @@ fn create_locales_enum(
let direction_match_arms = locids.iter().map(|(locale, locid)| {
let dir = match ld.get(locid) {
- Some(icu::locid_transform::Direction::LeftToRight) => quote!(LeftToRight),
- Some(icu::locid_transform::Direction::RightToLeft) => quote!(RightToLeft),
+ Some(icu_locid_transform::Direction::LeftToRight) => quote!(LeftToRight),
+ Some(icu_locid_transform::Direction::RightToLeft) => quote!(RightToLeft),
_ => quote!(Auto),
};
diff --git a/leptos_i18n_parser/Cargo.toml b/leptos_i18n_parser/Cargo.toml
index 853440a2..1c346815 100644
--- a/leptos_i18n_parser/Cargo.toml
+++ b/leptos_i18n_parser/Cargo.toml
@@ -9,12 +9,13 @@ description = "parser for the leptos_i18n crate"
readme = "../README.md"
[dependencies]
-icu = "1.5"
+icu_locid = { workspace = true }
+icu_plurals = { workspace = true, features = ["compiled_data"] }
serde = { version = "1", features = ["rc"] }
serde_json = { version = "1" }
serde_yaml = { version = "0.9" }
toml = "0.8"
-fixed_decimal = { version = "0.5", features = ["ryu"] }
+fixed_decimal = { workspace = true, features = ["ryu"] }
json5 = { version = "0.4" }
quote = { version = "1", optional = true }
syn = { version = "2.0", optional = true }
diff --git a/leptos_i18n_parser/src/parse_locales/error.rs b/leptos_i18n_parser/src/parse_locales/error.rs
index a5c3964b..7a9c7a1a 100644
--- a/leptos_i18n_parser/src/parse_locales/error.rs
+++ b/leptos_i18n_parser/src/parse_locales/error.rs
@@ -1,7 +1,7 @@
+use icu_locid::Error as LocidError;
+use icu_plurals::Error as PluralsError;
use std::{collections::BTreeSet, fmt::Display, num::TryFromIntError, path::PathBuf, rc::Rc};
-use icu::{locid::Error as ParserError, plurals::Error as PluralsError};
-
use super::{locale::SerdeError, ranges::RangeType};
use crate::utils::key::{Key, KeyPath};
@@ -9,7 +9,7 @@ use crate::utils::key::{Key, KeyPath};
pub enum Error {
InvalidLocale {
locale: Rc,
- err: ParserError,
+ err: LocidError,
},
PluralRulesError(PluralsError),
CargoDirEnvNotPresent(std::env::VarError),
diff --git a/leptos_i18n_parser/src/parse_locales/plurals.rs b/leptos_i18n_parser/src/parse_locales/plurals.rs
index 67c14b4d..246130ba 100644
--- a/leptos_i18n_parser/src/parse_locales/plurals.rs
+++ b/leptos_i18n_parser/src/parse_locales/plurals.rs
@@ -4,7 +4,7 @@ use std::{
};
use fixed_decimal::{FixedDecimal, FloatPrecision};
-use icu::plurals::{PluralCategory, PluralOperands, PluralRuleType as IcuRuleType, PluralRules};
+use icu_plurals::{PluralCategory, PluralOperands, PluralRuleType as IcuRuleType, PluralRules};
use super::{
error::{Error, Result},
@@ -82,7 +82,7 @@ impl Plurals {
let locale =
locale
.name
- .parse::()
+ .parse::()
.map_err(|err| Error::InvalidLocale {
locale: locale.name.clone(),
err,
diff --git a/leptos_i18n_router/.gitignore b/leptos_i18n_router/.gitignore
new file mode 100644
index 00000000..4fffb2f8
--- /dev/null
+++ b/leptos_i18n_router/.gitignore
@@ -0,0 +1,2 @@
+/target
+/Cargo.lock
diff --git a/leptos_i18n_router/Cargo.toml b/leptos_i18n_router/Cargo.toml
new file mode 100644
index 00000000..ea7aef0b
--- /dev/null
+++ b/leptos_i18n_router/Cargo.toml
@@ -0,0 +1,25 @@
+[package]
+name = "leptos_i18n_router"
+version = { workspace = true }
+edition = "2021"
+authors = ["Baptiste de Montangon"]
+license = "MIT"
+repository = "https://github.com/Baptistemontan/leptos_i18n"
+description = "Translations integration helper for the Leptos web framework"
+readme = "../README.md"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+leptos_i18n = { workspace = true }
+leptos = { workspace = true }
+leptos_router = { workspace = true }
+
+[features]
+ssr = ["leptos/ssr", "leptos_router/ssr", "leptos_i18n/ssr"]
+
+
+[package.metadata.cargo-all-features]
+denylist = []
+skip_feature_sets = []
+always_include_features = []
diff --git a/leptos_i18n_router/src/components.rs b/leptos_i18n_router/src/components.rs
new file mode 100644
index 00000000..ab3e4973
--- /dev/null
+++ b/leptos_i18n_router/src/components.rs
@@ -0,0 +1,33 @@
+use std::marker::PhantomData;
+
+use leptos::component;
+use leptos_i18n::Locale;
+use leptos_router::{components::RouteChildren, ChooseView, MatchNestedRoutes, SsrMode};
+
+#[component]
+pub fn I18nRoute(
+ /// The base path of this application.
+ /// If you setup your i18n route such that the path is `/foo/:locale/bar`,
+ /// the expected base path is `"foo"`, `"/foo"`, `"foo/"` or `"/foo/"`.
+ /// Defaults to `"/"`.
+ #[prop(default = "/")]
+ base_path: &'static str,
+ /// The view that should be shown when this route is matched. This can be any function
+ /// that returns a type that implements [`IntoView`] (like `|| view! { "Show this"
})`
+ /// or `|| view! { ` } or even, for a component with no props, `MyComponent`).
+ /// If you use nested routes you can just set it to `view=Outlet`
+ view: View,
+ /// The mode that this route prefers during server-side rendering. Defaults to out-of-order streaming
+ #[prop(optional)]
+ ssr: SsrMode,
+ /// `children` may be empty or include nested routes.
+ children: RouteChildren,
+ #[prop(optional)] _marker: PhantomData,
+) -> impl MatchNestedRoutes + 'static + Send + Sync + Clone
+where
+ View: ChooseView + 'static + Send + Sync,
+ Chil: MatchNestedRoutes + 'static + Send + Sync + Clone,
+ L: Locale,
+{
+ crate::routing::i18n_routing::(base_path, children, ssr, view)
+}
diff --git a/leptos_i18n_router/src/lib.rs b/leptos_i18n_router/src/lib.rs
new file mode 100644
index 00000000..c0665d08
--- /dev/null
+++ b/leptos_i18n_router/src/lib.rs
@@ -0,0 +1,26 @@
+#![deny(missing_docs)]
+#![forbid(unsafe_code)]
+#![deny(warnings)]
+//! This crate contain anything related to routing for the `leptos_i18n` crate.
+
+mod components;
+mod routing;
+
+pub use components::I18nRoute;
+
+/// Create a route segment that is possible to define based on a locale.
+///
+/// ```rust, ignore
+///
+/// ```
+#[macro_export]
+macro_rules! i18n_path {
+ ($t:ty, $func:expr) => {{
+ $crate::__private::make_i18n_segment::<$t, _>($func)
+ }};
+}
+
+#[doc(hidden)]
+pub mod __private {
+ pub use crate::routing::make_i18n_segment;
+}
diff --git a/leptos_i18n/src/routing.rs b/leptos_i18n_router/src/routing.rs
similarity index 99%
rename from leptos_i18n/src/routing.rs
rename to leptos_i18n_router/src/routing.rs
index ca2e3f98..1fc2f4a6 100644
--- a/leptos_i18n/src/routing.rs
+++ b/leptos_i18n_router/src/routing.rs
@@ -16,7 +16,7 @@ use leptos_router::{
PathSegment, PossibleRouteMatch, SsrMode, StaticSegment,
};
-use crate::{use_i18n_context, I18nContext, Locale};
+use leptos_i18n::{use_i18n_context, I18nContext, Locale};
// this whole file is a hack into `leptos_router`, it absolutely should'nt be used like that, but eh I'm a professional (or not.)
@@ -81,6 +81,18 @@ fn match_path_segments(segments: &[&str], old_segments: &[PathSegment]) -> Optio
segments_iter.next().is_none().then_some(optionals)
}
+fn get_locale_from_path(path: &str, base_path: &str) -> Option {
+ let base_path = base_path.trim_start_matches('/');
+ let stripped_path = path
+ .trim_start_matches('/')
+ .strip_prefix(base_path)?
+ .trim_start_matches('/');
+ L::get_all()
+ .iter()
+ .copied()
+ .find(|l| stripped_path.starts_with(l.as_str()))
+}
+
fn construct_path_segments<'b, 'p: 'b>(
segments: &[&'p str],
new_segments: &'p [PathSegment],
@@ -313,18 +325,6 @@ fn correct_locale_prefix_effect(
}
}
-pub(crate) fn get_locale_from_path(path: &str, base_path: &str) -> Option {
- let base_path = base_path.trim_start_matches('/');
- let stripped_path = path
- .trim_start_matches('/')
- .strip_prefix(base_path)?
- .trim_start_matches('/');
- L::get_all()
- .iter()
- .copied()
- .find(|l| stripped_path.starts_with(l.as_str()))
-}
-
fn check_history_change(
i18n: I18nContext,
base_path: &'static str,
diff --git a/tests/json5/Cargo.toml b/tests/json5/Cargo.toml
index 96d047ae..278a970e 100644
--- a/tests/json5/Cargo.toml
+++ b/tests/json5/Cargo.toml
@@ -9,7 +9,7 @@ crate-type = ["cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["ssr"] }
+leptos = { version = "0.7.0", features = ["ssr"] }
tests_common = { path = "../common" }
leptos_i18n = { path = "../../leptos_i18n", default-features = false, features = [
"json5_files",
diff --git a/tests/yaml/Cargo.toml b/tests/yaml/Cargo.toml
index bbdaa48e..5fbf6cba 100644
--- a/tests/yaml/Cargo.toml
+++ b/tests/yaml/Cargo.toml
@@ -9,7 +9,7 @@ crate-type = ["cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-leptos = { version = "0.7.0-rc1", features = ["ssr"] }
+leptos = { version = "0.7.0", features = ["ssr"] }
tests_common = { path = "../common" }
leptos_i18n = { path = "../../leptos_i18n", default-features = false, features = [
"yaml_files",