First commit

This is base for automatization translating
This commit is contained in:
anker-na-20
2026-05-21 10:45:27 +03:00
commit b6dd80e749
18 changed files with 222507 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import fs from "fs";
import path from "path";
/**
* Простейшая заготовка:
* - читает все .txt файлы из папки input
* - копирует их в папку output (пока без реального перевода)
*/
const inputDir = path.join(process.cwd(), "input");
const outputDir = path.join(process.cwd(), "output");
function ensureDirExists(dirPath) {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}
}
async function main() {
ensureDirExists(inputDir);
ensureDirExists(outputDir);
const files = fs
.readdirSync(inputDir)
.filter((name) => name.toLowerCase().endsWith(".txt"));
if (files.length === 0) {
console.log("В папке 'input' нет .txt файлов. Положи туда китайский текст и запусти снова.");
return;
}
for (const file of files) {
const sourcePath = path.join(inputDir, file);
const targetPath = path.join(outputDir, file);
const content = fs.readFileSync(sourcePath, "utf8");
// TODO: здесь позже будет вызов API перевода (OpenAI/DeepL/Яндекс и т.п.)
const translated = `ПОКА ЗАГЛУШКА\n\n${content}`;
fs.writeFileSync(targetPath, translated, "utf8");
console.log(`Обработан файл: ${file}`);
}
console.log("Готово.");
}
main().catch((err) => {
console.error("Ошибка в скрипте:", err);
process.exit(1);
});