mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-25 02:52:47 +08:00
feat: localize console output and add a run observer
Engine errors, integrity findings, and driver outcomes carry message codes from senbei-i18n, with their English unchanged, so reports, logs, and --json stay byte-identical. Verbose pipeline steps go through a progress sink instead of println!, and an error chain is translated through its first coded cause. The CLI takes the display language from SENBEI_LANG, or else from the system's preferred UI language, and translates console text: usage errors, help, per-file lines, the run summary, and the summary lines of the inspect report. Structural research evidence and saved logs stay English. When a translation leaves out context the English chain has, the English follows on a muted line. A front end can attach a RunObserver and a CancelToken to the Collector to follow a run input by input, receive verbose steps as events, and stop before the next input. A cancelled report says so. The CLI never cancels, so its JSON is unchanged.
This commit is contained in:
1 parent
9481b0ccf9
commit
4853fe22c0
39 files changed
+2016
-684
No files matched your search
Generated
+9
@@ -453,6 +453,7 @@ dependencies = [
|
||||
"memmap2",
|
||||
"senbei-crypto",
|
||||
"senbei-elf",
|
||||
"senbei-i18n",
|
||||
"senbei-pe",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -461,6 +462,13 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "senbei-i18n"
|
||||
version = "1.3.4"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "senbei-io"
|
||||
version = "1.3.4"
|
||||
@@ -473,6 +481,7 @@ dependencies = [
|
||||
"senbei-crypto",
|
||||
"senbei-elf",
|
||||
"senbei-engine",
|
||||
"senbei-i18n",
|
||||
"senbei-metadata",
|
||||
"senbei-pe",
|
||||
"serde",
|
||||
|
||||
@@ -157,7 +157,11 @@ fn kind_str(kind: senbei_engine::Kind) -> &'static str {
|
||||
/// Copy an integrity report's findings into the parallel arrays the JS layer
|
||||
/// reads (`issues[i]` and `severities[i]` describe the same defect).
|
||||
fn split_findings(report: &IntegrityReport) -> (Vec<String>, Vec<String>, bool) {
|
||||
let issues = report.issues.clone();
|
||||
let issues: Vec<String> = report
|
||||
.issues
|
||||
.iter()
|
||||
.map(|issue| issue.to_string())
|
||||
.collect();
|
||||
let mut severities = Vec::with_capacity(report.findings.len());
|
||||
let mut fatal = false;
|
||||
for finding in &report.findings {
|
||||
@@ -325,7 +329,7 @@ fn metadata_outcome(data: &[u8]) -> (Option<u32>, ProtectionProfile, MetadataTra
|
||||
layout: route,
|
||||
outcome: AttemptOutcome::Failed,
|
||||
warnings: Vec::new(),
|
||||
errors: vec![error.to_string()],
|
||||
errors: vec![error.to_string().into()],
|
||||
}];
|
||||
profile.recovery = RecoveryStatus::Failed;
|
||||
profile.push_error(error.to_string());
|
||||
|
||||
Reference in new issue
Block a user