refactor: add translations for system status

This commit is contained in:
Shishkevich D. 2025-04-04 08:12:21 +00:00
parent e75cec719b
commit e132b29485
15 changed files with 238 additions and 55 deletions

View file

@ -558,10 +558,6 @@ class CPUFormatter {
static cpuSpeedFormat(speed) {
return speed > 1000 ? (speed / 1000).toFixed(2) + " GHz" : speed.toFixed(2) + " MHz";
}
static cpuCoreFormat(cores) {
return cores === 1 ? "1 Core" : cores + " Cores";
}
}
class TimeFormatter {

View file

@ -95,7 +95,7 @@
<template>
<a-row v-if="!status.isLoaded">
<a-card hoverable :style="{ textAlign: 'center', padding: '30px 0', marginTop: '10px', background: 'transparent' }">
<a-spin tip="Loading..."></a-spin>
<a-spin tip='{{ i18n "loading" }}'></a-spin>
</a-card>
</a-row>
<a-row v-else>
@ -108,20 +108,31 @@
<a-progress type="dashboard" status="normal"
:stroke-color="status.cpu.color"
:percent="status.cpu.percent"></a-progress>
<div><b>CPU:</b> [[ CPUFormatter.cpuCoreFormat(status.cpuCores) ]] <a-tooltip>
<div>
<span>{{ i18n "pages.index.cpu" }}</span>
<a-tooltip>
<a-icon type="area-chart"></a-icon>
<template slot="title">
<div><b>Logical Processors:</b> [[ (status.logicalPro) ]]</div>
<div><b>Speed:</b> [[ CPUFormatter.cpuSpeedFormat(status.cpuSpeedMhz) ]]</div>
<div><b>{{ i18n "pages.index.cpuCores" }}:</b> [[ (status.cpuCores) ]]</div>
<div><b>{{ i18n "pages.index.logicalProcessors" }}:</b> [[ (status.logicalPro) ]]</div>
<div><b>{{ i18n "pages.index.frequency" }}:</b> [[ CPUFormatter.cpuSpeedFormat(status.cpuSpeedMhz) ]]</div>
</template>
</a-tooltip></div>
</a-tooltip>
</div>
</a-col>
<a-col :span="12" :style="{ textAlign: 'center' }">
<a-progress type="dashboard" status="normal"
:stroke-color="status.mem.color"
:percent="status.mem.percent"></a-progress>
<div>
<b>{{ i18n "pages.index.memory"}}:</b> [[ SizeFormatter.sizeFormat(status.mem.current) ]] / [[ SizeFormatter.sizeFormat(status.mem.total) ]]
<span>{{ i18n "pages.index.memory" }}</span>
<a-tooltip>
<a-icon type="area-chart"></a-icon>
<template slot="title">
<div><b>{{ i18n "pages.index.storageUsed" }}:</b> [[ SizeFormatter.sizeFormat(status.mem.current) ]]</div>
<div><b>{{ i18n "pages.index.storageTotal" }}:</b> [[ SizeFormatter.sizeFormat(status.mem.total) ]]</div>
</template>
</a-tooltip>
</div>
</a-col>
</a-row>
@ -133,7 +144,14 @@
:stroke-color="status.swap.color"
:percent="status.swap.percent"></a-progress>
<div>
<b>Swap:</b> [[ SizeFormatter.sizeFormat(status.swap.current) ]] / [[ SizeFormatter.sizeFormat(status.swap.total) ]]
<span>{{ i18n "pages.index.swap" }}</span>
<a-tooltip>
<a-icon type="area-chart"></a-icon>
<template slot="title">
<div><b>{{ i18n "pages.index.storageUsed" }}:</b> [[ SizeFormatter.sizeFormat(status.swap.current) ]]</div>
<div><b>{{ i18n "pages.index.storageTotal" }}:</b> [[ SizeFormatter.sizeFormat(status.swap.total) ]]</div>
</template>
</a-tooltip>
</div>
</a-col>
<a-col :span="12" :style="{ textAlign: 'center' }">
@ -141,7 +159,14 @@
:stroke-color="status.disk.color"
:percent="status.disk.percent"></a-progress>
<div>
<b>{{ i18n "pages.index.hard"}}:</b> [[ SizeFormatter.sizeFormat(status.disk.current) ]] / [[ SizeFormatter.sizeFormat(status.disk.total) ]]
<span>{{ i18n "pages.index.storage" }}</span>
<a-tooltip>
<a-icon type="area-chart"></a-icon>
<template slot="title">
<div><b>{{ i18n "pages.index.storageUsed" }}:</b> [[ SizeFormatter.sizeFormat(status.disk.current) ]]</div>
<div><b>{{ i18n "pages.index.storageTotal" }}:</b> [[ SizeFormatter.sizeFormat(status.disk.total) ]]</div>
</template>
</a-tooltip>
</div>
</a-col>
</a-row>
@ -160,18 +185,25 @@
</a-space>
</template>
<template #extra>
<template v-if="status.xray.state != State.Error">
<a-badge status="processing" class="running-animation" :text="status.xray.state" :color="status.xray.color" :style="{ textTransform: 'capitalize' }"/>
<template v-if="status.xray.state != 'error'">
<a-badge status="processing" class="running-animation" :text="status.xray.stateMsg" :color="status.xray.color"/>
</template>
<template v-else>
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
<span slot="title" :style="{ fontSize: '12pt' }">An error occurred while running Xray
<a-tag color="purple" :style="{ cursor: 'pointer', float: 'right' }" @click="openLogs()">{{ i18n "pages.index.logs" }}</a-tag>
<span slot="title">
<a-row type="flex" align="middle" justify="space-between">
<a-col>
<span>{{ i18n "pages.index.xrayErrorPopoverTitle" }}</span>
</a-col>
<a-col>
<a-icon type="bars" :style="{ cursor: 'pointer', float: 'right' }" @click="openLogs()"></a-tag>
</a-col>
</a-row>
</span>
<template slot="content">
<p :style="{ maxWidth: '400px' }" v-for="line in status.xray.errorMsg.split('\n')">[[ line ]]</p>
<span :style="{ maxWidth: '400px' }" v-for="line in status.xray.errorMsg.split('\n')">[[ line ]]</span>
</template>
<a-badge :text="status.xray.state" :color="status.xray.color" :style="{ textTransform: 'capitalize' }"/>
<a-badge :text="status.xray.stateMsg" :color="status.xray.color"/>
</a-popover>
</template>
</template>
@ -237,8 +269,8 @@
</a-col>
<a-col :sm="24" :lg="12">
<a-card title='{{ i18n "usage"}}' hoverable>
<a-tag color="green"> RAM: [[ SizeFormatter.sizeFormat(status.appStats.mem) ]] </a-tag>
<a-tag color="green"> Threads: [[ status.appStats.threads ]] </a-tag>
<a-tag color="green"> {{ i18n "pages.index.memory" }}: [[ SizeFormatter.sizeFormat(status.appStats.mem) ]] </a-tag>
<a-tag color="green"> {{ i18n "pages.index.threads" }}: [[ status.appStats.threads ]] </a-tag>
</a-card>
</a-col>
<a-col :sm="24" :lg="12">
@ -427,13 +459,6 @@
{{template "component/aCustomStatistic" .}}
{{template "modals/textModal"}}
<script>
const State = {
Running: "running",
Stop: "stop",
Error: "error",
}
Object.freeze(State);
class CurTotal {
constructor(current, total) {
@ -478,7 +503,8 @@
this.uptime = 0;
this.appUptime = 0;
this.appStats = {threads: 0, mem: 0, uptime: 0};
this.xray = { state: State.Stop, errorMsg: "", version: "", color: "" };
this.xray = { state: 'stop', stateMsg: "", errorMsg: "", version: "", color: "" };
if (data == null) {
return;
@ -503,17 +529,22 @@
this.appStats = data.appStats;
this.xray = data.xray;
switch (this.xray.state) {
case State.Running:
case 'running':
this.xray.color = "green";
this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusRunning" }}';
break;
case State.Stop:
case 'stop':
this.xray.color = "orange";
this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusStop" }}';
break;
case State.Error:
case 'error':
this.xray.color = "red";
this.xray.stateMsg ='{{ i18n "pages.index.xrayStatusError" }}';
break;
default:
this.xray.color = "gray";
this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusUnknown" }}';
break;
}
}
}

View file

@ -66,9 +66,9 @@
<a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button>
<a-popover v-if="restartResult"
:overlay-class-name="themeSwitcher.currentTheme">
<span slot="title" :style="{ fontSize: '12pt' }">Error in running xray-core</span>
<span slot="title">{{ i18n "pages.index.xrayErrorPopoverTitle" }}</span>
<template slot="content">
<p :style="{ maxWidth: '400px' }" v-for="line in restartResult.split('\n')">[[ line ]]</p>
<span :style="{ maxWidth: '400px' }" v-for="line in restartResult.split('\n')">[[ line ]]</span>
</template>
<a-icon type="question-circle"></a-icon>
</a-popover>

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Overview"
"cpu" = "CPU"
"cpuCores" = "Cores"
"logicalProcessors" = "Logical Processors"
"frequency" = "Frequency"
"swap" = "Swap"
"storage" = "Storage"
"storageUsed" = "Used"
"storageTotal" = "Total"
"memory" = "RAM"
"hard" = "Disk"
"threads" = "Threads"
"xrayStatus" = "Xray"
"stopXray" = "Stop"
"restartXray" = "Restart"
"xraySwitch" = "Version"
"xraySwitchClick" = "Choose the version you want to switch to."
"xraySwitchClickDesk" = "Choose carefully, as older versions may not be compatible with current configurations."
"xrayStatusUnknown" = "Unknown"
"xrayStatusRunning" = "Running"
"xrayStatusStop" = "Stop"
"xrayStatusError" = "Error"
"xrayErrorPopoverTitle" = "An error occurred while running Xray"
"operationHours" = "Uptime"
"systemLoad" = "System Load"
"systemLoadDesc" = "System load average for the past 1, 5, and 15 minutes"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Estado del Sistema"
"memory" = "Memoria"
"hard" = "Disco Duro"
"cpu" = "CPU"
"cpuCores" = "Núcleos"
"logicalProcessors" = "Procesadores lógicos"
"frequency" = "Frecuencia"
"swap" = "Intercambio"
"storage" = "Almacenamiento"
"storageUsed" = "Usado"
"storageTotal" = "Total"
"memory" = "RAM"
"threads" = "Hilos"
"xrayStatus" = "Xray"
"stopXray" = "Detener"
"restartXray" = "Reiniciar"
"xraySwitch" = "Versión"
"xraySwitchClick" = "Elige la versión a la que deseas cambiar."
"xraySwitchClickDesk" = "Elige sabiamente, ya que las versiones anteriores pueden no ser compatibles con las configuraciones actuales."
"xrayStatusUnknown" = "Desconocido"
"xrayStatusRunning" = "En ejecución"
"xrayStatusStop" = "Detenido"
"xrayStatusError" = "Error"
"xrayErrorPopoverTitle" = "Se produjo un error al ejecutar Xray"
"operationHours" = "Tiempo de Funcionamiento"
"systemLoad" = "Carga del Sistema"
"systemLoadDesc" = "promedio de carga del sistema en los últimos 1, 5 y 15 minutos"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "نمای کلی"
"memory" = "RAM"
"hard" = "Disk"
"cpu" = "پردازنده"
"cpuCores" = "هسته‌ها"
"logicalProcessors" = "پردازنده‌های منطقی"
"frequency" = "فرکانس"
"swap" = "سواپ"
"storage" = "ذخیره‌سازی"
"storageUsed" = "استفاده شده"
"storageTotal" = "کل"
"memory" = "حافظه رم"
"threads" = "رشته‌ها"
"xrayStatus" = "ایکس‌ری"
"stopXray" = "توقف"
"restartXray" = "شروع‌مجدد"
"xraySwitch" = "‌نسخه"
"xraySwitchClick" = "نسخه مورد نظر را انتخاب کنید"
"xraySwitchClickDesk" = "لطفا بادقت انتخاب کنید. درصورت انتخاب نسخه قدیمی‌تر، امکان ناهماهنگی با پیکربندی فعلی وجود دارد"
"xrayStatusUnknown" = "ناشناخته"
"xrayStatusRunning" = "در حال اجرا"
"xrayStatusStop" = "متوقف"
"xrayStatusError" = "خطا"
"xrayErrorPopoverTitle" = "خطا در هنگام اجرای Xray رخ داد"
"operationHours" = "مدت‌کارکرد"
"systemLoad" = "بارسیستم"
"systemLoadDesc" = "میانگین بار سیستم برای 1، 5 و 15 دقیقه گذشته"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Ikhtisar"
"cpu" = "CPU"
"cpuCores" = "Inti"
"logicalProcessors" = "Prosesor logis"
"frequency" = "Frekuensi"
"swap" = "Swap"
"storage" = "Penyimpanan"
"storageUsed" = "Digunakan"
"storageTotal" = "Total"
"memory" = "RAM"
"hard" = "Disk"
"threads" = "Thread"
"xrayStatus" = "Xray"
"stopXray" = "Stop"
"restartXray" = "Restart"
"xraySwitch" = "Versi"
"xraySwitchClick" = "Pilih versi yang ingin Anda pindah."
"xraySwitchClickDesk" = "Pilih dengan hati-hati, karena versi yang lebih lama mungkin tidak kompatibel dengan konfigurasi saat ini."
"xrayStatusUnknown" = "Tidak diketahui"
"xrayStatusRunning" = "Berjalan"
"xrayStatusStop" = "Berhenti"
"xrayStatusError" = "Kesalahan"
"xrayErrorPopoverTitle" = "Terjadi kesalahan saat menjalankan Xray"
"operationHours" = "Waktu Aktif"
"systemLoad" = "Beban Sistem"
"systemLoadDesc" = "Rata-rata beban sistem selama 1, 5, dan 15 menit terakhir"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "システムステータス"
"memory" = "メモリ"
"hard" = "ハードディスク"
"cpu" = "CPU"
"cpuCores" = "コア"
"logicalProcessors" = "論理プロセッサ"
"frequency" = "周波数"
"swap" = "スワップ"
"storage" = "ストレージ"
"storageUsed" = "使用済み"
"storageTotal" = "合計"
"memory" = "RAM"
"threads" = "スレッド"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "再起動"
"xraySwitch" = "バージョン"
"xraySwitchClick" = "切り替えるバージョンを選択してください"
"xraySwitchClickDesk" = "慎重に選択してください。古いバージョンは現在の設定と互換性がない可能性があります。"
"xrayStatusUnknown" = "不明"
"xrayStatusRunning" = "実行中"
"xrayStatusStop" = "停止"
"xrayStatusError" = "エラー"
"xrayErrorPopoverTitle" = "Xrayの実行中にエラーが発生しました"
"operationHours" = "システム稼働時間"
"systemLoad" = "システム負荷"
"systemLoadDesc" = "過去1、5、15分間のシステム平均負荷"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Visão Geral"
"memory" = "Memória RAM"
"hard" = "Disco"
"cpu" = "CPU"
"cpuCores" = "Núcleos"
"logicalProcessors" = "Processadores lógicos"
"frequency" = "Frequência"
"swap" = "Swap"
"storage" = "Armazenamento"
"storageUsed" = "Usado"
"storageTotal" = "Total"
"memory" = "RAM"
"threads" = "Threads"
"xrayStatus" = "Xray"
"stopXray" = "Parar"
"restartXray" = "Reiniciar"
"xraySwitch" = "Versão"
"xraySwitchClick" = "Escolha a versão para a qual deseja alternar."
"xraySwitchClickDesk" = "Escolha com cuidado, pois versões mais antigas podem não ser compatíveis com as configurações atuais."
"xrayStatusUnknown" = "Desconhecido"
"xrayStatusRunning" = "Em execução"
"xrayStatusStop" = "Parado"
"xrayStatusError" = "Erro"
"xrayErrorPopoverTitle" = "Ocorreu um erro ao executar o Xray"
"operationHours" = "Tempo de Atividade"
"systemLoad" = "Carga do Sistema"
"systemLoadDesc" = "Média de carga do sistema nos últimos 1, 5 e 15 minutos"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Статус системы"
"memory" = "Память"
"hard" = "Жесткий диск"
"cpu" = "ЦП"
"cpuCores" = "Ядра"
"logicalProcessors" = "Логические процессоры"
"frequency" = "Частота"
"swap" = "Файл подкачки"
"storage" = "Хранилище"
"storageUsed" = "Использовано"
"storageTotal" = "Всего"
"memory" = "ОЗУ"
"threads" = "Потоки"
"xrayStatus" = "Xray"
"stopXray" = "Остановить"
"restartXray" = "Перезапустить"
"xraySwitch" = "Выбор версии"
"xraySwitchClick" = "Выберите желаемую версию"
"xraySwitchClickDesk" = "Обратите внимание: старые версии могут не поддерживать текущие настройки"
"xrayStatusUnknown" = "Неизвестно"
"xrayStatusRunning" = "Запущен"
"xrayStatusStop" = "Остановлен"
"xrayStatusError" = "Ошибка"
"xrayErrorPopoverTitle" = "Произошла ошибка при запуске Xray"
"operationHours" = "Время работы системы"
"systemLoad" = "Нагрузка на систему"
"systemLoadDesc" = "Средняя загрузка системы за последние 1, 5 и 15 минут"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Genel Bakış"
"cpu" = "İşlemci"
"cpuCores" = "Çekirdekler"
"logicalProcessors" = "Mantıksal işlemciler"
"frequency" = "Frekans"
"swap" = "Takas"
"storage" = "Depolama"
"storageUsed" = "Kullanılan"
"storageTotal" = "Toplam"
"memory" = "RAM"
"hard" = "Disk"
"threads" = "İş parçacıkları"
"xrayStatus" = "Xray"
"stopXray" = "Durdur"
"restartXray" = "Yeniden Başlat"
"xraySwitch" = "Sürüm"
"xraySwitchClick" = "Geçiş yapmak istediğiniz sürümü seçin."
"xraySwitchClickDesk" = "Dikkatli seçin, eski sürümler mevcut yapılandırmalarla uyumlu olmayabilir."
"xrayStatusUnknown" = "Bilinmiyor"
"xrayStatusRunning" = "Çalışıyor"
"xrayStatusStop" = "Durduruldu"
"xrayStatusError" = "Hata"
"xrayErrorPopoverTitle" = "Xray çalıştırılırken bir hata oluştu"
"operationHours" = "Çalışma Süresi"
"systemLoad" = "Sistem Yükü"
"systemLoadDesc" = "Geçmiş 1, 5 ve 15 dakika için sistem yük ortalaması"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Огляд"
"memory" = "Пам'ять"
"hard" = "Диск"
"cpu" = "ЦП"
"cpuCores" = "Ядра"
"logicalProcessors" = "Логічні процесори"
"frequency" = "Частота"
"swap" = "Своп"
"storage" = "Сховище"
"storageUsed" = "Використано"
"storageTotal" = "Всього"
"memory" = "ОЗП"
"threads" = "Потоки"
"xrayStatus" = "Xray"
"stopXray" = "Зупинити"
"restartXray" = "Перезапустити"
"xraySwitch" = "Версія"
"xraySwitchClick" = "Виберіть версію, на яку ви хочете перейти."
"xraySwitchClickDesk" = "Вибирайте уважно, оскільки старіші версії можуть бути несумісними з поточними конфігураціями."
"xrayStatusUnknown" = "Невідомо"
"xrayStatusRunning" = "Запущено"
"xrayStatusStop" = "Зупинено"
"xrayStatusError" = "Помилка"
"xrayErrorPopoverTitle" = "Під час роботи Xray сталася помилка"
"operationHours" = "Час роботи"
"systemLoad" = "Завантаження системи"
"systemLoadDesc" = "Середнє завантаження системи за останні 1, 5 і 15 хвилин"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "Trạng thái hệ thống"
"memory" = "Ram"
"hard" = "Dung lượng"
"cpu" = "CPU"
"cpuCores" = "Nhân"
"logicalProcessors" = "Bộ xử lý logic"
"frequency" = "Tần số"
"swap" = "Swap"
"storage" = "Lưu trữ"
"storageUsed" = "Đã dùng"
"storageTotal" = "Tổng"
"memory" = "RAM"
"threads" = "Luồng"
"xrayStatus" = "Xray"
"stopXray" = "Dừng lại"
"restartXray" = "Khởi động lại"
"xraySwitch" = "Phiên bản"
"xraySwitchClick" = "Chọn phiên bản mà bạn muốn chuyển đổi sang."
"xraySwitchClickDesk" = "Hãy lựa chọn thận trọng, vì các phiên bản cũ có thể không tương thích với các cấu hình hiện tại."
"xrayStatusUnknown" = "Không xác định"
"xrayStatusRunning" = "Đang chạy"
"xrayStatusStop" = "Dừng"
"xrayStatusError" = "Lỗi"
"xrayErrorPopoverTitle" = "Đã xảy ra lỗi khi chạy Xray"
"operationHours" = "Thời gian hoạt động"
"systemLoad" = "Tải hệ thống"
"systemLoadDesc" = "trung bình tải hệ thống trong 1, 5 và 15 phút qua"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "系统状态"
"cpu" = "CPU"
"cpuCores" = "核心"
"logicalProcessors" = "逻辑处理器"
"frequency" = "频率"
"swap" = "交换分区"
"storage" = "存储"
"storageUsed" = "已用"
"storageTotal" = "总计"
"memory" = "内存"
"hard" = "磁盘"
"threads" = "线程"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "重启"
"xraySwitch" = "版本"
"xraySwitchClick" = "选择你要切换到的版本"
"xraySwitchClickDesk" = "请谨慎选择,因为较旧版本可能与当前配置不兼容"
"xrayStatusUnknown" = "未知"
"xrayStatusRunning" = "运行中"
"xrayStatusStop" = "停止"
"xrayStatusError" = "错误"
"xrayErrorPopoverTitle" = "运行Xray时发生错误"
"operationHours" = "系统正常运行时间"
"systemLoad" = "系统负载"
"systemLoadDesc" = "过去 1、5 和 15 分钟的系统平均负载"

View file

@ -91,14 +91,27 @@
[pages.index]
"title" = "系統狀態"
"cpu" = "CPU"
"cpuCores" = "核心"
"logicalProcessors" = "邏輯處理器"
"frequency" = "頻率"
"swap" = "交換空間"
"storage" = "儲存"
"storageUsed" = "已使用"
"storageTotal" = "總計"
"memory" = "記憶體"
"hard" = "磁碟"
"threads" = "執行緒"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "重啟"
"xraySwitch" = "版本"
"xraySwitchClick" = "選擇你要切換到的版本"
"xraySwitchClickDesk" = "請謹慎選擇,因為較舊版本可能與當前配置不相容"
"xrayStatusUnknown" = "未知"
"xrayStatusRunning" = "運行中"
"xrayStatusStop" = "停止"
"xrayStatusError" = "錯誤"
"xrayErrorPopoverTitle" = "執行Xray時發生錯誤"
"operationHours" = "系統正常執行時間"
"systemLoad" = "系統負載"
"systemLoadDesc" = "過去 1、5 和 15 分鐘的系統平均負載"