From 0bdf28fcdd3c4ba0756b37a3c6cde67443163ed2 Mon Sep 17 00:00:00 2001 From: Monviech <79600909+Monviech@users.noreply.github.com> Date: Tue, 14 May 2024 16:05:15 +0200 Subject: [PATCH] www/caddy: Added lang() function for all user exposed text for translation (#3978) --- .../mvc/app/views/OPNsense/Caddy/general.volt | 22 +-- .../views/OPNsense/Caddy/reverse_proxy.volt | 156 +++++++++--------- 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/general.volt b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/general.volt index 7e704763d..3ee96f862 100644 --- a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/general.volt +++ b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/general.volt @@ -72,12 +72,12 @@ if (data && data['status'].toLowerCase() === 'ok') { dfObj.resolve(); // Configuration is valid } else { - showAlert(data['message'], "Validation Error"); + showAlert(data['message'], "{{ lang._('Validation Error') }}"); dfObj.reject(); // Configuration is invalid } }, error: function(xhr, status, error) { - showAlert("Validation request failed: " + error, "Validation Error"); + showAlert("{{ lang._('Validation request failed: ') }}" + error, "{{ lang._('Validation Error') }}"); dfObj.reject(); // AJAX request failed } }); @@ -85,7 +85,7 @@ false, // disable_dialog: Show the dialog with the validation error function(errorData) { // callback_fail: What to do when save fails // Handle failure due to validation errors or other issues - showAlert("Configuration save failed: " + (errorData.message || "Validation Error"), "Error"); + showAlert("{{ lang._('Configuration save failed: ') }}" + (errorData.message || "{{ lang._('Validation Error') }}"), "{{ lang._('Error') }}"); dfObj.reject(); // Reject the deferred object to stop the reconfigure action } ); @@ -95,11 +95,11 @@ onAction: function(data, status) { if (status === "success" && data && data['status'].toLowerCase() === 'ok') { // Configuration is valid and applied, possibly refresh UI or notify user - showAlert("Configuration applied successfully.", "Apply Success"); + showAlert("{{ lang._('Configuration applied successfully.') }}", "{{ lang._('Apply Success') }}"); updateServiceControlUI('caddy'); } else { // Handle errors or unsuccessful application - showAlert("An error occurred while applying the configuration.", "Error"); + showAlert("{{ lang._('An error occurred while applying the configuration.') }}", "{{ lang._('Error') }}"); } } }); @@ -111,12 +111,12 @@ // Save the form before continuing saveFormToEndpoint("/api/caddy/general/set", 'frm_GeneralSettings', function() { // callback_ok: What to do when save is successful - showAlert("Configuration saved successfully. Please don't forget to apply the configuration.", "Save Successful"); + showAlert("{{ lang._('Configuration saved successfully. Please do not forget to apply the configuration.') }}", "{{ lang._('Save Success') }}"); dfObj.resolve(); }, false, // disable_dialog: Show the dialog with the validation error function(errorData) { // callback_fail: What to do when save fails - showAlert("Configuration save failed: " + (errorData.message || "Validation Error"), "Error"); + showAlert("{{ lang._('Configuration save failed: ') }}" + (errorData.message || "{{ lang._('Validation Error') }}"), "{{ lang._('Error') }}"); dfObj.reject(); } ); @@ -134,10 +134,10 @@ diff --git a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt index ec5e4b7dc..0afbf51bb 100644 --- a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt +++ b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt @@ -136,13 +136,13 @@ dfObj.resolve(); } else { // If configuration is invalid, show alert and reject the Deferred object - showAlert(data['message'], "Validation Failed"); + showAlert(data['message'], "{{ lang._('Validation Failed') }}"); dfObj.reject(); } }, error: function(xhr, status, error) { // On AJAX error, show alert and reject the Deferred object - showAlert("Validation request failed: " + error, "Error"); + showAlert("{{ lang._('Validation request failed: ') }}" + error, "{{ lang._('Error') }}"); dfObj.reject(); } }); @@ -153,10 +153,10 @@ // Check if the action was successful if (status === "success" && data && data['status'].toLowerCase() === 'ok') { // Update only the service control UI for 'caddy' - showAlert("Configuration applied successfully.", "Apply Success"); + showAlert("{{ lang._('Configuration applied successfully.') }}", "{{ lang._('Apply Success') }}"); updateServiceControlUI('caddy'); } else { - console.error("Action was not successful or an error occurred:", data); + console.error("{{ lang._('Action was not successful or an error occurred:') }}", data); } } }); @@ -181,7 +181,7 @@ select.selectpicker('refresh'); // Refresh selectpicker to update the UI }, error: function() { - $('#reverseFilter').html('').selectpicker('refresh'); + $('#reverseFilter').html('').selectpicker('refresh'); } }); } @@ -227,17 +227,17 @@
-
@@ -246,24 +246,24 @@
-

Domains

+

{{ lang._('Domains') }}

- - - - - - - - - - - - - + + + + + + + + + + + + + @@ -282,22 +282,22 @@
-

Subdomains

+

{{ lang._('Subdomains') }}

IDEnabledDomainPortAccess ListBasic AuthDNS-01 challengeDynamic DNSHTTP Access LogCustom CertificateHTTP-01 redirectionDescriptionCommands{{ lang._('ID') }}{{ lang._('Enabled') }}{{ lang._('Domain') }}{{ lang._('Port') }}{{ lang._('Access List') }}{{ lang._('Basic Auth') }}{{ lang._('DNS-01 challenge') }}{{ lang._('Dynamic DNS') }}{{ lang._('HTTP Access Log') }}{{ lang._('Custom Certificate') }}{{ lang._('HTTP-01 redirection') }}{{ lang._('Description') }}{{ lang._('Commands') }}
- - - - - - - - - - - + + + + + + + + + + + @@ -319,29 +319,29 @@
-

Handlers

+

{{ lang._('Handlers') }}

IDEnabledDomainSubdomainPortAccess ListBasic AuthDynamic DNSHTTP-01 redirectionDescriptionCommands{{ lang._('ID') }}{{ lang._('Enabled') }}{{ lang._('Domain') }}{{ lang._('Subdomain') }}{{ lang._('Port') }}{{ lang._('Access List') }}{{ lang._('Basic Auth') }}{{ lang._('Dynamic DNS') }}{{ lang._('HTTP-01 redirection') }}{{ lang._('Description') }}{{ lang._('Commands') }}
- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -364,19 +364,19 @@
-

Access Lists

+

{{ lang._('Access Lists') }}

IDEnabledDomainSubdomainHandle TypeHandle PathHeaderUpstream DomainUpstream PortUpstream PathFail DurationTLSTLS CATLS Server NameNTLMTLS Insecure Skip VerifyDescriptionCommands{{ lang._('ID') }}{{ lang._('Enabled') }}{{ lang._('Domain') }}{{ lang._('Subdomain') }}{{ lang._('Handle Type') }}{{ lang._('Handle Path') }}{{ lang._('Header') }}{{ lang._('Upstream Domain') }}{{ lang._('Upstream Port') }}{{ lang._('Upstream Path') }}{{ lang._('Fail Duration') }}{{ lang._('TLS') }}{{ lang._('TLS CA') }}{{ lang._('TLS Server Name') }}{{ lang._('NTLM') }}{{ lang._('TLS Insecure Skip Verify') }}{{ lang._('Description') }}{{ lang._('Commands') }}
- - - - - - - - + + + + + + + + @@ -396,15 +396,15 @@
-

Basic Auth

+

{{ lang._('Basic Auth') }}

IDNameClient IPsInvertHTTP CodeHTTP MessageDescriptionCommands{{ lang._('ID') }}{{ lang._('Name') }}{{ lang._('Client IPs') }}{{ lang._('Invert') }}{{ lang._('HTTP Code') }}{{ lang._('HTTP Message') }}{{ lang._('Description') }}{{ lang._('Commands') }}
- - - - + + + + @@ -426,18 +426,18 @@
-

Headers

+

{{ lang._('Headers') }}

IDUserDescriptionCommands{{ lang._('ID') }}{{ lang._('User') }}{{ lang._('Description') }}{{ lang._('Commands') }}
- - - - - - - + + + + + + + @@ -473,7 +473,7 @@
IDHeaderHeader TypeHeader ValueHeader ReplaceDescriptionCommands{{ lang._('ID') }}{{ lang._('Header') }}{{ lang._('Header Type') }}{{ lang._('Header Value') }}{{ lang._('Header Replace') }}{{ lang._('Description') }}{{ lang._('Commands') }}