From 86b8231395743220a3e04ea77eb9fa19c08f621a Mon Sep 17 00:00:00 2001 From: lifegpc Date: Fri, 29 Aug 2025 21:16:21 +0800 Subject: [PATCH] Add alias for m3t output format fix kr scn extension --- README.md | 2 +- src/main.rs | 8 ++++---- src/scripts/kirikiri/scn.rs | 4 ++-- src/types.rs | 3 +++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6d86589..24f7bad 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ msg-tool create -t ## Supported Output Script Types - `json` - [GalTransl](https://github.com/GalTransl/GalTransl)'s JSON format -- `m3t` - A simple text format that supports both original/llm/translated messages. +- `m3t` / `m3ta` - A simple text format that supports both original/llm/translated messages. - `yaml` - Same as `json`, but in YAML format. ## Supported Image Types diff --git a/src/main.rs b/src/main.rs index fab6258..a44f16e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -595,7 +595,7 @@ pub fn export_script( } } } - types::OutputScriptType::M3t => { + types::OutputScriptType::M3t | types::OutputScriptType::M3ta => { let enc = get_output_encoding(arg); let s = output_scripts::m3t::M3tDumper::dump(&mes); let b = match utils::encoding::encode_string(enc, &s, false) { @@ -888,7 +888,7 @@ pub fn export_script( let mut f = utils::files::write_file(&f)?; f.write_all(&b)?; } - types::OutputScriptType::M3t => { + types::OutputScriptType::M3t | types::OutputScriptType::M3ta => { let enc = get_output_encoding(arg); let s = output_scripts::m3t::M3tDumper::dump(&mes); let b = utils::encoding::encode_string(enc, &s, false)?; @@ -1083,7 +1083,7 @@ pub fn import_script( } } } - types::OutputScriptType::M3t => { + types::OutputScriptType::M3t | types::OutputScriptType::M3ta => { let enc = get_output_encoding(arg); let b = match utils::files::read_file(&out_path) { Ok(b) => b, @@ -1314,7 +1314,7 @@ pub fn import_script( let s = utils::encoding::decode_to_string(enc, &b, true)?; serde_json::from_str::>(&s)? } - types::OutputScriptType::M3t => { + types::OutputScriptType::M3t | types::OutputScriptType::M3ta => { let enc = get_output_encoding(arg); let b = utils::files::read_file(&out_f)?; let s = utils::encoding::decode_to_string(enc, &b, true)?; diff --git a/src/scripts/kirikiri/scn.rs b/src/scripts/kirikiri/scn.rs index ccb362c..d578e92 100644 --- a/src/scripts/kirikiri/scn.rs +++ b/src/scripts/kirikiri/scn.rs @@ -79,7 +79,7 @@ impl ScriptBuilder for ScnScriptBuilder { } fn extensions(&self) -> &'static [&'static str] { - &["ks.scn"] + &["scn"] } fn script_type(&self) -> &'static ScriptType { @@ -92,7 +92,7 @@ impl ScriptBuilder for ScnScriptBuilder { .map(|name| { name.to_ascii_lowercase() .to_string_lossy() - .ends_with(".ks.scn") + .ends_with(".scn") }) .unwrap_or(false) && buf_len >= 4 diff --git a/src/types.rs b/src/types.rs index 9287fad..319495c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -70,6 +70,8 @@ pub enum TextEncoding { pub enum OutputScriptType { /// Text script M3t, + /// Same as M3t, buf different extension + M3ta, /// JSON which can be used for GalTransl Json, /// YAML (same as JSON, but with YAML syntax) @@ -90,6 +92,7 @@ impl AsRef for OutputScriptType { fn as_ref(&self) -> &str { match self { OutputScriptType::M3t => "m3t", + OutputScriptType::M3ta => "m3ta", OutputScriptType::Json => "json", OutputScriptType::Yaml => "yaml", OutputScriptType::Custom => "",