Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1929760e82 | |||
| 167e5c4f65 | |||
| 40c9ca38b9 | |||
| 6bb99f6e0e | |||
| 53fee00315 | |||
| c508caab7b | |||
| e90a1bb6ec | |||
| 27f023964f | |||
| b43c8db305 | |||
| e3fc28e440 | |||
| c9638403ab | |||
| 02ae9c6745 | |||
| c8cb378123 | |||
| 47060bcb2d |
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -8,5 +8,6 @@
|
|||||||
"**/Thumbs.db": true,
|
"**/Thumbs.db": true,
|
||||||
// "**/node_modules": true,
|
// "**/node_modules": true,
|
||||||
"**/.angular": true
|
"**/.angular": true
|
||||||
}
|
},
|
||||||
|
"editor.formatOnSave": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<header>
|
<header>
|
||||||
<app-panel></app-panel>
|
<app-panel></app-panel>
|
||||||
</header>
|
</header>
|
||||||
<main class="main">
|
<main>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.main {
|
main {
|
||||||
display: block;
|
overflow-y: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 2rem);
|
height: calc(100% - 2rem);
|
||||||
background-image: url("../assets/img/wallpaper.png");
|
background-image: url("../assets/img/wallpaper.png");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from "@angular/router";
|
||||||
import { PanelComponent } from "./modules/panel/panel.component";
|
import { PanelComponent } from "./modules/panel/panel.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -3,7 +3,15 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 3rem;
|
width: 5rem;
|
||||||
height: 3rem;
|
height: 6rem;
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
user-select: none;
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: 0.2s ease-in-out;
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(25, 17, 19, 0.7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<h1 *ngIf="elements_data.length">Всего: {{ elements_data.length }}</h1>
|
@if (elements_data.length) {
|
||||||
|
<h1>{{ "ROW_COUNT_LABEL" | translate }}: {{ elements_data.length }}</h1>
|
||||||
|
<h2>{{ "FILE_NAME_LABEL" | translate }}: {{ fileName }}</h2>
|
||||||
|
}
|
||||||
<div id="elements">
|
<div id="elements">
|
||||||
@for(item of elements_data; track $index) {
|
@for (item of elements_data; track $index) {
|
||||||
<app-translate-block #translateBlock [index]="$index" [item]="item"></app-translate-block>
|
<app-translate-block #translateBlock [index]="$index" [item]="item"></app-translate-block>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,13 +6,7 @@
|
|||||||
margin-inline: 2rem;
|
margin-inline: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix scroll on router click
|
h1, h2 {
|
||||||
:host {
|
|
||||||
overflow-y: scroll;
|
|
||||||
height: fit-content;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
color: #efdee0;
|
color: #efdee0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 1rem 2rem;
|
margin: 1rem 2rem;
|
||||||
|
|||||||
@@ -1,24 +1,36 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, QueryList, ViewChildren } from '@angular/core';
|
import { AfterViewInit, Component, Input, QueryList, ViewChildren } from "@angular/core";
|
||||||
import { TranslateData } from '../../dto/translate_data.dto';
|
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||||
import { TranslateBlockComponent } from '../translate_block/translate_block.component';
|
import { NpsFile, TranslateData } from "../../dto/translate_data.dto";
|
||||||
|
import { TranslateBlockComponent } from "../translate_block/translate_block.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-text-list',
|
selector: "app-text-list",
|
||||||
templateUrl: './text_list.component.html',
|
templateUrl: "./text_list.component.html",
|
||||||
styleUrls: ['./text_list.component.scss'],
|
styleUrls: ["./text_list.component.scss"],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslateBlockComponent],
|
imports: [CommonModule, TranslateBlockComponent, TranslationPipe],
|
||||||
})
|
})
|
||||||
export class TextListComponent {
|
export class TextListComponent implements AfterViewInit {
|
||||||
@ViewChildren('translateBlock') translate_blocks: QueryList<TranslateBlockComponent> | null = null;
|
@ViewChildren("translateBlock") translate_blocks: QueryList<TranslateBlockComponent> | null =
|
||||||
|
null;
|
||||||
|
fileName = "";
|
||||||
elements_data: TranslateData[] = [];
|
elements_data: TranslateData[] = [];
|
||||||
@Input() set elements(el: TranslateData[]) {
|
@Input() set elements(el: TranslateData[]) {
|
||||||
this.elements_data = el;
|
this.elements_data = el;
|
||||||
localStorage.setItem('translations', JSON.stringify(this.elements_data));
|
localStorage.setItem("translations", JSON.stringify(this.elements_data));
|
||||||
|
this.ngAfterViewInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
get elements() {
|
get elements() {
|
||||||
return this.elements_data;
|
return this.elements_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
const data = localStorage.getItem("original_file");
|
||||||
|
if (data) {
|
||||||
|
const file: NpsFile = JSON.parse(data);
|
||||||
|
this.fileName = file.file_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<div class="element">
|
<div class="element">
|
||||||
<h2>{{ index + 1 }}</h2>
|
<h2>{{ index + 1 }}</h2>
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
|
<h2>{{ item.name }}</h2>
|
||||||
<nwui-textarea [contenteditable]="false">{{ item.english_text }}</nwui-textarea>
|
<nwui-textarea [contenteditable]="false">{{ item.english_text }}</nwui-textarea>
|
||||||
<nwui-textarea
|
<nwui-textarea
|
||||||
#translatedText
|
#translatedText
|
||||||
@@ -11,8 +12,14 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<nwui-button (click)="sendToGoogleTranslate()" [disabled]="translateLoading">Translate</nwui-button>
|
<nwui-button (click)="sendToGoogleTranslate()" [disabled]="translateLoading">{{
|
||||||
<nwui-button (click)="isEditing = !isEditing" [disabled]="isEditing">Edit</nwui-button>
|
"TRANSLATE_BTN" | translate
|
||||||
<nwui-button (click)="clear()" [disabled]="!item.translated_text.length">Clear</nwui-button>
|
}}</nwui-button>
|
||||||
|
<nwui-button (click)="isEditing = !isEditing" [disabled]="isEditing">{{
|
||||||
|
"EDIT_BTN" | translate
|
||||||
|
}}</nwui-button>
|
||||||
|
<nwui-button (click)="clear()" [disabled]="!item.translated_text.length">{{
|
||||||
|
"CLEAR_ROW_BTN" | translate
|
||||||
|
}}</nwui-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,38 +1,45 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
import { Component, Input, OnInit, ViewChild } from "@angular/core";
|
||||||
import { NWUIButtonComponent, NWUITextAreaComponent } from '@nwaifu-ui';
|
import { NWUIButtonComponent, NWUITextAreaComponent } from "@nwaifu-ui";
|
||||||
import { LocalStorageKeys } from '../../consts';
|
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||||
import { TranslateData } from '../../dto/translate_data.dto';
|
import { LocalStorageKeys } from "../../consts";
|
||||||
import { ETranslateService } from '../../services/translate.enums';
|
import { TranslateData } from "../../dto/translate_data.dto";
|
||||||
import { TranslateService } from '../../services/translate.service';
|
import { ETranslateService } from "../../services/translate.enums";
|
||||||
|
import { TranslateService } from "../../services/translate.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-translate-block',
|
selector: "app-translate-block",
|
||||||
templateUrl: './translate_block.component.html',
|
templateUrl: "./translate_block.component.html",
|
||||||
styleUrls: ['./translate_block.component.scss'],
|
styleUrls: ["./translate_block.component.scss"],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, NWUIButtonComponent, NWUITextAreaComponent],
|
imports: [CommonModule, NWUIButtonComponent, NWUITextAreaComponent, TranslationPipe],
|
||||||
providers: [TranslateService],
|
providers: [TranslateService],
|
||||||
})
|
})
|
||||||
export class TranslateBlockComponent implements OnInit {
|
export class TranslateBlockComponent implements OnInit {
|
||||||
@ViewChild('translatedText') translatedText: NWUITextAreaComponent | null = null;
|
@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;
|
@Input({ required: true }) index = 0;
|
||||||
translateLoading = false;
|
translateLoading = false;
|
||||||
isEditing = false;
|
isEditing = false;
|
||||||
|
|
||||||
saveChanges() {
|
saveChanges() {
|
||||||
const data: TranslateData[] = JSON.parse(localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? '[]');
|
const data: TranslateData[] = JSON.parse(
|
||||||
|
localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? "[]",
|
||||||
|
);
|
||||||
if (!data.length) {
|
if (!data.length) {
|
||||||
alert('No data');
|
alert("No data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data[this.index] = this.item;
|
data[this.index] = this.item;
|
||||||
localStorage.setItem('translations', JSON.stringify(data));
|
localStorage.setItem("translations", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.isEditing = this.item.translated_text === '';
|
this.isEditing = this.item.translated_text === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private translateService: TranslateService) {}
|
constructor(private translateService: TranslateService) {}
|
||||||
@@ -40,7 +47,8 @@ export class TranslateBlockComponent implements OnInit {
|
|||||||
private sendToTranslate(service: ETranslateService = ETranslateService.GOOGLE) {
|
private sendToTranslate(service: ETranslateService = ETranslateService.GOOGLE) {
|
||||||
this.translateLoading = true;
|
this.translateLoading = true;
|
||||||
this.translateService.translate(this.item.english_text, service).subscribe((text) => {
|
this.translateService.translate(this.item.english_text, service).subscribe((text) => {
|
||||||
if (this.translatedText) if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = text;
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = text;
|
||||||
this.item.translated_text = text;
|
this.item.translated_text = text;
|
||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
this.translateLoading = false;
|
this.translateLoading = false;
|
||||||
@@ -62,14 +70,16 @@ export class TranslateBlockComponent implements OnInit {
|
|||||||
|
|
||||||
saveTranslate(text: string) {
|
saveTranslate(text: string) {
|
||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
if (this.translatedText) if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = '';
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = "";
|
||||||
this.item.translated_text = text;
|
this.item.translated_text = text;
|
||||||
this.saveChanges();
|
this.saveChanges();
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
this.item.translated_text = '';
|
this.item.translated_text = "";
|
||||||
this.isEditing = true;
|
this.isEditing = true;
|
||||||
if (this.translatedText) if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = '';
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = "";
|
||||||
this.saveChanges();
|
this.saveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export interface TranslateData {
|
export interface TranslateData {
|
||||||
english_text: string;
|
english_text: string;
|
||||||
translated_text: string;
|
translated_text: string;
|
||||||
|
name: string;
|
||||||
}
|
}
|
||||||
export interface NpsFile {
|
export interface NpsFile {
|
||||||
file_name: string;
|
file_name: string;
|
||||||
|
|||||||
@@ -1,15 +1,35 @@
|
|||||||
import { TranslateData } from '../dto/translate_data.dto';
|
import { TranslateData } from "../dto/translate_data.dto";
|
||||||
|
|
||||||
export function parse(text: string): TranslateData[] {
|
export function parse(text: string): TranslateData[] {
|
||||||
const replaced_text = text
|
// Find all TEXT attr data
|
||||||
.replace('/<[kK]{1}>/gm', '\n')
|
const result: TranslateData[] = [];
|
||||||
.replace(/(<[^>]*>|\/\/.*)/gm, '')
|
const re = /^(?!\/\/)<[^>]*TEXT="(?<textAttr>[^>"]+)"[^>]*>/gim;
|
||||||
.replace(/\s*\n\s*/gm, '\n');
|
for (const match of text.matchAll(re)) {
|
||||||
const result = replaced_text
|
console.log(match);
|
||||||
.split('\n')
|
if (match.groups?.["textAttr"])
|
||||||
.map((line) => line.trim())
|
result.push({
|
||||||
.filter((line) => line.length > 0)
|
english_text: match.groups?.["textAttr"],
|
||||||
.map((line) => ({ english_text: line, translated_text: '' }));
|
translated_text: "",
|
||||||
|
name: "Choice (without name)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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) => line.trim())
|
||||||
|
.forEach((line) => {
|
||||||
|
result.push({ english_text: line, translated_text: "", name: name });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
console.log(result);
|
console.log(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,33 @@
|
|||||||
<div class="btns">
|
<div class="btns">
|
||||||
<nwui-button (click)="fileInput.click()">
|
<div id="op_btns">
|
||||||
<span><i class="lni lni-upload"></i> Upload</span>
|
<nwui-button (click)="fileInput.click()">
|
||||||
<input type="file" (change)="submitFile($event)" accept=".nps" #fileInput style="display: none" />
|
<span><i class="lni lni-upload"></i> {{ "UPLOAD_BTN" | translate }}</span>
|
||||||
</nwui-button>
|
<input
|
||||||
<nwui-button (click)="onSaveClicked()">
|
type="file"
|
||||||
<span><i class="lni lni-save"></i> Save</span>
|
(change)="submitFile($event)"
|
||||||
</nwui-button>
|
accept=".nps"
|
||||||
@if (this.elements.length){
|
#fileInput
|
||||||
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
style="display: none"
|
||||||
<span><i class="lni lni-trash-can"></i> Clear translations</span>
|
/>
|
||||||
</nwui-button>
|
</nwui-button>
|
||||||
<nwui-button (click)="getAllTranslations()">
|
<nwui-button (click)="onSaveClicked()">
|
||||||
<span><i class="lni lni-google"></i> Translate all</span>
|
<span><i class="lni lni-save"></i> {{ "SAVE_BTN" | translate }}</span>
|
||||||
</nwui-button>
|
</nwui-button>
|
||||||
<nwui-button (click)="onClearClicked()">
|
@if (this.elements.length) {
|
||||||
<span><i class="lni lni-trash-can"></i> Clear</span>
|
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
||||||
</nwui-button>
|
<span><i class="lni lni-trash-can"></i> {{ "CLEAR_TRANSLATIONS_BTN" | translate }}</span>
|
||||||
}
|
</nwui-button>
|
||||||
|
<nwui-button (click)="getAllTranslations()">
|
||||||
|
<span><i class="lni lni-google"></i> {{ "TRANSLATE_ALL_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="onClearClicked()">
|
||||||
|
<span><i class="lni lni-trash-can"></i> {{ "CLEAR_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<button id="close_win" (click)="onCloseClicked()"><i class="lni lni-close"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<app-text-list [elements]="elements"></app-text-list>
|
<app-text-list [elements]="elements"></app-text-list>
|
||||||
|
<nwui-button class="to-top-btn" (click)="scrollToTop()"
|
||||||
|
><i class="lni lni-arrow-up"></i
|
||||||
|
></nwui-button>
|
||||||
|
|||||||
@@ -1,14 +1,58 @@
|
|||||||
.btns {
|
.btns {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-start;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
scrollbar-color: #413738;
|
||||||
nwui-button {
|
nwui-button {
|
||||||
margin: 2rem;
|
margin: 2rem;
|
||||||
}
|
}
|
||||||
|
#op_btns {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
#close_win {
|
||||||
|
color: var(--white);
|
||||||
|
font-weight: 600;
|
||||||
|
margin-inline: 2rem;
|
||||||
|
background-color: #413738;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 50px;
|
||||||
|
transition: 0.2s linear;
|
||||||
|
i {
|
||||||
|
transition: 0.3s linear;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background-color: #5b3f45;
|
||||||
|
transform: scale(1.1);
|
||||||
|
i {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
:host {
|
:host {
|
||||||
background-color: #191113;
|
background-color: #191113;
|
||||||
display: block;
|
display: block;
|
||||||
min-height: calc(100vh - 2rem);
|
min-height: calc(100vh - 2rem);
|
||||||
|
scrollbar-color: #413738;
|
||||||
|
}
|
||||||
|
.to-top-btn {
|
||||||
|
position: fixed;
|
||||||
|
width: 2rem;
|
||||||
|
left: 2rem;
|
||||||
|
bottom: -5rem;
|
||||||
|
transition: bottom 0.3s ease-in-out;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
bottom: 1rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { NWUIButtonComponent } from '@nwaifu-ui';
|
import { Router } from "@angular/router";
|
||||||
import { TextListComponent } from './components/text_list/text_list.component';
|
import { NWUIButtonComponent } from "@nwaifu-ui";
|
||||||
import { LocalStorageKeys } from './consts';
|
import { fromEvent, map } from "rxjs";
|
||||||
import { NpsFile, TranslateData } from './dto/translate_data.dto';
|
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||||
import { saveOriginalFile } from './lib/file_tools';
|
import { TextListComponent } from "./components/text_list/text_list.component";
|
||||||
import { parse } from './lib/parser';
|
import { LocalStorageKeys } from "./consts";
|
||||||
|
import { NpsFile, TranslateData } from "./dto/translate_data.dto";
|
||||||
|
import { saveOriginalFile } from "./lib/file_tools";
|
||||||
|
import { parse } from "./lib/parser";
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [TextListComponent, CommonModule, NWUIButtonComponent],
|
imports: [TextListComponent, CommonModule, NWUIButtonComponent, TranslationPipe],
|
||||||
selector: 'app-nitroplus',
|
selector: "app-nitroplus",
|
||||||
templateUrl: './nitroplus-translator.component.html',
|
templateUrl: "./nitroplus-translator.component.html",
|
||||||
styleUrl: './nitroplus-translator.component.less',
|
styleUrl: "./nitroplus-translator.component.less",
|
||||||
})
|
})
|
||||||
export class NitroplusComponent implements OnInit {
|
export class NitroplusComponent implements OnInit, AfterViewInit {
|
||||||
title = 'NitroPlusTranslator';
|
title = "NitroPlusTranslator";
|
||||||
elements: TranslateData[] = [];
|
elements: TranslateData[] = [];
|
||||||
@ViewChild('fileInput') fileInput: HTMLInputElement | null = null;
|
@ViewChild("fileInput") fileInput: HTMLInputElement | null = null;
|
||||||
@ViewChild(TextListComponent) text_list: TextListComponent | null = null;
|
@ViewChild(TextListComponent) text_list: TextListComponent | null = null;
|
||||||
|
|
||||||
|
constructor(private readonly router: Router) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -26,13 +31,32 @@ export class NitroplusComponent implements OnInit {
|
|||||||
this.elements = JSON.parse(data);
|
this.elements = JSON.parse(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
alert('Error while loading');
|
alert("Error while loading");
|
||||||
localStorage.removeItem(LocalStorageKeys.TRANSLATIONS);
|
localStorage.removeItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
this.elements = [];
|
this.elements = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
const container = document.querySelector("main");
|
||||||
|
if (container) {
|
||||||
|
fromEvent(container, "scroll")
|
||||||
|
.pipe(map(() => container.scrollTop > 100))
|
||||||
|
.subscribe((val) => {
|
||||||
|
if (val) document.querySelector(".to-top-btn")?.classList.add("active");
|
||||||
|
else document.querySelector(".to-top-btn")?.classList.remove("active");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToTop() {
|
||||||
|
const container = document.querySelector("main");
|
||||||
|
if (container) {
|
||||||
|
container.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
submitFile($event: Event) {
|
submitFile($event: Event) {
|
||||||
const target = $event.target as HTMLInputElement;
|
const target = $event.target as HTMLInputElement;
|
||||||
if (target.files) {
|
if (target.files) {
|
||||||
@@ -47,7 +71,7 @@ export class NitroplusComponent implements OnInit {
|
|||||||
original_text: reader.result.toString(),
|
original_text: reader.result.toString(),
|
||||||
};
|
};
|
||||||
saveOriginalFile(original_file);
|
saveOriginalFile(original_file);
|
||||||
target.value = '';
|
target.value = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
@@ -67,21 +91,27 @@ export class NitroplusComponent implements OnInit {
|
|||||||
|
|
||||||
onSaveClicked() {
|
onSaveClicked() {
|
||||||
const original_file: NpsFile = JSON.parse(
|
const original_file: NpsFile = JSON.parse(
|
||||||
localStorage.getItem(LocalStorageKeys.ORIGINAL_FILE) ?? '{"file_name":"", "original_text":""}',
|
localStorage.getItem(LocalStorageKeys.ORIGINAL_FILE) ??
|
||||||
|
'{"file_name":"", "original_text":""}',
|
||||||
);
|
);
|
||||||
if (original_file.file_name && original_file.original_text) {
|
if (original_file.file_name && original_file.original_text) {
|
||||||
const data: TranslateData[] = JSON.parse(localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? '[]');
|
const data: TranslateData[] = JSON.parse(
|
||||||
|
localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? "[]",
|
||||||
|
);
|
||||||
if (!data.length) {
|
if (!data.length) {
|
||||||
alert('No data');
|
alert("No data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
original_file.translated_text = original_file.original_text;
|
original_file.translated_text = original_file.original_text;
|
||||||
data.forEach((el) => {
|
data.forEach((el) => {
|
||||||
original_file.translated_text = original_file.translated_text?.replace(el.english_text, el.translated_text);
|
original_file.translated_text = original_file.translated_text?.replace(
|
||||||
|
el.english_text,
|
||||||
|
el.translated_text,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const element = document.createElement('a');
|
const element = document.createElement("a");
|
||||||
const file = new Blob([original_file.translated_text], { type: 'text/plain' });
|
const file = new Blob([original_file.translated_text], { type: "text/plain" });
|
||||||
element.href = URL.createObjectURL(file);
|
element.href = URL.createObjectURL(file);
|
||||||
element.download = original_file.file_name;
|
element.download = original_file.file_name;
|
||||||
element.click();
|
element.click();
|
||||||
@@ -92,7 +122,9 @@ export class NitroplusComponent implements OnInit {
|
|||||||
clearAllTranslations() {
|
clearAllTranslations() {
|
||||||
if (this.text_list)
|
if (this.text_list)
|
||||||
if (this.text_list.translate_blocks) {
|
if (this.text_list.translate_blocks) {
|
||||||
this.text_list.translate_blocks.filter((item) => item.item.translated_text).forEach((item) => item.clear());
|
this.text_list.translate_blocks
|
||||||
|
.filter((item) => item.item.translated_text)
|
||||||
|
.forEach((item) => item.clear());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,4 +137,8 @@ export class NitroplusComponent implements OnInit {
|
|||||||
get has_translations(): boolean {
|
get has_translations(): boolean {
|
||||||
return this.elements.some((i) => i.translated_text);
|
return this.elements.some((i) => i.translated_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCloseClicked() {
|
||||||
|
this.router.navigate(["/"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Telegram channel",
|
"TELEGRAM_LABEL": "Telegram channel",
|
||||||
"GITHUB_LABEL": "Admin's Github",
|
"GITHUB_LABEL": "Admin's Github",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "Source code"
|
"SOURCE_CODE_TITLE": "Source code",
|
||||||
|
"UPLOAD_BTN": "Upload",
|
||||||
|
"SAVE_BTN": "Save",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "Clear translations",
|
||||||
|
"CLEAR_BTN": "Clear",
|
||||||
|
"ROW_COUNT_LABEL": "Row count",
|
||||||
|
"FILE_NAME_LABEL": "File name",
|
||||||
|
"TRANSLATE_BTN": "Translate",
|
||||||
|
"EDIT_BTN": "Edit",
|
||||||
|
"CLEAR_ROW_BTN": "Clear",
|
||||||
|
"TRANSLATE_ALL_BTN": "Translate all"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Telegramチャンネル",
|
"TELEGRAM_LABEL": "Telegramチャンネル",
|
||||||
"GITHUB_LABEL": "管理者Github",
|
"GITHUB_LABEL": "管理者Github",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "ソースコード"
|
"SOURCE_CODE_TITLE": "ソースコード",
|
||||||
|
"UPLOAD_BTN": "アップロード",
|
||||||
|
"SAVE_BTN": "保存",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "翻訳をクリア",
|
||||||
|
"CLEAR_BTN": "クリア",
|
||||||
|
"ROW_COUNT_LABEL": "行数",
|
||||||
|
"FILE_NAME_LABEL": "ファイル名",
|
||||||
|
"TRANSLATE_BTN": "翻訳",
|
||||||
|
"EDIT_BTN": "編集",
|
||||||
|
"CLEAR_ROW_BTN": "クリア",
|
||||||
|
"TRANSLATE_ALL_BTN": "すべて翻訳"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Телеграм канал",
|
"TELEGRAM_LABEL": "Телеграм канал",
|
||||||
"GITHUB_LABEL": "Github админа",
|
"GITHUB_LABEL": "Github админа",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "Исходный код"
|
"SOURCE_CODE_TITLE": "Исходный код",
|
||||||
|
"UPLOAD_BTN": "Загрузить",
|
||||||
|
"SAVE_BTN": "Сохранить",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "Очистить переводы",
|
||||||
|
"CLEAR_BTN": "Очистить",
|
||||||
|
"ROW_COUNT_LABEL": "Количество строк",
|
||||||
|
"FILE_NAME_LABEL": "Имя файла",
|
||||||
|
"TRANSLATE_BTN": "Перевести",
|
||||||
|
"EDIT_BTN": "Редактировать",
|
||||||
|
"CLEAR_ROW_BTN": "Очистить",
|
||||||
|
"TRANSLATE_ALL_BTN": "Перевести все"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,16 +25,10 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
html {
|
html, body {
|
||||||
position: relative;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100%;
|
||||||
position: absolute;
|
position: relative;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
}
|
||||||
ngneat-dialog {
|
ngneat-dialog {
|
||||||
.ngneat-dialog-backdrop {
|
.ngneat-dialog-backdrop {
|
||||||
|
|||||||
@@ -3,10 +3,15 @@ button {
|
|||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #5b3f45;
|
background-color: #5b3f45;
|
||||||
|
word-break: keep-all;
|
||||||
padding: 1em 1.5em;
|
padding: 1em 1.5em;
|
||||||
color: #f5f6fa;
|
color: #f5f6fa;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
transition: ease-in-out 0.2s;
|
transition: ease-in-out 0.2s;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
&:hover,
|
&:hover,
|
||||||
&:active {
|
&:active {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nwaifu-web",
|
"name": "nwaifu-web",
|
||||||
"version": "0.0.1",
|
"version": "0.2.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "nx serve NwaifuWeb",
|
"start": "nx serve NwaifuWeb",
|
||||||
|
|||||||
15912
pnpm-lock.yaml
generated
15912
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user