Translation for Wireguard status page and reload/restart/export messages

This commit is contained in:
Eduardo Silva 2025-04-14 16:22:05 -03:00
parent e430580aba
commit 6836621b80
7 changed files with 131 additions and 30 deletions

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-14 15:34-0300\n" "POT-Creation-Date: 2025-04-14 16:18-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -26,6 +26,21 @@ msgstr "Idioma"
msgid "Change Language" msgid "Change Language"
msgstr "Alterar Idioma" msgstr "Alterar Idioma"
#: templates/access_denied.html:9
msgid "Access Denied"
msgstr "Acesso Negado"
#: templates/access_denied.html:12
msgid "Sorry, you do not have permission to access this page."
msgstr "Desculpe, você não tem permissão para acessar esta página."
#: templates/access_denied.html:12
msgid ""
"Please contact your system administrator if you believe this is an error."
msgstr ""
"Por favor, entre em contato com o administrador do sistema se você acredita "
"que isto é um erro."
#: templates/accounts/login.html:14 #: templates/accounts/login.html:14
msgid "Username" msgid "Username"
msgstr "Usuário" msgstr "Usuário"
@ -85,3 +100,90 @@ msgstr "Atualização Disponível"
#: templates/base.html:288 #: templates/base.html:288
msgid "Version" msgid "Version"
msgstr "Versão" msgstr "Versão"
#: templates/wireguard/wireguard_status.html:9
msgid "Update Configuration"
msgstr "Atualizar Configuração"
#: templates/wireguard/wireguard_status.html:16
msgid "Restart Wireguard service"
msgstr "Reiniciar o serviço Wireguard"
#: templates/wireguard/wireguard_status.html:24
msgid "Reload Wireguard service"
msgstr "Recarregar o serviço Wireguard"
#: templates/wireguard/wireguard_status.html:42
msgid "Instance Traffic"
msgstr "Tráfego da Instância"
#: templates/wireguard/wireguard_status.html:45
msgid "IP Address"
msgstr "Endereço IP"
#: templates/wireguard/wireguard_status.html:46
msgid "Public Address"
msgstr "Endereço Público"
#: templates/wireguard/wireguard_status.html:47
msgid "Port"
msgstr "Porta"
#: templates/wireguard/wireguard_status.html:48
msgid "Peers"
msgstr "Peers"
#: wireguard/views.py:96
msgid "WireGuard Status"
msgstr "Estado do WireGuard"
#: wireguard_tools/views.py:160
msgid ""
"Export successful!|WireGuard configuration files have been exported to /etc/"
"wireguard/."
msgstr ""
"Exportação bem-sucedida!|Os arquivos de configuração do WireGuard foram "
"exportados para /etc/wireguard/."
#: wireguard_tools/views.py:162
msgid ""
"Export successful!|WireGuard configuration files have been exported to /etc/"
"wireguard/. Don't forget to restart the interfaces."
msgstr ""
"Exportação bem-sucedida!|Os arquivos de configuração do WireGuard foram "
"exportados para /etc/wireguard/. Não se esqueça de reiniciar as interfaces."
#: wireguard_tools/views.py:255
msgid "Error reloading"
msgstr "Erro ao recarregar"
#: wireguard_tools/views.py:267
msgid "Error stopping"
msgstr "Erro ao parar"
#: wireguard_tools/views.py:272
msgid "Error starting"
msgstr "Erro ao iniciar"
#: wireguard_tools/views.py:279
msgid ""
"WARNING|Please note that the interface was reloaded, not restarted. Double-"
"check if the the peers are working as expected. If you find any issues, "
"please report them."
msgstr "Aviso|Por favor, note que a interface foi recarregada, sem ser reiniciada. Verifique se os peers estão funcionando como esperado. Se você encontrar algum problema, por favor, relate-o."
#: wireguard_tools/views.py:280
msgid "WireGuard reloaded|The WireGuard service has been reloaded."
msgstr "WireGuard recarregado|O serviço WireGuard foi recarregado."
#: wireguard_tools/views.py:282
msgid "WireGuard restarted|The WireGuard service has been restarted."
msgstr "WireGuard reiniciado|O serviço WireGuard foi reiniciado."
#: wireguard_tools/views.py:285
msgid "Errors encountered|Error processing one or more interfaces."
msgstr "Erros encontrados|Erro ao processar uma ou mais interfaces."
#: wireguard_tools/views.py:288
msgid "No interfaces found|No WireGuard interfaces were found to process."
msgstr "Nenhuma interface encontrada|Nenhuma interface WireGuard foi encontrada para processar."

