16 lines
481 B
TypeScript
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;
|
|
}
|