mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 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
@@ -835,10 +835,16 @@ fn run_pe(
|
||||
output.detected_kind = Some(kind_name(image.kind).to_owned());
|
||||
output.bytes = Some(image.bytes.len() as u64);
|
||||
output.sha256 = Some(sha256_hex(&image.bytes));
|
||||
let issues: Vec<String> = image
|
||||
.integrity
|
||||
.issues
|
||||
.iter()
|
||||
.map(|issue| issue.text().to_owned())
|
||||
.collect();
|
||||
output.integrity = Some(IntegrityInfo {
|
||||
ok: image.integrity.ok(),
|
||||
fatal: image.integrity.has_fatal(),
|
||||
issues: image.integrity.issues.clone(),
|
||||
issues: issues.clone(),
|
||||
});
|
||||
if expect_failure {
|
||||
output.fail("expected failure, but the input unpacked");
|
||||
@@ -847,13 +853,7 @@ fn run_pe(
|
||||
"expected failure, but the input unpacked",
|
||||
);
|
||||
} else {
|
||||
compare_output(
|
||||
&mut output,
|
||||
&image.bytes,
|
||||
expected,
|
||||
allow_suspect,
|
||||
&image.integrity.issues,
|
||||
);
|
||||
compare_output(&mut output, &image.bytes, expected, allow_suspect, &issues);
|
||||
finish_case(report, &mut output, "unpacked");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user