Skip to content

Commit fbc8d2a

Browse files
committed
refactor(panel): migrate to local i18n module
1 parent 53b94b1 commit fbc8d2a

13 files changed

Lines changed: 49 additions & 22 deletions

File tree

rustmail_panel/src/components/api_keys.rs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::components::forbidden::Forbidden403;
2+
use crate::i18n::yew::use_translation;
23
use crate::types::PanelPermission;
34
use gloo_net::http::Request;
4-
use i18nrs::yew::use_translation;
55
use serde::{Deserialize, Serialize};
66
use wasm_bindgen_futures::spawn_local;
77
use web_sys::HtmlInputElement;
@@ -131,11 +131,19 @@ pub fn api_keys_page() -> Html {
131131
error.set(Some(i18n_clone.t("panel.apikeys.error_parse")));
132132
}
133133
} else {
134-
error.set(Some(format!("{}: {}", i18n_clone.t("panel.apikeys.error_load"), resp.status())));
134+
error.set(Some(format!(
135+
"{}: {}",
136+
i18n_clone.t("panel.apikeys.error_load"),
137+
resp.status()
138+
)));
135139
}
136140
}
137141
Err(e) => {
138-
error.set(Some(format!("{}: {:?}", i18n_clone.t("panel.apikeys.error_network"), e)));
142+
error.set(Some(format!(
143+
"{}: {:?}",
144+
i18n_clone.t("panel.apikeys.error_network"),
145+
e
146+
)));
139147
}
140148
}
141149
loading.set(false);
@@ -384,12 +392,16 @@ fn create_api_key_modal(props: &CreateApiKeyModalProps) -> Html {
384392
.unwrap_or_default();
385393

386394
if name.trim().is_empty() {
387-
error.set(Some(i18n_clone.t("panel.apikeys.modal.error_name_required")));
395+
error.set(Some(
396+
i18n_clone.t("panel.apikeys.modal.error_name_required"),
397+
));
388398
return;
389399
}
390400

391401
if selected_permissions.is_empty() {
392-
error.set(Some(i18n_clone.t("panel.apikeys.modal.error_permission_required")));
402+
error.set(Some(
403+
i18n_clone.t("panel.apikeys.modal.error_permission_required"),
404+
));
393405
return;
394406
}
395407

@@ -418,14 +430,24 @@ fn create_api_key_modal(props: &CreateApiKeyModalProps) -> Html {
418430
on_created.emit(response.api_key);
419431
error.set(None);
420432
} else {
421-
error.set(Some(i18n_clone2.t("panel.apikeys.modal.error_parse_response")));
433+
error.set(Some(
434+
i18n_clone2.t("panel.apikeys.modal.error_parse_response"),
435+
));
422436
}
423437
} else {
424-
error.set(Some(format!("{}: {}", i18n_clone2.t("panel.apikeys.modal.error_create"), resp.status())));
438+
error.set(Some(format!(
439+
"{}: {}",
440+
i18n_clone2.t("panel.apikeys.modal.error_create"),
441+
resp.status()
442+
)));
425443
}
426444
}
427445
Err(e) => {
428-
error.set(Some(format!("{}: {:?}", i18n_clone2.t("panel.apikeys.error_network"), e)));
446+
error.set(Some(format!(
447+
"{}: {:?}",
448+
i18n_clone2.t("panel.apikeys.error_network"),
449+
e
450+
)));
429451
}
430452
}
431453
creating.set(false);

rustmail_panel/src/components/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::components::forbidden::Forbidden403;
2+
use crate::i18n::yew::use_translation;
23
use crate::types::PanelPermission;
34
use gloo_net::http::Request;
4-
use i18nrs::yew::use_translation;
55
use wasm_bindgen_futures::spawn_local;
66
use yew::prelude::*;
77

rustmail_panel/src/components/forbidden.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::i18n::yew::use_translation;
12
use crate::pages::panel::PanelRoute;
2-
use i18nrs::yew::use_translation;
33
use yew::prelude::*;
44
use yew_router::prelude::*;
55

