feat(bat): 补全工作流命令与人工校对状态
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

Refs #43
This commit is contained in:
2026-08-19 21:33:33 +08:00
parent 550ee7fd9a
commit 72c1a879a3
21 changed files with 797 additions and 41 deletions
+133 -8
View File
@@ -26,9 +26,11 @@ use bat_infrastructure::{
SqliteResourceRepository, SqliteTranslationTaskRepository, TranslationTaskStatus,
UnityFsFieldPatchParams, UnityFsPatchReport, UnityFsStringFieldPatchParams,
UnityFsTextAssetPatchParams, CROWDIN_TEXTUNIT_QUEUE_FILE, LOCALIZED_CURRENT_LINK,
LOCALIZED_PATCH_MANIFEST_FILE, LOCALIZED_VERSIONS_DIR, LOCALIZED_VERSION_STATE_FILE,
MAX_DOWNLOAD_CONCURRENCY, MIN_DOWNLOAD_CONCURRENCY, OFFICIAL_PARSE_CACHE_FILE,
OFFICIAL_TEXTUNIT_INDEX_FILE, OFFICIAL_TEXTUNIT_TASK_QUEUE_FILE, PRIVATE_FILE_MODE,
LOCALIZED_PATCH_MANIFEST_FILE, LOCALIZED_TRANSLATION_STATUS_MANUAL_PROOFREADING,
LOCALIZED_TRANSLATION_STATUS_MANUAL_PROOFREADING_LABEL, LOCALIZED_VERSIONS_DIR,
LOCALIZED_VERSION_STATE_FILE, MAX_DOWNLOAD_CONCURRENCY, MIN_DOWNLOAD_CONCURRENCY,
OFFICIAL_PARSE_CACHE_FILE, OFFICIAL_TEXTUNIT_INDEX_FILE, OFFICIAL_TEXTUNIT_TASK_QUEUE_FILE,
PRIVATE_FILE_MODE,
};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
@@ -81,8 +83,8 @@ use translation_query::{
};
use workflow_commands::{
run_parse_clear_cache, run_parse_once, run_publish_localized, run_repack, run_translate_once,
run_translation_get, run_translation_set, run_translation_task_update, run_translation_unset,
run_translation_validate,
run_translation_get, run_translation_proofread, run_translation_set,
run_translation_task_update, run_translation_unset, run_translation_validate,
};
const EXIT_ERROR: i32 = 1;
@@ -223,6 +225,10 @@ fn run() -> anyhow::Result<i32> {
run_translation_task_update(&options)?;
Ok(0)
}
CliCommand::TranslationProofread => {
run_translation_proofread(&options)?;
Ok(0)
}
CliCommand::Repack => {
run_repack(&options)?;
Ok(0)
@@ -540,6 +546,7 @@ enum CliCommand {
TranslationGet,
TranslationUnset,
TranslationTaskUpdate,
TranslationProofread,
Repack,
PublishLocalized,
ScheduleList,
@@ -1017,6 +1024,7 @@ const RPC_METHOD_PARSE_ERRORS: &str = "parse.errors";
const RPC_METHOD_TRANSLATION_TASKS: &str = "translation.tasks";
const RPC_METHOD_TRANSLATION_HANDOFF: &str = "translation.handoff";
const RPC_METHOD_TRANSLATION_TASK_UPDATE: &str = "translation.task.update";
const RPC_METHOD_TRANSLATION_PROOFREAD: &str = "translation.proofread";
const RPC_METHOD_LOCALIZED_STATUS: &str = "localized.status";
const RPC_METHOD_CATALOG_STATUS: &str = "catalog.status";
const RPC_METHOD_CATALOG_VERSIONS: &str = "catalog.versions";
@@ -2013,6 +2021,12 @@ fn dispatch_rpc_method(
"translation.task.update",
update_translation_task_status_report(state_dir, request.params.as_ref()),
),
RPC_METHOD_TRANSLATION_PROOFREAD => rpc_envelope_from_result(
request_id,
"translation.proofread",
mark_localized_manual_proofreading_report(state_dir, &tasks.base_config)
.and_then(|report| serde_json::to_value(report).map_err(anyhow::Error::from)),
),
RPC_METHOD_LOCALIZED_STATUS => rpc_envelope_from_result(
request_id,
"localized.status",
@@ -2836,6 +2850,22 @@ fn build_parse_errors_report(
}))
}
fn mark_localized_manual_proofreading_report(
state_dir: &Path,
base_config: &OfficialUpdateConfig,
) -> anyhow::Result<bat_infrastructure::LocalizedTranslationWorkflowReport> {
let (_, version_state) = read_daemon_resource_state(state_dir)?;
let official_release_id = version_state
.as_ref()
.and_then(|state| state.current_completed_version.as_ref())
.map(|record| record.id.as_str())
.ok_or_else(|| anyhow::anyhow!("没有可标记人工校对状态的当前官方 release"))?;
bat_infrastructure::mark_localized_manual_proofreading(
&base_config.localized_output_root,
official_release_id,
)
}
/// `localized.status`:当前官方版本对应的汉化 release 状态。
fn build_localized_status_report(
state_dir: &Path,
@@ -2854,6 +2884,12 @@ fn build_localized_status_report(
let current_path = localized_root.join(LOCALIZED_CURRENT_LINK);
let state = read_localized_version_state(&localized_root)?;
let mut localized_release_status = "not_localized";
let mut translation_workflow_status = None;
let mut translation_workflow_status_code = None;
let mut translation_workflow_status_phase = None;
let mut translation_workflow_status_terminal = None;
let mut translation_workflow_status_retryable = None;
let mut translation_workflow_label = None;
let mut published_version_path = None;
let mut matches_current_official_release = false;
let mut current_points_to_published_version = false;
@@ -2873,6 +2909,23 @@ fn build_localized_status_report(
matches_current_official_release = official_version_id
.as_deref()
.is_some_and(|id| localized_state.official_release_id == id);
if matches_current_official_release
&& localized_state.translation_workflow_status()
== Some(LOCALIZED_TRANSLATION_STATUS_MANUAL_PROOFREADING)
{
let (status, code, phase, terminal, retryable) =
flow_status_fields(ReleaseFlowStatusCode::TranslationManualProofreading);
translation_workflow_status = Some(status);
translation_workflow_status_code = Some(code);
translation_workflow_status_phase = Some(phase);
translation_workflow_status_terminal = Some(terminal);
translation_workflow_status_retryable = Some(retryable);
translation_workflow_label = Some(
localized_state
.translation_workflow_label()
.unwrap_or(LOCALIZED_TRANSLATION_STATUS_MANUAL_PROOFREADING_LABEL),
);
}
if official_version_id.is_some() && !matches_current_official_release {
flow_status_code = ReleaseFlowStatusCode::LocalizedStale;
}
@@ -2915,6 +2968,12 @@ fn build_localized_status_report(
"status_terminal": status_terminal,
"status_retryable": status_retryable,
"localized_release_status": localized_release_status,
"translation_workflow_status": translation_workflow_status,
"translation_workflow_status_code": translation_workflow_status_code,
"translation_workflow_status_phase": translation_workflow_status_phase,
"translation_workflow_status_terminal": translation_workflow_status_terminal,
"translation_workflow_status_retryable": translation_workflow_status_retryable,
"translation_workflow_label": translation_workflow_label,
"official_current_version_id": official_version_id,
"localized_output_root": localized_root,
"state_path": state_path,
@@ -4144,6 +4203,24 @@ impl HumanReport for LocalizedPatchReport {
}
}
impl HumanReport for bat_infrastructure::LocalizedTranslationWorkflowReport {
fn print_human(&self) -> anyhow::Result<()> {
print_title("汉化工作流状态");
print_field("命令", self.command);
print_field("状态", self.status);
print_field("官方 release", &self.official_release_id);
print_optional_field("汉化 release", self.current_release_id.as_deref());
print_field("汉化发布状态", &self.localized_release_status);
print_field("工作流状态", &self.translation_workflow_status);
print_field("工作流状态码", self.translation_workflow_status_code);
print_field("工作流标签", self.translation_workflow_label);
print_field("允许发布", format_bool(self.publish_allowed));
print_path_field("汉化输出目录", &self.localized_output_root);
print_path_field("状态文件", &self.state_path);
Ok(())
}
}
fn print_human_json_value(value: &serde_json::Value) -> anyhow::Result<()> {
if value.get("running").is_some() && value.get("state_dir").is_some() {
print_title("后台状态");
@@ -7329,6 +7406,39 @@ fn parse_args_with_env(
options.progress = false;
options.banner = false;
}
CliCommand::TranslationProofread => {
if options.watch || options.daemon || options.daemon_child {
return Err(anyhow::anyhow!("i18n proofread 只支持单次执行或 RPC 调用"));
}
if options.config.force
|| options.config.dry_run
|| options.run_count.is_some()
|| options.sync_option_explicit
|| options.proxy_option_explicit
|| tools_are_non_default(&options.config, &options.env_baseline_config)
{
return Err(anyhow::anyhow!(
"i18n proofread 只接受 --output、--localized-output、--resource-root、--state-dir 和 --json/--human"
));
}
if options.translation_file.is_some()
|| options.translation_id.is_some()
|| options.translation_text.is_some()
|| options.translation_text_file.is_some()
|| options.translation_failure_reason.is_some()
|| options.translation_provider_run_id.is_some()
|| options.localized_release_id.is_some()
|| options.repack_spec.is_some()
|| options.query_option_explicit
|| options.schedule_option_explicit
{
return Err(anyhow::anyhow!(
"i18n proofread 不接受工作台、任务、查询、调度或发布 release 参数"
));
}
options.progress = false;
options.banner = false;
}
CliCommand::ScheduleList
| CliCommand::ScheduleAdd
| CliCommand::ScheduleUpdate
@@ -7530,6 +7640,7 @@ fn parse_translation_command(
"unset" | "clear" => CliCommand::TranslationUnset,
"validate" => CliCommand::TranslationValidate,
"publish" => CliCommand::PublishLocalized,
"proofread" => CliCommand::TranslationProofread,
"tasks" => CliCommand::TranslationTasks,
"handoff" => CliCommand::TranslationHandoff,
"status" => CliCommand::LocalizedStatus,
@@ -7688,12 +7799,19 @@ fn print_usage(binary: &str) {
eprintln!(" parse run Parse current official release");
eprintln!(" parse clear-cache Clear regenerable parse and translation queue files");
eprintln!(" parse repack Repack a UnityFS bundle from a JSON spec");
eprintln!(" parse schedule Manage parse schedules");
eprintln!(" i18n run Refresh offline translation work");
eprintln!(" i18n export Export an editable translation workbench");
eprintln!(" i18n set Update one translation workbench entry");
eprintln!(" i18n get Show one translation workbench entry");
eprintln!(" i18n unset Clear one translated workbench entry");
eprintln!(" i18n validate Validate workbench against the current official release");
eprintln!(" i18n proofread Mark localized workflow as manual proofreading");
eprintln!(
" i18n tasks / i18n task list / i18n task status Query current offline TextUnit translation task status"
);
eprintln!(" i18n handoff Query current translation handoff");
eprintln!(" i18n status Show localized release status for current official release");
eprintln!(" i18n task update Update one provider worker task status");
eprintln!(" i18n publish Publish a localized release");
eprintln!(" i18n schedule Manage translation schedules");
@@ -7727,6 +7845,7 @@ fn print_usage(binary: &str) {
eprintln!(" {binary} --auto-discover --daemon");
eprintln!(" {binary} res pull --auto-discover --run-count 3 --interval 1h");
eprintln!(" {binary} parse run --force --resource-root /tmp/bat-release");
eprintln!(" {binary} parse schedule list --state-dir /tmp/bat-schedule");
eprintln!(" {binary} i18n export --translation-file /tmp/bat-workbench.json");
eprintln!(
" {binary} i18n get --translation-file /tmp/bat-workbench.json --translation-id unit-1"
@@ -7734,6 +7853,10 @@ fn print_usage(binary: &str) {
eprintln!(
" {binary} i18n unset --translation-file /tmp/bat-workbench.json --translation-id unit-1"
);
eprintln!(" {binary} i18n proofread --json");
eprintln!(" {binary} i18n tasks --json");
eprintln!(" {binary} i18n handoff --json");
eprintln!(" {binary} i18n status --json");
eprintln!(" {binary} i18n publish --translation-file /tmp/bat-workbench.json --force");
eprintln!(" {binary} status");
eprintln!(" {binary} refresh --force --json");
@@ -7779,7 +7902,7 @@ fn print_usage(binary: &str) {
eprintln!(" --run-count <N> Run pull/parse/translate/publish N times");
eprintln!(" --once Explicitly select one run");
eprintln!(" --resource-root <DIR> Use an explicit published official release root");
eprintln!(" --translation-file <PATH> Translation workbench JSON file");
eprintln!(" --translation-file <PATH> / --workbench <PATH> Translation workbench JSON file");
eprintln!(" --translation-id <ID> TextUnit ID for i18n set");
eprintln!(" --translated-text <TEXT> Inline translation for i18n set");
eprintln!(" --translated-file <PATH> UTF-8 translation file for i18n set");
@@ -7847,8 +7970,10 @@ fn print_usage(binary: &str) {
eprintln!(" --quiet-up-to-date Suppress clean up-to-date reports");
eprintln!(" --no-quiet-up-to-date Always print reports");
eprintln!(" --tail <N> Log lines for logs command (default: 200)");
eprintln!(" --schedule-id <ID> Schedule identifier");
eprintln!(" --schedule-action <ACTION> Schedule action (pull/run/repack/publish)");
eprintln!(" --schedule-id <ID> / --id <ID> Schedule identifier");
eprintln!(
" --schedule-action <ACTION> / --action <ACTION> Schedule action (pull/run/repack/publish)"
);
eprintln!(" --schedule-at-unix <SECONDS> First execution time");
eprintln!(" --schedule-delay <DURATION> Delay first execution from now");
eprintln!(" --schedule-every <DURATION> Period between executions");
+302 -2
View File
@@ -254,6 +254,34 @@ fn grouped_workflow_commands_use_short_top_level_aliases() {
.unwrap();
assert_eq!(options.command, CliCommand::TranslationUnset);
let options = parse(&[
"bat",
"i18n",
"proofread",
"--output",
"/tmp/bat-resources",
"--localized-output",
"/tmp/bat-localized",
])
.unwrap();
assert_eq!(options.command, CliCommand::TranslationProofread);
let options = parse(&[
"bat",
"i18n",
"proofread",
"--resource-root",
"/tmp/bat-resources/versions/v-current",
"--localized-output",
"/tmp/bat-localized",
])
.unwrap();
assert_eq!(options.command, CliCommand::TranslationProofread);
assert_eq!(
options.resource_root,
Some(PathBuf::from("/tmp/bat-resources/versions/v-current"))
);
let options = parse(&[
"bat",
"i18n",
@@ -286,6 +314,25 @@ fn grouped_workflow_commands_use_short_top_level_aliases() {
Some("provider-run-1")
);
assert!(parse(&["bat", "i18n", "task", "update", "--task-id", "task-only",]).is_err());
assert!(parse(&[
"bat",
"i18n",
"workbench",
"proofread",
"--translation-file",
"/tmp/workbench.json",
"--translation-id",
"unit-1",
])
.is_err());
assert!(parse(&[
"bat",
"i18n",
"proofread",
"--translation-file",
"/tmp/workbench.json",
])
.is_err());
assert!(parse(&[
"bat",
"i18n",
@@ -355,7 +402,7 @@ fn translation_workbench_commands_read_update_and_clear_entries() {
"bat",
"i18n",
"set",
"--translation-file",
"--workbench",
&path_arg,
"--translation-id",
"unit-1",
@@ -424,6 +471,49 @@ fn grouped_command_long_aliases_and_schedule_options_are_accepted() {
assert_eq!(options.schedule_count, Some(4));
assert_eq!(options.schedule_args, vec!["--auto-discover"]);
let options = parse(&[
"bat",
"res",
"schedule",
"add",
"--state-dir",
"/tmp/bat-schedule",
"--id",
"alias-pull",
"--action",
"pull",
"--schedule-delay",
"1s",
])
.unwrap();
assert_eq!(options.command, CliCommand::ScheduleAdd);
assert_eq!(options.schedule_id.as_deref(), Some("alias-pull"));
assert_eq!(options.schedule_action.as_deref(), Some("pull"));
let options = parse(&[
"bat",
"parse",
"schedule",
"list",
"--state-dir",
"/tmp/bat-parse-schedule",
])
.unwrap();
assert_eq!(options.command, CliCommand::ScheduleList);
assert_eq!(options.schedule_group.as_deref(), Some("parse"));
let options = parse(&[
"bat",
"resource",
"schedule",
"list",
"--state-dir",
"/tmp/bat-resource-schedule",
])
.unwrap();
assert_eq!(options.command, CliCommand::ScheduleList);
assert_eq!(options.schedule_group.as_deref(), Some("res"));
let options = parse(&[
"bat",
"translate",
@@ -438,6 +528,36 @@ fn grouped_command_long_aliases_and_schedule_options_are_accepted() {
assert_eq!(options.schedule_group.as_deref(), Some("i18n"));
assert!(options.config.force);
assert_eq!(options.schedule_max_runs, Some(2));
let options = parse(&["bat", "translation", "tasks", "--json"]).unwrap();
assert_eq!(options.command, CliCommand::TranslationTasks);
let options = parse(&["bat", "translation", "task", "list", "--json"]).unwrap();
assert_eq!(options.command, CliCommand::TranslationTasks);
let options = parse(&["bat", "translation", "task", "status", "--json"]).unwrap();
assert_eq!(options.command, CliCommand::TranslationTasks);
let options = parse(&["bat", "translation", "handoff", "--json"]).unwrap();
assert_eq!(options.command, CliCommand::TranslationHandoff);
let options = parse(&["bat", "translation", "status", "--json"]).unwrap();
assert_eq!(options.command, CliCommand::LocalizedStatus);
let options = parse(&[
"bat",
"translation",
"task",
"update",
"--state-dir",
"/tmp/bat-state",
"--task-id",
"textunit/v-current/TextAssets/Scenario.json",
"--task-status",
"running",
])
.unwrap();
assert_eq!(options.command, CliCommand::TranslationTaskUpdate);
}
#[test]
@@ -1100,6 +1220,9 @@ fn parses_management_and_resource_commands() {
assert_eq!(options.command, expected);
}
let options = parse(&["bat", "resource", "status"]).unwrap();
assert_eq!(options.command, CliCommand::ResourceIndex);
let index = parse(&[
"bat",
"resource-index",
@@ -3067,12 +3190,28 @@ fn write_catalog_fixture(
output_root: &Path,
current_bundle: &str,
previous_bundle: Option<&str>,
) -> PathBuf {
write_catalog_fixture_with_localized(
state_dir,
output_root,
&output_root.with_file_name("localized"),
current_bundle,
previous_bundle,
)
}
fn write_catalog_fixture_with_localized(
state_dir: &Path,
output_root: &Path,
localized_output_root: &Path,
current_bundle: &str,
previous_bundle: Option<&str>,
) -> PathBuf {
fs::create_dir_all(state_dir).unwrap();
fs::create_dir_all(output_root).unwrap();
write_daemon_status_file(
&daemon_status_path(state_dir),
&test_daemon_status_file(state_dir, output_root),
&test_daemon_status_file_with_localized(state_dir, output_root, localized_output_root),
)
.unwrap();
@@ -4090,6 +4229,7 @@ fn dispatch_localized_status_verifies_current_release_pointer() {
official_release_id: "v-current".to_string(),
current_release_id: Some("v-current".to_string()),
status: "localized".to_string(),
translation_workflow_status: None,
updated_unix_seconds: 123,
})
.unwrap(),
@@ -4138,6 +4278,165 @@ fn dispatch_localized_status_verifies_current_release_pointer() {
assert_eq!(value["data"]["patch_manifest_matches_release"], true);
assert_eq!(value["data"]["patch_file_count"], 0);
assert_eq!(value["data"]["patch_text_asset_operation_count"], 0);
assert_eq!(
value["data"]["translation_workflow_status"],
serde_json::Value::Null
);
assert_eq!(
value["data"]["published_version_path"].as_str().unwrap(),
localized_version.to_string_lossy()
);
}
#[test]
fn dispatch_translation_proofread_marks_state_for_dashboard() {
let temp = tempfile::TempDir::new().unwrap();
let state_dir = temp.path().join("state");
let output_root = temp.path().join("output");
let localized_root = temp.path().join("localized");
write_catalog_fixture_with_localized(
&state_dir,
&output_root,
&localized_root,
"bundle-b2",
None,
);
let tasks = test_task_context_with_config(OfficialUpdateConfig {
localized_output_root: localized_root.clone(),
..OfficialUpdateConfig::default()
});
let envelope = dispatch_rpc_method(
&rpc_request("translation.proofread", None),
&state_dir,
&new_daemon_control(),
&tasks,
"req-proofread-1".to_string(),
);
let value = serde_json::to_value(&envelope).unwrap();
assert_eq!(value["ok"], true);
assert_eq!(
value["data"]["translation_workflow_status"],
"manual_proofreading"
);
assert_eq!(
value["data"]["translation_workflow_status_code"],
"translation.manual_proofreading"
);
assert_eq!(value["data"]["translation_workflow_label"], "人工校对中");
assert_eq!(value["data"]["publish_allowed"], false);
let envelope = dispatch_rpc_method(
&rpc_request("localized.status", None),
&state_dir,
&new_daemon_control(),
&tasks,
"req-proofread-status-1".to_string(),
);
let value = serde_json::to_value(&envelope).unwrap();
assert_eq!(value["ok"], true);
assert_eq!(value["data"]["status_code"], "localized.pending");
assert_eq!(
value["data"]["translation_workflow_status_code"],
"translation.manual_proofreading"
);
assert_eq!(value["data"]["translation_workflow_label"], "人工校对中");
assert_eq!(
value["data"]["state"]["translation_workflow_status"],
"manual_proofreading"
);
}
#[cfg(unix)]
#[test]
fn localized_status_keeps_published_release_during_manual_proofreading() {
use std::os::unix::fs::symlink;
let temp = tempfile::TempDir::new().unwrap();
let state_dir = temp.path().join("state");
let output_root = temp.path().join("output");
let localized_root = temp.path().join("localized");
write_catalog_fixture_with_localized(
&state_dir,
&output_root,
&localized_root,
"bundle-b2",
None,
);
let localized_version = localized_root
.join(LOCALIZED_VERSIONS_DIR)
.join("v-current-auto");
fs::create_dir_all(&localized_version).unwrap();
symlink(
Path::new(LOCALIZED_VERSIONS_DIR).join("v-current-auto"),
localized_root.join(LOCALIZED_CURRENT_LINK),
)
.unwrap();
fs::write(
localized_root.join(LOCALIZED_VERSION_STATE_FILE),
serde_json::to_vec(&bat_infrastructure::LocalizedVersionState {
state_version: bat_infrastructure::LOCALIZED_VERSION_STATE_VERSION,
official_release_id: "v-current".to_string(),
current_release_id: Some("v-current-auto".to_string()),
status: "localized".to_string(),
translation_workflow_status: None,
updated_unix_seconds: 123,
})
.unwrap(),
)
.unwrap();
fs::write(
localized_version.join(LOCALIZED_PATCH_MANIFEST_FILE),
serde_json::to_vec(&bat_infrastructure::LocalizedPatchManifest {
manifest_version: bat_infrastructure::LOCALIZED_PATCH_MANIFEST_VERSION,
official_release_id: "v-current".to_string(),
localized_release_id: "v-current-auto".to_string(),
generated_unix_seconds: 124,
file_count: 0,
text_asset_operation_count: 0,
files: Vec::new(),
rollback: bat_infrastructure::LocalizedPatchRollbackInfo {
previous_current_target: None,
remove_version_path: localized_version.clone(),
},
})
.unwrap(),
)
.unwrap();
let tasks = test_task_context_with_config(OfficialUpdateConfig {
localized_output_root: localized_root.clone(),
..OfficialUpdateConfig::default()
});
let envelope = dispatch_rpc_method(
&rpc_request("translation.proofread", None),
&state_dir,
&new_daemon_control(),
&tasks,
"req-proofread-2".to_string(),
);
let value = serde_json::to_value(&envelope).unwrap();
assert_eq!(value["ok"], true);
assert_eq!(value["data"]["publish_allowed"], true);
let envelope = dispatch_rpc_method(
&rpc_request("localized.status", None),
&state_dir,
&new_daemon_control(),
&tasks,
"req-proofread-status-2".to_string(),
);
let value = serde_json::to_value(&envelope).unwrap();
assert_eq!(value["ok"], true);
assert_eq!(value["data"]["status"], "published");
assert_eq!(value["data"]["status_code"], "localized.published");
assert_eq!(value["data"]["localized_release_status"], "localized");
assert_eq!(
value["data"]["translation_workflow_status_code"],
"translation.manual_proofreading"
);
assert_eq!(value["data"]["translation_workflow_label"], "人工校对中");
assert_eq!(value["data"]["current_points_to_published_version"], true);
assert_eq!(
value["data"]["published_version_path"].as_str().unwrap(),
localized_version.to_string_lossy()
@@ -4168,6 +4467,7 @@ fn dispatch_localized_status_rejects_stale_release_state() {
official_release_id: "v-old".to_string(),
current_release_id: Some("v-old".to_string()),
status: "localized".to_string(),
translation_workflow_status: None,
updated_unix_seconds: 123,
})
.unwrap(),
@@ -235,6 +235,24 @@ pub(super) fn run_translation_task_update(options: &CliOptions) -> anyhow::Resul
print_json_value(options.output_format, &report)
}
pub(super) fn run_translation_proofread(options: &CliOptions) -> anyhow::Result<()> {
if daemon_rpc_available(&options.state_dir)
&& options.resource_root.is_none()
&& !options.output_explicit
{
let _control_lock = DaemonControlLock::acquire(&options.state_dir)?;
let report = daemon_rpc_call(&options.state_dir, RPC_METHOD_TRANSLATION_PROOFREAD, None)?;
print_json_value(options.output_format, &report)?;
return Ok(());
}
let (_, official_release_id) = current_official_release(options)?;
let report = bat_infrastructure::mark_localized_manual_proofreading(
&options.config.localized_output_root,
&official_release_id,
)?;
print_report(options.output_format, &report)
}
pub(super) fn run_repack(options: &CliOptions) -> anyhow::Result<()> {
let spec = options
.repack_spec