mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Allow translations of BTCPay Server Backend by admins (#5662)
This commit is contained in:
@@ -68,6 +68,7 @@ namespace BTCPayServer.Controllers
|
||||
private readonly UriResolver _uriResolver;
|
||||
private readonly EmailSenderFactory _emailSenderFactory;
|
||||
private readonly TransactionLinkProviders _transactionLinkProviders;
|
||||
private readonly LocalizerService _localizer;
|
||||
|
||||
public UIServerController(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
@@ -93,7 +94,8 @@ namespace BTCPayServer.Controllers
|
||||
EmailSenderFactory emailSenderFactory,
|
||||
IHostApplicationLifetime applicationLifetime,
|
||||
IHtmlHelper html,
|
||||
TransactionLinkProviders transactionLinkProviders
|
||||
TransactionLinkProviders transactionLinkProviders,
|
||||
LocalizerService localizer
|
||||
)
|
||||
{
|
||||
_policiesSettings = policiesSettings;
|
||||
@@ -120,6 +122,7 @@ namespace BTCPayServer.Controllers
|
||||
ApplicationLifetime = applicationLifetime;
|
||||
Html = html;
|
||||
_transactionLinkProviders = transactionLinkProviders;
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
[HttpGet("server/stores")]
|
||||
@@ -325,17 +328,22 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
[Route("server/policies")]
|
||||
public async Task<IActionResult> Policies()
|
||||
{
|
||||
await UpdateViewBag();
|
||||
return View(_policiesSettings);
|
||||
}
|
||||
|
||||
private async Task UpdateViewBag()
|
||||
{
|
||||
ViewBag.UpdateUrlPresent = _Options.UpdateUrl != null;
|
||||
ViewBag.AppsList = await GetAppSelectList();
|
||||
return View(_policiesSettings);
|
||||
ViewBag.LangDictionaries = await GetLangDictionariesSelectList();
|
||||
}
|
||||
|
||||
[HttpPost("server/policies")]
|
||||
public async Task<IActionResult> Policies([FromServices] BTCPayNetworkProvider btcPayNetworkProvider, PoliciesSettings settings, string command = "")
|
||||
{
|
||||
ViewBag.UpdateUrlPresent = _Options.UpdateUrl != null;
|
||||
ViewBag.AppsList = await GetAppSelectList();
|
||||
await UpdateViewBag();
|
||||
|
||||
if (command == "add-domain")
|
||||
{
|
||||
@@ -384,9 +392,12 @@ namespace BTCPayServer.Controllers
|
||||
domainToAppMappingItem.AppType = apps[domainToAppMappingItem.AppId];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _SettingsRepository.UpdateSetting(settings);
|
||||
_ = _transactionLinkProviders.RefreshTransactionLinkTemplates();
|
||||
if (_policiesSettings.LangDictionary != settings.LangDictionary)
|
||||
await _localizer.Load();
|
||||
TempData[WellKnownTempData.SuccessMessage] = "Policies updated successfully";
|
||||
return RedirectToAction(nameof(Policies));
|
||||
}
|
||||
@@ -455,6 +466,12 @@ namespace BTCPayServer.Controllers
|
||||
return apps;
|
||||
}
|
||||
|
||||
private async Task<List<SelectListItem>> GetLangDictionariesSelectList()
|
||||
{
|
||||
var dictionaries = await this._localizer.GetDictionaries();
|
||||
return dictionaries.Select(d => new SelectListItem(d.DictionaryName, d.DictionaryName)).OrderBy(d => d.Value).ToList();
|
||||
}
|
||||
|
||||
private static bool TryParseAsExternalService(TorService torService, [MaybeNullWhen(false)] out ExternalService externalService)
|
||||
{
|
||||
externalService = null;
|
||||
|
||||
Reference in New Issue
Block a user