From 6836621b8094bb8215ca942cc50b263c5f5ae84b Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 14 Apr 2025 16:22:05 -0300 Subject: [PATCH] Translation for Wireguard status page and reload/restart/export messages --- locale/pt_BR/LC_MESSAGES/django.mo | Bin 1489 -> 4040 bytes locale/pt_BR/LC_MESSAGES/django.po | 104 +++++++++++++++++++++- templates/access_denied.html | 6 +- templates/template_messages.html | 4 +- templates/wireguard/wireguard_status.html | 18 ++-- wireguard/views.py | 3 +- wireguard_tools/views.py | 26 +++--- 7 files changed, 131 insertions(+), 30 deletions(-) diff --git a/locale/pt_BR/LC_MESSAGES/django.mo b/locale/pt_BR/LC_MESSAGES/django.mo index fb309f4ab29dc5296b1ee1e5382aa58e7c5c438a..39cf0ab1207ac25917d81d4a65a484802544f885 100644 GIT binary patch literal 4040 zcmchZ$&VyQ6~@EHn4tj!gINp)V$3ouT{Rd9G<16gm#1rng6`^4FEf}6#AHTQr=69N zj?Aofqn3OyTr5i#2qc?>rNO`e(j4L7n<*hK2=1&mBm{o|2ZZ>&$gHJ3EGI}+)|ZhH z8S&otzIZSGaQd!qE3UKL_jB*vq130qXYb^X>npEO>P?^l-we72p91fp{ak}Dg6p(z zf!Dx4gHM5-yOdf1Ujg3&{t`R|{vLcS_$TlU;9tQvT&027f*9^B`U7TcE7_ z0{AZQhv0qSE8wTW--368r}>lh?gQ@yKL(2Zp9N+7Hu!EZ0pAFI4HUb+0gAof0bd7x zAN&D$3zYfxcqx8b@B(-P{4n@O@ay2+OwxhFXF=iZSFf+_{T+Ck_Fq7;;~${(-@{@u z-~C_;ei3{D{5dFgeHn7z0j3}(sHZ`eQqO>I1-}Uj-`@jqUH!emJNekqJ_XAA$3R&> z2j34q4ZaV23A_mY43zorz$oG86e#>Y(6raVGqm?X4IYBR>+_)Sb_*1KehP|xzW`qb ze+|A3e1@QjpD%)+0e=I20K6A6o&(Q=&=xcZsQ1br*W0g(t*iFR&VlOnUPgp@157)rq0AkHfq{MX?(fdba_5+ z7TRW!tFqF18z0vbN*8XRxLW8*fuf>_&%4s7(eghD=*JC`78L!^o6O z1?AhQl+Su~(1r<~ne2#w6_qVkbzVo^+pxQsXxvr{5j9*cUer6CeY?k!i`NYk1gNOD z+-%(PWOFC}`^SM_%vO&gw8chVZ2t5}r*1T2PrIrN!~6+zN=ZMpeu1 z=S+aJqW6%|7EDyNZiLd4S!GER(s`Tn=-#`>pu5$JTTR5*^q_O;3!N)neYLx@+uQE1 z>;$4)Tg51eTaQ$uqP6GN^vYnnwPPoVsHC-lZrAjq-Of&HYrD14(VyF1+v}?QrU}Z`tttfrtWvPy85B+R;Rc5aA#vYkxw!E;vce!GRiRXp5Ib0Jki0b^4MM5v+w4Gio=+T303jyk`1a0a`jVxgHF@*Uk?EP&%&HfK zX=orqD?< z$VSdV1(KD5sq^U#js%AD3oY3zWo6RjtBr;>k|KB6^wz|t^B%9~r7tLT-cjqeZ)N)F z4NpX8ld;y)Zd>y1RU>ZqPtDizdcUY-T1QQ8o}^a_W9=7(GE_($RULAmJLUi}3udU1 z5|3s13|+FYD>kdJJ{IQZI*v_SlY+_k@+kq9trrR;lu#{C4BHD85sg=Eg5Z5y{S$e=&sYEe delta 476 zcmX}oF-yZx5Ww+N)3ln#TB(S&Vx*uT4&v$*0;1qh@DoHD5=9$G701v)upkIN99-4G z-L7s5t`2UZlg`~8^nWpUaQVHL_T9V7^W2M>yie$t8c`wZroM(T7Ha=lhOEm3^g-rI1(z#9*DLjb{oW*l=kUr8& z;6G$adP~2CoR?biB_yPdG-r{NPY00che;V)n;}PJA>oEzJMir-o=0Bbt2ez~Yy#jw@75!`\n" "Language-Team: LANGUAGE \n" @@ -26,6 +26,21 @@ msgstr "Idioma" msgid "Change Language" 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 msgid "Username" msgstr "Usuário" @@ -85,3 +100,90 @@ msgstr "Atualização Disponível" #: templates/base.html:288 msgid "Version" 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." diff --git a/templates/access_denied.html b/templates/access_denied.html index de9b6a3..0412091 100644 --- a/templates/access_denied.html +++ b/templates/access_denied.html @@ -1,15 +1,15 @@ {% extends "base.html" %} - +{% load i18n %} {% block content %}
-

Access Denied

+

{% trans 'Access Denied' %}

-

Sorry, you do not have permission to access this page.
Please contact your system administrator if you believe this is an error.

+

{% trans 'Sorry, you do not have permission to access this page.' %}
{% trans 'Please contact your system administrator if you believe this is an error.' %}

diff --git a/templates/template_messages.html b/templates/template_messages.html index 94c3807..61b648e 100644 --- a/templates/template_messages.html +++ b/templates/template_messages.html @@ -6,7 +6,7 @@ if (parts.length > 1) { $(document).Toasts('create', { {% if message.tags %} - class: 'bg-{{ message.tags }}', + class: '{% if message.tags == 'error' %}bg-danger{% else %}bg-{{ message.tags }}{% endif %}', {% endif %} title: parts[0], subtitle: '{{ message.tags }}', @@ -17,7 +17,7 @@ } else { $(document).Toasts('create', { {% if message.tags %} - class: 'bg-{{ message.tags }}', + class: '{% if message.tags == 'error' %}bg-danger{% else %}bg-{{ message.tags }}{% endif %}', {% endif %} subtitle: '{{ message.tags }}', body: parts[0], diff --git a/templates/wireguard/wireguard_status.html b/templates/wireguard/wireguard_status.html index c470677..b46270e 100644 --- a/templates/wireguard/wireguard_status.html +++ b/templates/wireguard/wireguard_status.html @@ -1,19 +1,19 @@ {% extends "base.html" %} - +{% load i18n %} {% block content %}
- Update Configuration + {% trans 'Update Configuration' %} Restart Wireguard service + >{% trans 'Restart Wireguard service' %} Reload Wireguard service + >{% trans 'Reload Wireguard service' %}
6h @@ -39,13 +39,13 @@ {% for wireguard_instance in wireguard_instances %}

wg{{ wireguard_instance.instance_id }} {% if wireguard_instance.name %}({{ wireguard_instance.name }}){% endif %}

-

Instance Traffic

+

{% trans 'Instance Traffic' %}

No traffic history, please wait a few minutes

- IP Address: {{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}
- Public Address: {{ wireguard_instance.hostname }}
- Port: {{ wireguard_instance.listen_port }}
- Peers: {{ wireguard_instance.peer_set.count }}
+ {% trans 'IP Address' %}: {{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}
+ {% trans 'Public Address' %}: {{ wireguard_instance.hostname }}
+ {% trans 'Port' %}: {{ wireguard_instance.listen_port }}
+ {% trans 'Peers' %}: {{ wireguard_instance.peer_set.count }}

{% endfor %} diff --git a/wireguard/views.py b/wireguard/views.py index 438969a..acb3a6c 100644 --- a/wireguard/views.py +++ b/wireguard/views.py @@ -4,6 +4,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.db import models 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 wireguard.forms import WireGuardInstanceForm @@ -92,7 +93,7 @@ def legacy_view_wireguard_status(request): @login_required def view_wireguard_status(request): user_acl = get_object_or_404(UserAcl, user=request.user) - page_title = 'WireGuard Status' + page_title = _("WireGuard Status") if user_acl.peer_groups.exists(): wireguard_instances = [] diff --git a/wireguard_tools/views.py b/wireguard_tools/views.py index da6b3bc..2579d5d 100644 --- a/wireguard_tools/views.py +++ b/wireguard_tools/views.py @@ -9,6 +9,7 @@ from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.shortcuts import Http404, get_object_or_404, redirect, render from django.utils import timezone +from django.utils.translation import gettext_lazy as _ from dns.views import export_dns_configuration from firewall.models import RedirectRule @@ -156,9 +157,9 @@ def export_wireguard_configs(request): with open(config_path, "w") as config_file: config_file.write(config_content) 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: - 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': return redirect('/tools/restart_wireguard/?action=dismiss_warning') elif request.GET.get('action') == 'update_and_reload': @@ -251,7 +252,7 @@ def restart_wireguard_interfaces(request): os.remove(temp_config_path) 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 else: interface_count += 1 @@ -263,31 +264,28 @@ def restart_wireguard_interfaces(request): stop_command = f"wg-quick down {interface_name}" stop_result = subprocess.run(stop_command, shell=True, capture_output=True, text=True) 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 start_command = f"wg-quick up {interface_name}" start_result = subprocess.run(start_command, shell=True, capture_output=True, text=True) 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 else: interface_count += 1 if interface_count > 0 and error_count == 0: 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.") - verbose_mode = 'reloaded' + 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.success(request, _("WireGuard reloaded|The WireGuard service has been reloaded.")) else: - verbose_mode = '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}.") + messages.success(request, _("WireGuard restarted|The WireGuard service has been restarted.")) + 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: - 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': for wireguard_instancee in WireGuardInstance.objects.filter(pending_changes=True): wireguard_instancee.pending_changes = False