chore: translate CLI and installer messages to English

This commit is contained in:
2026-02-18 21:04:28 +08:00
parent d1e23a3179
commit 95324ce199
16 changed files with 219 additions and 249 deletions

View File

@@ -1,19 +1,13 @@
use crate::config::{FILE_MAIN_C, file_dcr_toml};
use crate::utils::fs::check_dir;
use crate::utils::text::{BOLD, BRIGHT_CYAN, BRIGHT_GREEN, BRIGHT_RED, colored, printc};
use crate::utils::log::{error, warn};
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::fs;
use std::io::Write;
pub fn init(args: &[String]) -> i32 {
let red_bold = BRIGHT_RED.to_owned() + BOLD;
let green_bold = BRIGHT_GREEN.to_owned() + BOLD;
let cyan_bold = BRIGHT_CYAN.to_owned() + BOLD;
if !args.is_empty() {
println!(
"{}: команда не поддерживает доп. аргументы",
colored("error", &red_bold)
);
warn("Command does not support additional arguments");
return 1;
}
@@ -24,22 +18,19 @@ pub fn init(args: &[String]) -> i32 {
.unwrap_or_else(|| "project".to_string());
if !items.is_empty() {
println!("{}: директория не пуста", colored("error", &red_bold));
error("Directory not empty");
return 1;
}
let cwd = std::env::current_dir()
.map(|v| v.to_string_lossy().to_string())
.unwrap_or_else(|_| ".".to_string());
println!("Инициализация проекта в {cwd}");
println!("Initializing the project in {cwd}");
let mut dcr_toml = match fs::File::create("./dcr.toml") {
Ok(file) => file,
Err(_) => {
println!(
"{}: не удалось создать dcr.toml",
colored("error", &red_bold)
);
error("Failed to create dcr.toml");
return 1;
}
};
@@ -47,50 +38,41 @@ pub fn init(args: &[String]) -> i32 {
.write_all(file_dcr_toml(&project_name).as_bytes())
.is_err()
{
println!(
"{}: не удалось записать dcr.toml",
colored("error", &red_bold)
);
error("Failed to write dcr.toml");
return 1;
}
println!(
" {} Создан файл {}",
colored("✔", &green_bold),
colored("dcr.toml", &cyan_bold)
" {} Created file {}",
colored("✔", BOLD_CYAN),
colored("dcr.toml", BOLD_CYAN)
);
if fs::create_dir("src").is_err() {
println!("{}: не удалось создать src", colored("error", &red_bold));
error("Failed to create src/");
return 1;
}
let mut main_c = match fs::File::create("./src/main.c") {
Ok(file) => file,
Err(_) => {
println!(
"{}: не удалось создать src/main.c",
colored("error", &red_bold)
);
error("Failed to create src/main.c");
return 1;
}
};
if main_c.write_all(FILE_MAIN_C.as_bytes()).is_err() {
println!(
"{}: не удалось записать src/main.c",
colored("error", &red_bold)
);
error("Failed to write src/main.c");
return 1;
}
println!(
" {} Создан файл {}\n",
colored("✔", &green_bold),
colored("src/main.c", &cyan_bold)
" {} Created file {}\n",
colored("✔", BOLD_GREEN),
colored("src/main.c", BOLD_CYAN)
);
println!(
"Проект `{}` успешно создан\n",
colored(&project_name, &green_bold)
"Project `{}` successfully created\n",
colored(project_name.as_str(), BOLD_GREEN)
);
printc("Следуюший шаг:", &green_bold);
printc(" dcr run", &cyan_bold);
printc("Next step:", BOLD_GREEN);
printc(" cd {}\n dcr run", project_name.as_str());
0
}