fix: automatically reconnect after losing a WebSocket connection
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 7s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 3s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 6s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 9s
GitLeaks check / GitLeaks check (pull_request) Successful in 11s
hadolint check / hadolint check (pull_request) Successful in 14s
Prettier check / Prettier check (pull_request) Failing after 35s
markdownlint check / markdownlint check (pull_request) Failing after 40s
htmlhint check / htmlhint check (pull_request) Successful in 44s
checkov check / checkov check (pull_request) Failing after 1m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 23s
Stylelint check / Stylelint check (pull_request) Successful in 24s
yamllint check / yamllint check (pull_request) Successful in 22s
Rust check / Rust check (pull_request) Failing after 57m45s
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 7s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 3s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 6s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 9s
GitLeaks check / GitLeaks check (pull_request) Successful in 11s
hadolint check / hadolint check (pull_request) Successful in 14s
Prettier check / Prettier check (pull_request) Failing after 35s
markdownlint check / markdownlint check (pull_request) Failing after 40s
htmlhint check / htmlhint check (pull_request) Successful in 44s
checkov check / checkov check (pull_request) Failing after 1m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 23s
Stylelint check / Stylelint check (pull_request) Successful in 24s
yamllint check / yamllint check (pull_request) Successful in 22s
Rust check / Rust check (pull_request) Failing after 57m45s
This commit is contained in:
57
dioxus-i18n/examples/config-static-includestr.rs
Normal file
57
dioxus-i18n/examples/config-static-includestr.rs
Normal file
@@ -0,0 +1,57 @@
|
||||
//! This example demonstrates how to use pathbuf derived I18nConfig.
|
||||
//! This is useful for WASM targets; the paths to the translation files must be known at compile time.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_i18n::{prelude::*, t};
|
||||
use unic_langid::langid;
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
fn Body() -> Element {
|
||||
let mut i18n = i18n();
|
||||
|
||||
let change_to_english = move |_| i18n.set_language(langid!("en-US"));
|
||||
let change_to_spanish = move |_| i18n.set_language(langid!("es-ES"));
|
||||
|
||||
rsx!(
|
||||
button {
|
||||
onclick: change_to_english,
|
||||
label {
|
||||
"English"
|
||||
}
|
||||
}
|
||||
button {
|
||||
onclick: change_to_spanish,
|
||||
label {
|
||||
"Spanish"
|
||||
}
|
||||
}
|
||||
p { { t!("hello_world") } }
|
||||
p { { t!("hello", name: "Dioxus") } }
|
||||
)
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
use_init_i18n(|| {
|
||||
// This initialisation allows individual translation files to be selected.
|
||||
// The locales can be added with an implicitly derived locale (see config-dynamic-pathbuf.rs for a comparison)
|
||||
// or using an explicit Locale::new_static call.
|
||||
//
|
||||
// The two examples are functionally equivalent.
|
||||
//
|
||||
// It IS supported in WASM targets.
|
||||
I18nConfig::new(langid!("en-US"))
|
||||
// Implicit...
|
||||
.with_locale((langid!("es-ES"), include_str!("./data/i18n/es-ES.ftl")))
|
||||
// Explicit...
|
||||
.with_locale(Locale::new_static(
|
||||
langid!("en-US"),
|
||||
include_str!("./data/i18n/en-US.ftl"),
|
||||
))
|
||||
});
|
||||
|
||||
rsx!(Body {})
|
||||
}
|
||||
Reference in New Issue
Block a user