Files
todo-baggins/dioxus-i18n/tests/defects_spec.rs
Matouš Volf 2c2ad7ad21
Some checks failed
hadolint check / hadolint check (pull_request) Successful in 13s
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 7s
GitLeaks check / GitLeaks check (pull_request) Successful in 13s
markdownlint check / markdownlint check (pull_request) Failing after 54s
Prettier check / Prettier check (pull_request) Failing after 51s
htmlhint check / htmlhint check (pull_request) Successful in 1m3s
checkov check / checkov check (pull_request) Failing after 2m26s
ShellCheck check / ShellCheck check (pull_request) Successful in 1m14s
Stylelint check / Stylelint check (pull_request) Successful in 1m27s
Rust check / Rust check (pull_request) Failing after 11m40s
yamllint check / yamllint check (pull_request) Successful in 13m36s
fix: automatically reconnect after losing a WebSocket connection
2026-01-23 11:04:10 +01:00

45 lines
1.3 KiB
Rust

mod common;
use common::*;
use dioxus_i18n::{
prelude::{use_init_i18n, I18n, I18nConfig},
t,
};
use unic_langid::{langid, LanguageIdentifier};
#[test]
fn issue_15_recent_change_to_t_macro_unnecessarily_breaks_v0_3_code_test_attr() {
test_hook(i18n_from_static, |_, proxy| {
let panic = std::panic::catch_unwind(|| {
let name = "World";
t!(&format!("hello"), name: name)
});
proxy.assert(panic.is_ok(), true, "translate_from_static_source");
proxy.assert(
panic.ok().unwrap(),
"Hello, \u{2068}World\u{2069}!".to_string(),
"translate_from_static_source",
);
});
}
#[test]
fn issue_15_recent_change_to_t_macro_unnecessarily_breaks_v0_3_code_test_no_attr() {
test_hook(i18n_from_static, |_, proxy| {
let panic = std::panic::catch_unwind(|| t!(&format!("simple")));
proxy.assert(panic.is_ok(), true, "translate_from_static_source");
proxy.assert(
panic.ok().unwrap(),
"Hello, Zaphod!".to_string(),
"translate_from_static_source",
);
});
}
const EN: LanguageIdentifier = langid!("en");
fn i18n_from_static() -> I18n {
let config = I18nConfig::new(EN).with_locale((EN, include_str!("./data/i18n/en.ftl")));
use_init_i18n(|| config)
}