Console app translation

This commit is contained in:
Eduardo Silva 2025-04-15 10:49:16 -03:00
parent be7d00803f
commit 1bd4c04475
4 changed files with 67 additions and 17 deletions

View file

@ -2,6 +2,7 @@ import subprocess
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render
from django.utils.translation import gettext_lazy as _
from user_manager.models import UserAcl
from wgwadmlibrary.tools import is_valid_ip_or_hostname
@ -10,7 +11,6 @@ from wireguard.models import WireGuardInstance
@login_required
def view_console(request):
page_title = 'Console'
user_acl = get_object_or_404(UserAcl, user=request.user)
if not user_acl.enable_console:
@ -22,50 +22,51 @@ def view_console(request):
if command_target:
if not is_valid_ip_or_hostname(command_target):
command_target = ''
page_title = _('Console') + ': '
if requested_command == 'iptables':
page_title = 'Console: iptables list'
page_title += _('iptables list')
bash_command = ['bash', '-c', 'iptables -L -nv ; iptables -t nat -L -nv']
elif requested_command == 'ifconfig':
page_title = 'Console: ifconfig'
page_title += 'ifconfig'
bash_command = ['bash', '-c', 'ifconfig']
elif requested_command == 'ps':
page_title = 'Console: running processes'
page_title += _('running processes')
bash_command = ['bash', '-c', 'ps faux']
elif requested_command == 'wgshow':
page_title = 'Console: WireGuard show'
page_title += _('WireGuard show')
bash_command = ['bash', '-c', 'wg show']
elif requested_command == 'freem':
page_title = 'Console: Memory usage'
page_title += _('Memory usage')
bash_command = ['bash', '-c', 'free -m']
elif requested_command == 'route':
page_title = 'Console: top'
page_title += _('Routing table')
bash_command = ['bash', '-c', 'route -n']
elif requested_command == 'top':
page_title = 'Console: top'
page_title += 'top'
bash_command = ['bash', '-c', 'top -b -n 1']
elif requested_command == 'ping':
page_title = 'Console: ping ' + command_target
page_title = 'ping ' + command_target
bash_command = ['bash', '-c', 'ping -c 4 ' + command_target]
elif requested_command == 'traceroute':
page_title = 'Console: traceroute ' + command_target
page_title += 'traceroute ' + command_target
bash_command = ['bash', '-c', 'traceroute ' + command_target]
elif requested_command == 'testdns':
page_title = 'Console: DNS container test script'
page_title += _('DNS container test script')
bash_command = ['/app/dns/scripts/test_dns_service.sh']
else:
page_title = _('Console') + ': ' + _('Invalid command')
bash_command = None
command_output = ''
command_success = False
if requested_command == 'ping' or requested_command == 'traceroute':
if not command_target:
command_output = requested_command + ': Invalid target'
command_output = requested_command + ': ' + _('Invalid target')
bash_command = None
command_success = False
if user_acl.enable_enhanced_filter and requested_command == 'wgshow':
command_output = 'Enhanced filter is enabled. This command is not available.'
command_output = _('Enhanced filter is enabled. This command is not available.')
bash_command = None
command_success = False
else:

Binary file not shown.

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-15 10:21-0300\n"
"POT-Creation-Date: 2025-04-15 10:45-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,6 +18,46 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: console/views.py:24 console/views.py:56
msgid "Console"
msgstr "Console"
#: console/views.py:26
msgid "iptables list"
msgstr "Lista de regras do iptables"
#: console/views.py:32
msgid "running processes"
msgstr "Processos em execução"
#: console/views.py:35
msgid "WireGuard show"
msgstr "Estado do WireGuard"
#: console/views.py:38
msgid "Memory usage"
msgstr "Uso de Memória"
#: console/views.py:41
msgid "Routing table"
msgstr "Tabela de Roteamento"
#: console/views.py:53
msgid "DNS container test script"
msgstr "Script de teste do contêiner DNS"
#: console/views.py:56
msgid "Invalid command"
msgstr "Comando inválido"
#: console/views.py:63
msgid "Invalid target"
msgstr "Destino inválido"
#: console/views.py:68
msgid "Enhanced filter is enabled. This command is not available."
msgstr "Filtro aprimorado está habilitado. Este comando não está disponível."
#: dns/forms.py:22
msgid "Primary Resolver"
msgstr "Servidor Primário"
@ -243,6 +283,14 @@ msgstr "Atualização Disponível"
msgid "Version"
msgstr "Versão"
#: templates/console/console.html:12
msgid "Clear"
msgstr "Limpar"
#: templates/console/console.html:27
msgid "Destination Hostname or IP Address"
msgstr "Endereço ou IP do Destino"
#: templates/dns/static_host_list.html:9
msgid "Static Host List"
msgstr "Lista de Endereços Estáticos"

View file

@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
@ -8,7 +9,7 @@
<div class="card-title">
<div class='row'>
<div class='col-md-12'>
<a href='/console/' class='btn btn-outline-primary'>Clear</a>
<a href='/console/' class='btn btn-outline-primary'>{% trans 'Clear' %}</a>
<a href='?command=iptables' class='btn btn-outline-primary'>iptables</a>
<a href='?command=ifconfig' class='btn btn-outline-primary'>ifconfig</a>
<a href='?command=ps' class='btn btn-outline-primary'>processes</a>
@ -23,7 +24,7 @@
<script>
function openCommandDialog(element) {
var command = element.getAttribute('data-command');
var destination = prompt("Host or IP address to " + command);
var destination = prompt("{% trans 'Destination Hostname or IP Address' %}");
if (destination) {
var url = "?command=" + command + "&target=" + encodeURIComponent(destination);
window.location.href = url;