diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.html b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.html index a142299..2619a4a 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.html +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.html @@ -1,6 +1,6 @@ @if (elements_data.length) { -

Всего: {{ elements_data.length }}

-

Файл: {{ fileName }}

+

{{ "ROW_COUNT_LABEL" | translate }}: {{ elements_data.length }}

+

{{ "FILE_NAME_LABEL" | translate }}: {{ fileName }}

}
@for (item of elements_data; track $index) { diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.ts b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.ts index 2ff1c34..dbae00f 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.ts +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/text_list/text_list.component.ts @@ -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 | null = diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.html b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.html index 7c60d57..e309c08 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.html +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.html @@ -11,8 +11,14 @@ >
- Translate - Edit - Clear + {{ + "TRANSLATE_BTN" | translate + }} + {{ + "EDIT_BTN" | translate + }} + {{ + "CLEAR_ROW_BTN" | translate + }}
diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.ts b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.ts index 58520b1..2136cb2 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.ts +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/components/translate_block/translate_block.component.ts @@ -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(); } } diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.html b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.html index bad6c92..e3a28fe 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.html +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.html @@ -1,7 +1,7 @@
- Upload + {{ "UPLOAD_BTN" | translate }} - Save + {{ "SAVE_BTN" | translate }} @if (this.elements.length) { - Clear translations + {{ "CLEAR_TRANSLATIONS_BTN" | translate }} - Translate all + {{ "TRANSLATE_ALL_BTN" | translate }} - Clear + {{ "CLEAR_BTN" | translate }} }
diff --git a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.ts b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.ts index 5522b61..caa7bca 100644 --- a/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.ts +++ b/apps/NwaifuWeb/src/app/pages/nitroplus-translator/nitroplus-translator.component.ts @@ -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", diff --git a/apps/NwaifuWeb/src/assets/i18n/en.json b/apps/NwaifuWeb/src/assets/i18n/en.json index 289fc66..71acabf 100644 --- a/apps/NwaifuWeb/src/assets/i18n/en.json +++ b/apps/NwaifuWeb/src/assets/i18n/en.json @@ -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" } diff --git a/apps/NwaifuWeb/src/assets/i18n/ja.json b/apps/NwaifuWeb/src/assets/i18n/ja.json index e710822..5f47303 100644 --- a/apps/NwaifuWeb/src/assets/i18n/ja.json +++ b/apps/NwaifuWeb/src/assets/i18n/ja.json @@ -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": "すべて翻訳" } diff --git a/apps/NwaifuWeb/src/assets/i18n/ru.json b/apps/NwaifuWeb/src/assets/i18n/ru.json index 2b7209d..f8178cf 100644 --- a/apps/NwaifuWeb/src/assets/i18n/ru.json +++ b/apps/NwaifuWeb/src/assets/i18n/ru.json @@ -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": "Перевести все" }