Compare commits
3 Commits
27f023964f
...
v0.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 53fee00315 | |||
| c508caab7b | |||
| e90a1bb6ec |
@@ -1,6 +1,6 @@
|
||||
@if (elements_data.length) {
|
||||
<h1>Всего: {{ elements_data.length }}</h1>
|
||||
<h2>Файл: {{ fileName }}</h2>
|
||||
<h1>{{ "ROW_COUNT_LABEL" | translate }}: {{ elements_data.length }}</h1>
|
||||
<h2>{{ "FILE_NAME_LABEL" | translate }}: {{ fileName }}</h2>
|
||||
}
|
||||
<div id="elements">
|
||||
@for (item of elements_data; track $index) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnInit, QueryList, ViewChildren } from "@angular/core";
|
||||
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||
import { NpsFile, TranslateData } from "../../dto/translate_data.dto";
|
||||
import { TranslateBlockComponent } from "../translate_block/translate_block.component";
|
||||
|
||||
@@ -8,7 +9,7 @@ import { TranslateBlockComponent } from "../translate_block/translate_block.comp
|
||||
templateUrl: "./text_list.component.html",
|
||||
styleUrls: ["./text_list.component.scss"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslateBlockComponent],
|
||||
imports: [CommonModule, TranslateBlockComponent, TranslationPipe],
|
||||
})
|
||||
export class TextListComponent implements OnInit {
|
||||
@ViewChildren("translateBlock") translate_blocks: QueryList<TranslateBlockComponent> | null =
|
||||
|
||||
@@ -11,8 +11,14 @@
|
||||
>
|
||||
</div>
|
||||
<div class="btns">
|
||||
<nwui-button (click)="sendToGoogleTranslate()" [disabled]="translateLoading">Translate</nwui-button>
|
||||
<nwui-button (click)="isEditing = !isEditing" [disabled]="isEditing">Edit</nwui-button>
|
||||
<nwui-button (click)="clear()" [disabled]="!item.translated_text.length">Clear</nwui-button>
|
||||
<nwui-button (click)="sendToGoogleTranslate()" [disabled]="translateLoading">{{
|
||||
"TRANSLATE_BTN" | translate
|
||||
}}</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>
|
||||
|
||||
@@ -1,38 +1,41 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { NWUIButtonComponent, NWUITextAreaComponent } from '@nwaifu-ui';
|
||||
import { LocalStorageKeys } from '../../consts';
|
||||
import { TranslateData } from '../../dto/translate_data.dto';
|
||||
import { ETranslateService } from '../../services/translate.enums';
|
||||
import { TranslateService } from '../../services/translate.service';
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnInit, ViewChild } from "@angular/core";
|
||||
import { NWUIButtonComponent, NWUITextAreaComponent } from "@nwaifu-ui";
|
||||
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||
import { LocalStorageKeys } from "../../consts";
|
||||
import { TranslateData } from "../../dto/translate_data.dto";
|
||||
import { ETranslateService } from "../../services/translate.enums";
|
||||
import { TranslateService } from "../../services/translate.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-translate-block',
|
||||
templateUrl: './translate_block.component.html',
|
||||
styleUrls: ['./translate_block.component.scss'],
|
||||
selector: "app-translate-block",
|
||||
templateUrl: "./translate_block.component.html",
|
||||
styleUrls: ["./translate_block.component.scss"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, NWUIButtonComponent, NWUITextAreaComponent],
|
||||
imports: [CommonModule, NWUIButtonComponent, NWUITextAreaComponent, TranslationPipe],
|
||||
providers: [TranslateService],
|
||||
})
|
||||
export class TranslateBlockComponent implements OnInit {
|
||||
@ViewChild('translatedText') translatedText: NWUITextAreaComponent | null = null;
|
||||
@Input({ required: true }) item: TranslateData = { english_text: '', translated_text: '' };
|
||||
@ViewChild("translatedText") translatedText: NWUITextAreaComponent | null = null;
|
||||
@Input({ required: true }) item: TranslateData = { english_text: "", translated_text: "" };
|
||||
@Input({ required: true }) index = 0;
|
||||
translateLoading = false;
|
||||
isEditing = false;
|
||||
|
||||
saveChanges() {
|
||||
const data: TranslateData[] = JSON.parse(localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? '[]');
|
||||
const data: TranslateData[] = JSON.parse(
|
||||
localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? "[]",
|
||||
);
|
||||
if (!data.length) {
|
||||
alert('No data');
|
||||
alert("No data");
|
||||
return;
|
||||
}
|
||||
data[this.index] = this.item;
|
||||
localStorage.setItem('translations', JSON.stringify(data));
|
||||
localStorage.setItem("translations", JSON.stringify(data));
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.isEditing = this.item.translated_text === '';
|
||||
this.isEditing = this.item.translated_text === "";
|
||||
}
|
||||
|
||||
constructor(private translateService: TranslateService) {}
|
||||
@@ -40,7 +43,8 @@ export class TranslateBlockComponent implements OnInit {
|
||||
private sendToTranslate(service: ETranslateService = ETranslateService.GOOGLE) {
|
||||
this.translateLoading = true;
|
||||
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.isEditing = false;
|
||||
this.translateLoading = false;
|
||||
@@ -62,14 +66,16 @@ export class TranslateBlockComponent implements OnInit {
|
||||
|
||||
saveTranslate(text: string) {
|
||||
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.saveChanges();
|
||||
}
|
||||
clear() {
|
||||
this.item.translated_text = '';
|
||||
this.item.translated_text = "";
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="btns">
|
||||
<div id="op_btns">
|
||||
<nwui-button (click)="fileInput.click()">
|
||||
<span><i class="lni lni-upload"></i> Upload</span>
|
||||
<span><i class="lni lni-upload"></i> {{ "UPLOAD_BTN" | translate }}</span>
|
||||
<input
|
||||
type="file"
|
||||
(change)="submitFile($event)"
|
||||
@@ -11,17 +11,17 @@
|
||||
/>
|
||||
</nwui-button>
|
||||
<nwui-button (click)="onSaveClicked()">
|
||||
<span><i class="lni lni-save"></i> Save</span>
|
||||
<span><i class="lni lni-save"></i> {{ "SAVE_BTN" | translate }}</span>
|
||||
</nwui-button>
|
||||
@if (this.elements.length) {
|
||||
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
||||
<span><i class="lni lni-trash-can"></i> Clear translations</span>
|
||||
<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</span>
|
||||
<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</span>
|
||||
<span><i class="lni lni-trash-can"></i> {{ "CLEAR_BTN" | translate }}</span>
|
||||
</nwui-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { NWUIButtonComponent } from "@nwaifu-ui";
|
||||
import { fromEvent, map } from "rxjs";
|
||||
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||
import { TextListComponent } from "./components/text_list/text_list.component";
|
||||
import { LocalStorageKeys } from "./consts";
|
||||
import { NpsFile, TranslateData } from "./dto/translate_data.dto";
|
||||
@@ -10,7 +11,7 @@ import { saveOriginalFile } from "./lib/file_tools";
|
||||
import { parse } from "./lib/parser";
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [TextListComponent, CommonModule, NWUIButtonComponent],
|
||||
imports: [TextListComponent, CommonModule, NWUIButtonComponent, TranslationPipe],
|
||||
selector: "app-nitroplus",
|
||||
templateUrl: "./nitroplus-translator.component.html",
|
||||
styleUrl: "./nitroplus-translator.component.less",
|
||||
|
||||
@@ -5,5 +5,15 @@
|
||||
"TELEGRAM_LABEL": "Telegram channel",
|
||||
"GITHUB_LABEL": "Admin's Github",
|
||||
"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チャンネル",
|
||||
"GITHUB_LABEL": "管理者Github",
|
||||
"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": "Телеграм канал",
|
||||
"GITHUB_LABEL": "Github админа",
|
||||
"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": "Перевести все"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nwaifu-web",
|
||||
"version": "0.0.1",
|
||||
"version": "0.2.2",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "nx serve NwaifuWeb",
|
||||
|
||||
Reference in New Issue
Block a user