feat(cmd): service return message i18 language support

This commit is contained in:
Tunglies
2025-03-28 11:51:52 +08:00
parent f6c0f144a6
commit 492a5a6de7
3 changed files with 12 additions and 5 deletions

View File

@@ -1,17 +1,20 @@
use super::CmdResult;
use crate::core::{service, CoreManager};
use crate::{
core::{service, CoreManager},
utils::i18n::t,
};
async fn execute_service_operation(
service_op: impl std::future::Future<Output = Result<(), impl ToString + std::fmt::Debug>>,
op_type: &str,
) -> CmdResult {
if service_op.await.is_err() {
let emsg = format!("{} {} failed", op_type, "service");
return Err(emsg);
let emsg = format!("{} {} failed", op_type, "Service");
return Err(t(emsg.as_str()));
}
if CoreManager::global().restart_core().await.is_err() {
let emsg = format!("{} {} failed", op_type, "core");
return Err(emsg);
let emsg = format!("{} {} failed", "Restart", "Core");
return Err(t(emsg.as_str()));
}
Ok(())
}