www/caddy: Added lang() function for all user exposed text for translation (#3978)

This commit is contained in:
Monviech
2024-05-14 16:05:15 +02:00
committed by GitHub
parent 08aae0dfbd
commit 0bdf28fcdd
2 changed files with 89 additions and 89 deletions
@@ -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 @@
<!-- Tab Navigation -->
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#generalTab">General</a></li>
<li><a data-toggle="tab" href="#dnsProviderTab">DNS Provider</a></li>
<li><a data-toggle="tab" href="#dynamicDnsTab">Dynamic DNS</a></li>
<li><a data-toggle="tab" href="#logSettingsTab">Log Settings</a></li>
<li class="active"><a data-toggle="tab" href="#generalTab">{{ lang._('General') }}</a></li>
<li><a data-toggle="tab" href="#dnsProviderTab">{{ lang._('DNS Provider') }}</a></li>
<li><a data-toggle="tab" href="#dynamicDnsTab">{{ lang._('Dynamic DNS') }}</a></li>
<li><a data-toggle="tab" href="#logSettingsTab">{{ lang._('Log Settings') }}</a></li>
</ul>
<!-- Tab Content -->
@@ -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('<option value="">Failed to load data</option>').selectpicker('refresh');
$('#reverseFilter').html('<option value="">{{ lang._('Failed to load data') }}</option>').selectpicker('refresh');
}
});
}
@@ -227,17 +227,17 @@
</style>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#domainsTab">Domains</a></li>
<li><a data-toggle="tab" href="#handlesTab">Handlers</a></li>
<li><a data-toggle="tab" href="#accessTab">Access</a></li>
<li><a data-toggle="tab" href="#headerTab">Headers</a></li>
<li class="active"><a data-toggle="tab" href="#domainsTab">{{ lang._('Domains') }}</a></li>
<li><a data-toggle="tab" href="#handlesTab">{{ lang._('Handlers') }}</a></li>
<li><a data-toggle="tab" href="#accessTab">{{ lang._('Access') }}</a></li>
<li><a data-toggle="tab" href="#headerTab">{{ lang._('Headers') }}</a></li>
</ul>
<div class="tab-content content-box">
<!-- Selectpicker for filter by domain -->
<div class="form-group common-filter">
<select id="reverseFilter" class="selectpicker form-control" multiple data-live-search="true" data-width="348px" data-size="7" title="Filter by Domain">
<select id="reverseFilter" class="selectpicker form-control" multiple data-live-search="true" data-width="348px" data-size="7" title="{{ lang._('Filter by Domain') }}">
<!-- Options will be populated dynamically using JavaScript/Ajax -->
</select>
</div>
@@ -246,24 +246,24 @@
<div id="domainsTab" class="tab-pane fade in active">
<div style="padding-left: 16px;">
<!-- Reverse Proxy -->
<h1>Domains</h1>
<h1>{{ lang._('Domains') }}</h1>
<div style="display: block;"> <!-- Common container -->
<table id="reverseProxyGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogReverseProxy" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">Enabled</th>
<th data-column-id="FromDomain" data-type="string">Domain</th>
<th data-column-id="FromPort" data-type="string">Port</th>
<th data-column-id="accesslist" data-type="string" data-visible="false">Access List</th>
<th data-column-id="basicauth" data-type="string" data-visible="false">Basic Auth</th>
<th data-column-id="DnsChallenge" data-type="boolean" data-formatter="boolean" data-visible="false">DNS-01 challenge</th>
<th data-column-id="DynDns" data-type="boolean" data-formatter="boolean" data-visible="false">Dynamic DNS</th>
<th data-column-id="AccessLog" data-type="boolean" data-formatter="boolean" data-visible="false">HTTP Access Log</th>
<th data-column-id="CustomCertificate" data-type="string" data-visible="false">Custom Certificate</th>
<th data-column-id="AcmePassthrough" data-type="string" data-visible="false">HTTP-01 redirection</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="FromDomain" data-type="string">{{ lang._('Domain') }}</th>
<th data-column-id="FromPort" data-type="string">{{ lang._('Port') }}</th>
<th data-column-id="accesslist" data-type="string" data-visible="false">{{ lang._('Access List') }}</th>
<th data-column-id="basicauth" data-type="string" data-visible="false">{{ lang._('Basic Auth') }}</th>
<th data-column-id="DnsChallenge" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('DNS-01 challenge') }}</th>
<th data-column-id="DynDns" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('Dynamic DNS') }}</th>
<th data-column-id="AccessLog" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('HTTP Access Log') }}</th>
<th data-column-id="CustomCertificate" data-type="string" data-visible="false">{{ lang._('Custom Certificate') }}</th>
<th data-column-id="AcmePassthrough" data-type="string" data-visible="false">{{ lang._('HTTP-01 redirection') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -282,22 +282,22 @@
</div>
<div style="padding-left: 16px;">
<!-- Subdomains -->
<h1>Subdomains</h1>
<h1>{{ lang._('Subdomains') }}</h1>
<div style="display: block;"> <!-- Common container -->
<table id="reverseSubdomainGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogSubdomain" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">Enabled</th>
<th data-column-id="reverse" data-type="string">Domain</th>
<th data-column-id="FromDomain" data-type="string">Subdomain</th>
<th data-column-id="FromPort" data-type="string">Port</th>
<th data-column-id="accesslist" data-type="string" data-visible="false">Access List</th>
<th data-column-id="basicauth" data-type="string" data-visible="false">Basic Auth</th>
<th data-column-id="DynDns" data-type="boolean" data-formatter="boolean" data-visible="false">Dynamic DNS</th>
<th data-column-id="AcmePassthrough" data-type="string" data-visible="false">HTTP-01 redirection</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="reverse" data-type="string">{{ lang._('Domain') }}</th>
<th data-column-id="FromDomain" data-type="string">{{ lang._('Subdomain') }}</th>
<th data-column-id="FromPort" data-type="string">{{ lang._('Port') }}</th>
<th data-column-id="accesslist" data-type="string" data-visible="false">{{ lang._('Access List') }}</th>
<th data-column-id="basicauth" data-type="string" data-visible="false">{{ lang._('Basic Auth') }}</th>
<th data-column-id="DynDns" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('Dynamic DNS') }}</th>
<th data-column-id="AcmePassthrough" data-type="string" data-visible="false">{{ lang._('HTTP-01 redirection') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -319,29 +319,29 @@
<!-- Handle Tab -->
<div id="handlesTab" class="tab-pane fade">
<div style="padding-left: 16px;">
<h1>Handlers</h1>
<h1>{{ lang._('Handlers') }}</h1>
<div style="display: block;"> <!-- Common container -->
<table id="reverseHandleGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogHandle" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">Enabled</th>
<th data-column-id="reverse" data-type="string">Domain</th>
<th data-column-id="subdomain" data-type="string">Subdomain</th>
<th data-column-id="HandleType" data-type="string" data-visible="false">Handle Type</th>
<th data-column-id="HandlePath" data-type="string" data-visible="false">Handle Path</th>
<th data-column-id="header" data-type="string" data-visible="false">Header</th>
<th data-column-id="ToDomain" data-type="string">Upstream Domain</th>
<th data-column-id="ToPort" data-type="string">Upstream Port</th>
<th data-column-id="ToPath" data-type="string" data-visible="false">Upstream Path</th>
<th data-column-id="PassiveHealthFailDuration" data-type="string" data-visible="false">Fail Duration</th>
<th data-column-id="HttpTls" data-type="boolean" data-formatter="boolean" data-visible="false">TLS</th>
<th data-column-id="HttpTlsTrustedCaCerts" data-type="string" data-visible="false">TLS CA</th>
<th data-column-id="HttpTlsServerName" data-type="string" data-visible="false">TLS Server Name</th>
<th data-column-id="HttpNtlm" data-type="boolean" data-formatter="boolean" data-visible="false">NTLM</th>
<th data-column-id="HttpTlsInsecureSkipVerify" data-type="boolean" data-formatter="boolean" data-visible="false">TLS Insecure Skip Verify</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="enabled" data-width="6em" data-type="boolean" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="reverse" data-type="string">{{ lang._('Domain') }}</th>
<th data-column-id="subdomain" data-type="string">{{ lang._('Subdomain') }}</th>
<th data-column-id="HandleType" data-type="string" data-visible="false">{{ lang._('Handle Type') }}</th>
<th data-column-id="HandlePath" data-type="string" data-visible="false">{{ lang._('Handle Path') }}</th>
<th data-column-id="header" data-type="string" data-visible="false">{{ lang._('Header') }}</th>
<th data-column-id="ToDomain" data-type="string">{{ lang._('Upstream Domain') }}</th>
<th data-column-id="ToPort" data-type="string">{{ lang._('Upstream Port') }}</th>
<th data-column-id="ToPath" data-type="string" data-visible="false">{{ lang._('Upstream Path') }}</th>
<th data-column-id="PassiveHealthFailDuration" data-type="string" data-visible="false">{{ lang._('Fail Duration') }}</th>
<th data-column-id="HttpTls" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('TLS') }}</th>
<th data-column-id="HttpTlsTrustedCaCerts" data-type="string" data-visible="false">{{ lang._('TLS CA') }}</th>
<th data-column-id="HttpTlsServerName" data-type="string" data-visible="false">{{ lang._('TLS Server Name') }}</th>
<th data-column-id="HttpNtlm" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('NTLM') }}</th>
<th data-column-id="HttpTlsInsecureSkipVerify" data-type="boolean" data-formatter="boolean" data-visible="false">{{ lang._('TLS Insecure Skip Verify') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -364,19 +364,19 @@
<div id="accessTab" class="tab-pane fade">
<!-- Access Lists Section -->
<div style="padding-left: 16px;">
<h1>Access Lists</h1>
<h1>{{ lang._('Access Lists') }}</h1>
<div style="display: block;">
<table id="accessListGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogAccessList" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="accesslistName" data-type="string">Name</th>
<th data-column-id="clientIps" data-type="string">Client IPs</th>
<th data-column-id="accesslistInvert" data-type="boolean" data-formatter="boolean">Invert</th>
<th data-column-id="HttpResponseCode" data-type="string" data-visible="false">HTTP Code</th>
<th data-column-id="HttpResponseMessage" data-type="string" data-visible="false">HTTP Message</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="accesslistName" data-type="string">{{ lang._('Name') }}</th>
<th data-column-id="clientIps" data-type="string">{{ lang._('Client IPs') }}</th>
<th data-column-id="accesslistInvert" data-type="boolean" data-formatter="boolean">{{ lang._('Invert') }}</th>
<th data-column-id="HttpResponseCode" data-type="string" data-visible="false">{{ lang._('HTTP Code') }}</th>
<th data-column-id="HttpResponseMessage" data-type="string" data-visible="false">{{ lang._('HTTP Message') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -396,15 +396,15 @@
<!-- Basic Auth Section -->
<div style="padding-left: 16px;">
<h1>Basic Auth</h1>
<h1>{{ lang._('Basic Auth') }}</h1>
<div style="display: block;">
<table id="basicAuthGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogBasicAuth" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="basicauthuser" data-type="string">User</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="basicauthuser" data-type="string">{{ lang._('User') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -426,18 +426,18 @@
<!-- Header Tab -->
<div id="headerTab" class="tab-pane fade">
<div style="padding-left: 16px;">
<h1>Headers</h1>
<h1>{{ lang._('Headers') }}</h1>
<div style="display: block;"> <!-- Common container -->
<table id="reverseHeaderGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogHeader" data-editAlert="ConfigurationChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
<th data-column-id="HeaderUpDown" data-type="string">Header</th>
<th data-column-id="HeaderType" data-type="string">Header Type</th>
<th data-column-id="HeaderValue" data-type="string" data-visible="false">Header Value</th>
<th data-column-id="HeaderReplace" data-type="string" data-visible="false">Header Replace</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="HeaderUpDown" data-type="string">{{ lang._('Header') }}</th>
<th data-column-id="HeaderType" data-type="string">{{ lang._('Header Type') }}</th>
<th data-column-id="HeaderValue" data-type="string" data-visible="false">{{ lang._('Header Value') }}</th>
<th data-column-id="HeaderReplace" data-type="string" data-visible="false">{{ lang._('Header Replace') }}</th>
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
@@ -473,7 +473,7 @@
<div id="messageArea" class="alert alert-info" style="display: none;"></div>
<!-- Message Area to hint user to apply changes when data is changed in bootgrids -->
<div id="ConfigurationChangeMessage" class="alert alert-info" style="display: none;">
Please don't forget to apply the configuration.
{{ lang._('Please do not forget to apply the configuration.') }}
</div>
</div>
</div>