View File

@ -1,15 +1,15 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load i18n %}
{% block content %} {% block content %}
<div class='row'> <div class='row'>
<div class='col-lg-6'> <div class='col-lg-6'>
<div class="card card-primary card-outline"> <div class="card card-primary card-outline">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Access Denied</h3> <h3 class="card-title">{% trans 'Access Denied' %}</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<p>Sorry, you do not have permission to access this page. <br>Please contact your system administrator if you believe this is an error.</p> <p>{% trans 'Sorry, you do not have permission to access this page.' %}<br>{% trans 'Please contact your system administrator if you believe this is an error.' %}</p>
</div> </div>
</div> </div>

View File

@ -6,7 +6,7 @@
if (parts.length > 1) { if (parts.length > 1) {
$(document).Toasts('create', { $(document).Toasts('create', {
{% if message.tags %} {% if message.tags %}
class: 'bg-{{ message.tags }}', class: '{% if message.tags == 'error' %}bg-danger{% else %}bg-{{ message.tags }}{% endif %}',
{% endif %} {% endif %}
title: parts[0], title: parts[0],
subtitle: '{{ message.tags }}', subtitle: '{{ message.tags }}',
@ -17,7 +17,7 @@
} else { } else {
$(document).Toasts('create', { $(document).Toasts('create', {
{% if message.tags %} {% if message.tags %}
class: 'bg-{{ message.tags }}', class: '{% if message.tags == 'error' %}bg-danger{% else %}bg-{{ message.tags }}{% endif %}',
{% endif %} {% endif %}
subtitle: '{{ message.tags }}', subtitle: '{{ message.tags }}',
body: parts[0], body: parts[0],

View File

@ -1,19 +1,19 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load i18n %}
{% block content %} {% block content %}
<div class='row'> <div class='row'>
<div class='col-lg-12'> <div class='col-lg-12'>
<div class="card card-primary card-outline"> <div class="card card-primary card-outline">
<div class="card-header"> <div class="card-header">
<a href='/tools/export_wireguard_config/' class='btn btn-outline-primary'>Update Configuration</a> <a href='/tools/export_wireguard_config/' class='btn btn-outline-primary'>{% trans 'Update Configuration' %}</a>
<a <a
{% if user_acl.enable_restart %} {% if user_acl.enable_restart %}
href='/tools/restart_wireguard/' class='btn btn-outline-primary' href='/tools/restart_wireguard/' class='btn btn-outline-primary'
{% else %} {% else %}
href='#' class='btn btn-outline-primary disabled' href='#' class='btn btn-outline-primary disabled'
{% endif %} {% endif %}
>Restart Wireguard service</a> >{% trans 'Restart Wireguard service' %}</a>
<a <a
{% if user_acl.enable_reload %} {% if user_acl.enable_reload %}
@ -21,7 +21,7 @@
{% else %} {% else %}
href='#' class='btn btn-outline-primary disabled' href='#' class='btn btn-outline-primary disabled'
{% endif %} {% endif %}
>Reload Wireguard service</a> >{% trans 'Reload Wireguard service' %}</a>
<div class="btn-group float-right" role="group" aria-label="Graph interval"> <div class="btn-group float-right" role="group" aria-label="Graph interval">
<a href="?period=6h" data-period="6h" class="btn btn-outline-primary">6h</a> <a href="?period=6h" data-period="6h" class="btn btn-outline-primary">6h</a>
@ -39,13 +39,13 @@
{% for wireguard_instance in wireguard_instances %} {% for wireguard_instance in wireguard_instances %}
<div class="col-md-6"> <div class="col-md-6">
<h3>wg{{ wireguard_instance.instance_id }} {% if wireguard_instance.name %}({{ wireguard_instance.name }}){% endif %}</h3> <h3>wg{{ wireguard_instance.instance_id }} {% if wireguard_instance.name %}({{ wireguard_instance.name }}){% endif %}</h3>
<p><b><i class="fas fa-chart-area nav-icon"></i> Instance Traffic</b></p> <p><b><i class="fas fa-chart-area nav-icon"></i> {% trans 'Instance Traffic' %}</b></p>
<img id="graphImg" src="/rrd/graph/?instance={{ wireguard_instance.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}" class="img-fluid" alt="No traffic history, please wait a few minutes" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);"> <img id="graphImg" src="/rrd/graph/?instance={{ wireguard_instance.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}" class="img-fluid" alt="No traffic history, please wait a few minutes" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
<p> <p>
<b><i class="fas fa-network-wired nav-icon"></i> IP Address: </b>{{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}<br> <b><i class="fas fa-network-wired nav-icon"></i> {% trans 'IP Address' %}: </b>{{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}<br>
<b><i class="fas fa-link nav-icon"></i> Public Address: </b>{{ wireguard_instance.hostname }}<br> <b><i class="fas fa-link nav-icon"></i> {% trans 'Public Address' %}: </b>{{ wireguard_instance.hostname }}<br>
<b><i class="fas fa-door-open nav-icon"></i> Port: </b>{{ wireguard_instance.listen_port }}<br> <b><i class="fas fa-door-open nav-icon"></i> {% trans 'Port' %}: </b>{{ wireguard_instance.listen_port }}<br>
<b><i class="fas fa-users-cog nav-icon"></i> Peers: </b>{{ wireguard_instance.peer_set.count }}<br> <b><i class="fas fa-users-cog nav-icon"></i> {% trans 'Peers' %}: </b>{{ wireguard_instance.peer_set.count }}<br>
</p> </p>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -4,6 +4,7 @@ from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db import models from django.db import models
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import gettext_lazy as _
from user_manager.models import UserAcl from user_manager.models import UserAcl
from wireguard.forms import WireGuardInstanceForm from wireguard.forms import WireGuardInstanceForm
@ -92,7 +93,7 @@ def legacy_view_wireguard_status(request):
@login_required @login_required
def view_wireguard_status(request): def view_wireguard_status(request):
user_acl = get_object_or_404(UserAcl, user=request.user) user_acl = get_object_or_404(UserAcl, user=request.user)
page_title = 'WireGuard Status' page_title = _("WireGuard Status")
if user_acl.peer_groups.exists(): if user_acl.peer_groups.exists():
wireguard_instances = [] wireguard_instances = []

View File

@ -9,6 +9,7 @@ from django.contrib.auth.decorators import login_required
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import Http404, get_object_or_404, redirect, render from django.shortcuts import Http404, get_object_or_404, redirect, render
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from dns.views import export_dns_configuration from dns.views import export_dns_configuration
from firewall.models import RedirectRule from firewall.models import RedirectRule
@ -156,9 +157,9 @@ def export_wireguard_configs(request):
with open(config_path, "w") as config_file: with open(config_path, "w") as config_file:
config_file.write(config_content) config_file.write(config_content)
if request.GET.get('action') == 'update_and_restart' or request.GET.get('action') == 'update_and_reload': if request.GET.get('action') == 'update_and_restart' or request.GET.get('action') == 'update_and_reload':
messages.success(request, "Export successful!|WireGuard configuration files have been exported to /etc/wireguard/.") messages.success(request, _("Export successful!|WireGuard configuration files have been exported to /etc/wireguard/."))
else: else:
messages.success(request, "Export successful!|WireGuard configuration files have been exported to /etc/wireguard/. Don't forget to restart the interfaces.") messages.success(request, _("Export successful!|WireGuard configuration files have been exported to /etc/wireguard/. Don't forget to restart the interfaces."))
if request.GET.get('action') == 'update_and_restart': if request.GET.get('action') == 'update_and_restart':
return redirect('/tools/restart_wireguard/?action=dismiss_warning') return redirect('/tools/restart_wireguard/?action=dismiss_warning')
elif request.GET.get('action') == 'update_and_reload': elif request.GET.get('action') == 'update_and_reload':
@ -251,7 +252,7 @@ def restart_wireguard_interfaces(request):
os.remove(temp_config_path) os.remove(temp_config_path)
if result.returncode != 0: if result.returncode != 0:
messages.warning(request, f"Error reloading {interface_name}|{result.stderr}") messages.warning(request, _('Error reloading') + f" {interface_name}|{result.stderr}")
error_count += 1 error_count += 1
else: else:
interface_count += 1 interface_count += 1
@ -263,31 +264,28 @@ def restart_wireguard_interfaces(request):
stop_command = f"wg-quick down {interface_name}" stop_command = f"wg-quick down {interface_name}"
stop_result = subprocess.run(stop_command, shell=True, capture_output=True, text=True) stop_result = subprocess.run(stop_command, shell=True, capture_output=True, text=True)
if stop_result.returncode != 0: if stop_result.returncode != 0:
messages.warning(request, f"Error stopping {interface_name}|{stop_result.stderr}") messages.warning(request, _("Error stopping") + f" {interface_name}|{stop_result.stderr}")
error_count += 1 error_count += 1
start_command = f"wg-quick up {interface_name}" start_command = f"wg-quick up {interface_name}"
start_result = subprocess.run(start_command, shell=True, capture_output=True, text=True) start_result = subprocess.run(start_command, shell=True, capture_output=True, text=True)
if start_result.returncode != 0: if start_result.returncode != 0:
messages.warning(request, f"Error starting {interface_name}|{start_result.stderr}") messages.warning(request, _("Error starting") + f" {interface_name}|{start_result.stderr}")
error_count += 1 error_count += 1
else: else:
interface_count += 1 interface_count += 1
if interface_count > 0 and error_count == 0: if interface_count > 0 and error_count == 0:
if mode == 'reload': if mode == 'reload':
messages.warning(request, "WARNING|Please note that the interface was reloaded, not restarted. Double-check if the the peers are working as expected. If you find any issues, please report them.") messages.warning(request, _("WARNING|Please note that the interface was reloaded, not restarted. Double-check if the the peers are working as expected. If you find any issues, please report them."))
verbose_mode = 'reloaded' messages.success(request, _("WireGuard reloaded|The WireGuard service has been reloaded."))
else: else:
verbose_mode = 'restarted' messages.success(request, _("WireGuard restarted|The WireGuard service has been restarted."))
if interface_count == 1:
messages.success(request, f"Interface {verbose_mode}|The WireGuard interface has been {verbose_mode}.")
else:
messages.success(request, f"Interfaces {verbose_mode}|{interface_count} WireGuard interfaces have been {verbose_mode}.")
elif error_count > 0: elif error_count > 0:
messages.warning(request, f"Errors encountered|There were errors {mode}ing some interfaces. See warnings for details.") messages.error(request, _("Errors encountered|Error processing one or more interfaces."))
if interface_count == 0 and error_count == 0: if interface_count == 0 and error_count == 0:
messages.info(request, f"No interfaces found|No WireGuard interfaces were found to {mode}.") messages.info(request, _("No interfaces found|No WireGuard interfaces were found to process."))
if request.GET.get('action') == 'dismiss_warning': if request.GET.get('action') == 'dismiss_warning':
for wireguard_instancee in WireGuardInstance.objects.filter(pending_changes=True): for wireguard_instancee in WireGuardInstance.objects.filter(pending_changes=True):
wireguard_instancee.pending_changes = False wireguard_instancee.pending_changes = False