This repository has been archived on 2024-06-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
NitroPlusTranslator/src/app/lib/parser.ts

16 lines
481 B
TypeScript

import { TranslateData } from '../dto/translate_data.dto';
export function parse(text: string): TranslateData[] {
const replaced_text = text
.replace('/<[kK]{1}>/gm', '\n')
.replace(/(<[^>]*>|\/\/.*)/gm, '')
.replace(/\s*\n\s*/gm, '\n');
const result = replaced_text
.split('\n')
.map((line) => line.trim())
.filter((line) => line.length > 0)
.map((line) => ({ english_text: line, translated_text: '' }));
console.log(result);
return result;
}