rustmail_panel/src/components/home.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use i18nrs::yew::use_translation;
1+
use crate::i18n::yew::use_translation;
22
use yew::prelude::*;
33

44
#[function_component(Home)]

rustmail_panel/src/components/language_switcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use i18nrs::yew::use_translation;
1+
use crate::i18n::yew::use_translation;
22
use yew::prelude::*;
33

44
#[derive(Properties, PartialEq, Clone)]

rustmail_panel/src/components/logout_button.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::i18n::yew::use_translation;
12
use yew::{Html, function_component, html};
23

34
#[function_component(LogoutButton)]
45
pub fn logout_button() -> Html {
5-
let (i18n, _set_language) = i18nrs::yew::use_translation();
6+
let (i18n, _set_language) = use_translation();
67

78
html! {
89
<a href="/api/auth/logout"

rustmail_panel/src/components/navbar.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::components::language_switcher::LanguageSwitcher;
2+
use crate::i18n::yew::use_translation;
23
use crate::pages::panel::PanelRoute;
34
use crate::types::PanelPermission;
45
use yew::{Callback, Html, Properties, classes, function_component, html, use_state};
@@ -12,7 +13,7 @@ pub struct RustmailNavbarProps {
1213

1314
#[function_component(RustmailNavbar)]
1415
pub fn rustmail_navbar(props: &RustmailNavbarProps) -> Html {
15-
let (i18n, _set_language) = i18nrs::yew::use_translation();
16+
let (i18n, _set_language) = use_translation();
1617

1718
let mobile_menu_open = use_state(|| false);
1819
let profile_menu_open = use_state(|| false);
@@ -41,7 +42,9 @@ pub fn rustmail_navbar(props: &RustmailNavbarProps) -> Html {
4142
let has_manage_config = props.permissions.contains(&PanelPermission::ManageConfig);
4243
let has_manage_apikeys = props.permissions.contains(&PanelPermission::ManageApiKeys);
4344
let has_manage_tickets = props.permissions.contains(&PanelPermission::ManageTickets);
44-
let has_manage_permissions = props.permissions.contains(&PanelPermission::ManagePermissions);
45+
let has_manage_permissions = props
46+
.permissions
47+
.contains(&PanelPermission::ManagePermissions);
4548

4649
html! {
4750
<nav class="fixed top-0 left-0 w-full z-50 bg-gradient-to-r from-slate-900 to-black border-b border-slate-800">

rustmail_panel/src/components/ticket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::components::forbidden::Forbidden403;
2+
use crate::i18n::yew::use_translation;
23
use crate::types::PanelPermission;
34
use crate::utils::markdown::markdown_to_html_safe;
45
use gloo_net::http::Request;
5-
use i18nrs::yew::use_translation;
66
use js_sys::Date;
77
use serde::Deserialize;
88
use wasm_bindgen::JsValue;

rustmail_panel/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
mod components;
2+
mod i18n;
23
mod pages;
34
mod router;
45
mod types;
56
mod utils;
67

78
use crate::router::{Route, switch};
8-
use i18nrs::StorageType;
9-
use i18nrs::yew::I18nProvider;
9+
use i18n::config::StorageType;
10+
use i18n::yew::I18nProvider;
1011
use std::collections::HashMap;
1112
use yew::prelude::*;
1213
use yew_router::prelude::*;

rustmail_panel/src/pages/administration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::components::forbidden::Forbidden403;
22
use crate::components::navbar::RustmailNavbar;
3+
use crate::i18n::yew::use_translation;
34
use crate::types::PanelPermission;
45
use gloo_net::http::Request;
5-
use i18nrs::yew::use_translation;
66
use serde::{Deserialize, Serialize};
77
use wasm_bindgen_futures::spawn_local;
88
use yew::prelude::*;

0 commit comments

Comments
 (0)