subtitle_translator_cli/
lib.rs1mod args;
2pub use args::*;
3
4mod config;
5pub use config::*;
6
7mod translator;
8pub use translator::*;
9
10mod subtitle_file;
11pub use subtitle_file::*;
12
13mod processor;
14pub use processor::*;
15
16mod utils;
17pub use utils::*;
18#[cfg(test)]
19mod tests {
20
21 use super::*;
22 use std::{fs, time::Instant};
23 #[test]
24 fn test_translate() {
25 let config = Config {
26 file_path: "TEST.txt".to_string(),
27 file_name: "TEST.txt".to_string(),
28 input_language: "auto".to_string(),
29 output_language: "zh-CN".to_string(),
30 };
31 let contents = fs::read_to_string(&config.file_path).unwrap();
32
33 let translated_text = translate(contents, config.input_language, config.output_language);
34 println!("{:?}", translated_text);
35 }
36
37 #[test]
38 fn test_process_files() {
39 let config = Config {
40 file_path: "test.srt".to_string(),
41 file_name: "//".to_string(),
42 input_language: "auto".to_string(),
43 output_language: "en".to_string(),
44 };
45 let start = Instant::now();
46 let translated_text = process_file(
47 config.file_path,
48 config.input_language,
49 config.output_language,
50 )
51 .unwrap();
52 println!("{:?}", translated_text);
53 println!("Time elapsed: {:?}", start.elapsed());
54 }
55}