Merge branch 'feature/show-row-name' into dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<div class="element">
|
||||
<h2>{{ index + 1 }}</h2>
|
||||
<div class="fields">
|
||||
<h2>{{ item.name }}</h2>
|
||||
<nwui-textarea [contenteditable]="false">{{ item.english_text }}</nwui-textarea>
|
||||
<nwui-textarea
|
||||
#translatedText
|
||||
|
||||
@@ -17,7 +17,11 @@ import { TranslateService } from "../../services/translate.service";
|
||||
})
|
||||
export class TranslateBlockComponent implements OnInit {
|
||||
@ViewChild("translatedText") translatedText: NWUITextAreaComponent | null = null;
|
||||
@Input({ required: true }) item: TranslateData = { english_text: "", translated_text: "" };
|
||||
@Input({ required: true }) item: TranslateData = {
|
||||
english_text: "",
|
||||
translated_text: "",
|
||||
name: "",
|
||||
};
|
||||
@Input({ required: true }) index = 0;
|
||||
translateLoading = false;
|
||||
isEditing = false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export interface TranslateData {
|
||||
english_text: string;
|
||||
translated_text: string;
|
||||
name: string;
|
||||
}
|
||||
export interface NpsFile {
|
||||
file_name: string;
|
||||
|
||||
@@ -3,20 +3,33 @@ import { TranslateData } from "../dto/translate_data.dto";
|
||||
export function parse(text: string): TranslateData[] {
|
||||
// Find all TEXT attr data
|
||||
const result: TranslateData[] = [];
|
||||
const re = /<[^>]*TEXT="(?<textAttr>[^>"]+)"[^>]*>|<[^>]*>|\/\/.*|\s*\n\s*/gm;
|
||||
const re = /^(?!\/\/)<[^>]*TEXT="(?<textAttr>[^>"]+)"[^>]*>/gim;
|
||||
for (const match of text.matchAll(re)) {
|
||||
console.log(match);
|
||||
if (match.groups?.["textAttr"])
|
||||
result.push({ english_text: match.groups?.["textAttr"], translated_text: "" });
|
||||
result.push({
|
||||
english_text: match.groups?.["textAttr"],
|
||||
translated_text: "",
|
||||
name: "Choice (without name)",
|
||||
});
|
||||
}
|
||||
|
||||
const replaced_text = text.replace(re, "\n").replace(/\s*\n\s*/gm, "\n");
|
||||
result.push(
|
||||
...replaced_text
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
const name_re = /<voice name="(?<name>[^"]+)"[^>]*>(?<text>[\s\S]*?)(?=<voice|$)/gi;
|
||||
|
||||
for (const match of text.matchAll(name_re)) {
|
||||
if (match.groups?.["name"] && match.groups?.["text"]) {
|
||||
const name_text = match.groups?.["text"];
|
||||
const name = match.groups?.["name"];
|
||||
const re = /<[^>]*>|\/\/.*|\s*\n\s*/gm;
|
||||
name_text
|
||||
.split(re)
|
||||
.filter((line) => line.length > 0)
|
||||
.map((line) => ({ english_text: line, translated_text: "" })),
|
||||
);
|
||||
.map((line) => line.trim())
|
||||
.forEach((line) => {
|
||||
result.push({ english_text: line, translated_text: "", name: name });
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user