Apply store’s language on customer-facing pages (#7656)
What changed, and why it matters
This commit adds a new store-level setting that lets merchants choose which language customers see on public pages such as invoices, payment requests, and pull payments. It also marks more text on those pages as translatable. There is no direct evidence in the commit that this fixes an active security vulnerability; it reads as a feature or hardening change to make customer-facing language selection consistent and to prevent a SignalR hub from bypassing the store-language logic.
Treat as a regular feature/hardening patch. Review that RouteStoreResolver cache invalidation is acceptable (10-minute sliding cache on store-id lookups) and that the new UseStoreLanguage filter does not interfere with admin UI language selection. No urgent security deployment is indicated by the diff alone.
Security signals we found
New per-request language scoping via AsyncLocal with explicit BeginRequest/Restore disposal
SignalR hub now applies store language to controller calls that bypass MVC filters
RouteStoreResolver centralizes route-value-to-store-id lookup with 10-minute sliding memory-cache
StorefrontLanguage input is validated against installed translations in GeneralSettings POST
Refactored permission scope provider now reuses the same resolver, reducing duplicated SQL lookup logic
Evidence from the diff
The change introduces a StorefrontLanguage property on StoreBlob, a UseStoreLanguage MVC action filter, a RouteStoreResolver service, and updates the TranslationsAccessor to support scoped per-request language overrides. Public actions in UIInvoiceController, UIPaymentRequestController, and UIPullPaymentController are decorated with [UseStoreLanguage]. The PaymentRequestHub SignalR hub wraps controller calls in InStoreLanguage so that WebSocket-triggered actions also respect the store’s configured language. The BuiltInPermissionScopeProvider is refactored to delegate route-to-store resolution to RouteStoreResolver, which is then reused by the language filter. Several receipt/payment-request Razor views gain text-translate attributes and StringLocalizer calls. No memory-safety, cryptographic, or authorization bypass issues are visible in the diff.
Changed components
BTCPayServer.Plugins.Translations (TranslationsAccessor, UseStoreLanguageAttribute)BTCPayServer.Security (RouteStoreResolver, BuiltInPermissionScopeProvider, SetContextFilter)BTCPayServer.Controllers (UIInvoiceController, UIPaymentRequestController, UIPullPaymentController, UIStoresController)BTCPayServer.PaymentRequest.PaymentRequestHubBTCPayServer.Data.StoreBlobCustomer-facing Razor views: InvoiceReceipt, InvoiceReceiptPrint, ViewPaymentRequest, GeneralSettingsInspect captured patch +449 / −104
### BTCPayServer.Tests/LanguageServiceTests.cs
@@ -4,17 +4,23 @@
using System.Linq;
using System.Net;
using System.Net.Http;
+using System.Net.WebSockets;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Data;
using BTCPayServer.Abstractions.Models;
using BTCPayServer.Plugins.Translations;
+using BTCPayServer.Security;
using BTCPayServer.Services;
+using BTCPayServer.Services.Stores;
using Dapper;
using Microsoft.EntityFrameworkCore;
+using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Playwright;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Microsoft.Playwright.Assertions;
using Xunit;
@@ -762,21 +768,21 @@ await Task.Run(() =>
var previousTranslations = accessor.RequestTranslations;
try
{
- accessor.RequestTranslations = french;
+ accessor.UseStoreLanguage(french);
Assert.Same(french, accessor.Current);
Assert.Equal("Salut", Hello(accessor.Current.Translations));
Assert.NotEqual("Salut", Hello(localizer.Translations));
- accessor.RequestTranslations = french with { Rtl = true };
+ accessor.UseStoreLanguage(french with { Rtl = true });
Assert.True(accessor.Current.Rtl);
- accessor.RequestTranslations = null;
+ accessor.UseStoreLanguage((LocalizerService.LoadedTranslations)null);
Assert.Same(localizer.ServerTranslations, accessor.Current);
Assert.Equal(localizer.ServerTranslations.Rtl, accessor.Current.Rtl);
}
finally
{
- accessor.RequestTranslations = previousTranslations;
+ accessor.UseStoreLanguage(previousTranslations);
}
});
Assert.Null(accessor.RequestTranslations);
@@ -801,6 +807,169 @@ await Task.Run(() =>
await localizer.DeleteTranslation("French");
Assert.Null(await localizer.GetUserTranslations("French"));
}
+ [Fact(Timeout = TestTimeout)]
+ [Trait("Integration", "Integration")]
+ public async Task CanUseStoreLanguage()
+ {
+ using var tester = CreateServerTester(newDb: true);
+ await tester.StartAsync();
+ var localizer = tester.PayTester.GetService<LocalizerService>();
+ var accessor = tester.PayTester.GetService<TranslationsAccessor>();
+ var db = tester.PayTester.GetService<ApplicationDbContextFactory>().CreateContext().Database.GetDbConnection();
+ await db.ExecuteAsync("INSERT INTO lang_dictionaries VALUES ('French', 'English', 'Custom')");
+ var dict = await localizer.GetTranslation("French");
+ const string amountError = "Please provide an amount greater than 0";
+ await localizer.Save(dict!, new Translations(new[]
+ {
+ KeyValuePair.Create("Hello", "Salut"),
+ KeyValuePair.Create("No due date", "Sans date limite"),
+ KeyValuePair.Create(amountError, "Veuillez fournir un montant supérieur à 0")
+ }));
+ static string Hello(Translations t) => t.Records.TryGetValue("Hello", out var v) ? v : null;
+ var french = await localizer.GetUserTranslations("French");
+
+ async Task<string> RenderPublicPage(LocalizerService.LoadedTranslations userLanguage, string storeLanguage)
+ {
+ return await Task.Run(async () =>
+ {
+ using (accessor.BeginRequest())
+ {
+ accessor.UseStoreLanguage(userLanguage);
+ await accessor.UseStoreLanguage(storeLanguage);
+ return Hello(accessor.Current.Translations);
+ }
+ });
+ }
+ Assert.Equal("Salut", await RenderPublicPage(null, "French"));
+ Assert.NotEqual("Salut", await RenderPublicPage(french, localizer.ServerLanguage));
+ Assert.Equal("Salut", await RenderPublicPage(french, null));
+ Assert.Equal("Salut", await RenderPublicPage(french, ""));
+ using (accessor.BeginRequest())
+ {
+ await accessor.UseStoreLanguage((string)null);
+ Assert.Same(localizer.ServerTranslations, accessor.Current);
+ }
+ Assert.Equal("Salut", await RenderPublicPage(french, "Klingon"));
+ for (var i = 0; i < 20; i++)
+ {
+ var frenchStore = RenderPublicPage(null, "French");
+ var serverStore = RenderPublicPage(french, localizer.ServerLanguage);
+ Assert.Equal("Salut", await frenchStore);
+ Assert.NotEqual("Salut", await serverStore);
+ }
+ Assert.NotEqual("Salut", Hello(localizer.Translations));
+
+ // SignalR calls the controller directly, bypassing MVC action filters.
+ var user = tester.NewAccount();
+ await user.GrantAccessAsync();
+ var client = await user.CreateClient();
+ var paymentRequest = await client.CreatePaymentRequest(user.StoreId,
+ new() { Title = "Store language", Currency = "USD", Amount = 1 });
+ var resolver = tester.PayTester.GetService<RouteStoreResolver>();
+ var routeData = new RouteData();
+ routeData.Values["payReqId"] = paymentRequest.Id;
+ var resolved = Assert.IsType<RouteStoreResolver.Resolution.Resolved>(await resolver.Resolve(routeData));
+ Assert.Equal(user.StoreId, resolved.StoreId);
+ Assert.Equal(new RouteStoreResolver.AdditionalScope("payReqId", paymentRequest.Id),
+ Assert.Single(resolved.AdditionalScopes));
+ Assert.Equal(user.StoreId,
+ Assert.IsType<RouteStoreResolver.Resolution.Resolved>(await resolver.Resolve(routeData)).StoreId); // Cached lookup.
+ routeData.Values["payReqId"] = "missing";
+ Assert.IsType<RouteStoreResolver.Resolution.Invalid>(await resolver.Resolve(routeData));
+ routeData.Values["storeId"] = user.StoreId;
+ Assert.IsType<RouteStoreResolver.Resolution.Invalid>(await resolver.Resolve(routeData));
+ routeData.Values["payReqId"] = paymentRequest.Id;
+ Assert.Equal(user.StoreId,
+ Assert.IsType<RouteStoreResolver.Resolution.Resolved>(await resolver.Resolve(routeData)).StoreId);
+ routeData.Values["storeId"] = "another-store";
+ Assert.IsType<RouteStoreResolver.Resolution.Invalid>(await resolver.Resolve(routeData));
+ routeData.Values.Remove("storeId");
+ routeData.Values["paymentRequestId"] = paymentRequest.Id;
+ resolved = Assert.IsType<RouteStoreResolver.Resolution.Resolved>(await resolver.Resolve(routeData));
+ Assert.Equal(user.StoreId, resolved.StoreId);
+ Assert.Equal(new[]
+ {
+ new RouteStoreResolver.AdditionalScope("payReqId", paymentRequest.Id),
+ new RouteStoreResolver.AdditionalScope("paymentRequestId", paymentRequest.Id)
+ }, resolved.AdditionalScopes);
+ var otherUser = tester.NewAccount();
+ await otherUser.GrantAccessAsync();
+ var otherClient = await otherUser.CreateClient();
+ var otherRequest = await otherClient.CreatePaymentRequest(otherUser.StoreId,
+ new() { Title = "Other store", Currency = "USD", Amount = 1 });
+ routeData.Values["paymentRequestId"] = otherRequest.Id;
+ Assert.IsType<RouteStoreResolver.Resolution.Invalid>(await resolver.Resolve(routeData));
+ routeData.Values.Clear();
+ Assert.IsType<RouteStoreResolver.Resolution.Unscoped>(await resolver.Resolve(routeData));
+ routeData.Values["storeId"] = user.StoreId;
+ resolved = Assert.IsType<RouteStoreResolver.Resolution.Resolved>(await resolver.Resolve(routeData));
+ Assert.Equal(user.StoreId, resolved.StoreId);
+ Assert.Empty(resolved.AdditionalScopes);
+ var stores = tester.PayTester.GetService<StoreRepository>();
+ var store = await stores.FindStore(user.StoreId);
+ var blob = store.GetStoreBlob();
+ blob.StorefrontLanguage = "French";
+ store.SetStoreBlob(blob);
+ await stores.UpdateStore(store);
+
+ using var http = new HttpClient();
+ var paymentRequestPage = await http.GetStringAsync(new Uri(tester.PayTester.ServerUri,
+ $"payment-requests/{paymentRequest.Id}"));
+ Assert.Contains("Sans date limite", paymentRequestPage);
+ Assert.DoesNotContain("No due date", paymentRequestPage);
+
+ using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30));
+ using var socket = new ClientWebSocket();
+ var hubUri = new UriBuilder(new Uri(tester.PayTester.ServerUri, "payment-requests/hub"))
+ {
+ Scheme = "ws"
+ }.Uri;
+ await socket.ConnectAsync(hubUri, timeout.Token);
+
+ async Task Send(object message)
+ {
+ var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message) + "\u001e");
+ await socket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, timeout.Token);
+ }
+
+ async Task<JObject> Receive()
+ {
+ using var message = new MemoryStream();
+ var buffer = new byte[4096];
+ WebSocketReceiveResult received;
+ do
+ {
+ received = await socket.ReceiveAsync(new ArraySegment<byte>(buffer), timeout.Token);
+ Assert.Equal(WebSocketMessageType.Text, received.MessageType);
+ message.Write(buffer, 0, received.Count);
+ } while (!received.EndOfMessage);
+ return JsonParser.ParseObject(Encoding.UTF8.GetString(message.ToArray()).Split('\u001e')[0]);
+ }
+
+ await Send(new { protocol = "json", version = 1 });
+ Assert.Empty(await Receive());
+ async Task<string> PayError()
+ {
+ await Send(new { type = 1, target = "Pay", arguments = new object[] { paymentRequest.Id, 0 } });
+ JObject response;
+ do
+ {
+ response = await Receive();
+ } while (response["type"]?.Value<int>() == 6); // Ignore keep-alive messages.
+ Assert.Equal("InvoiceError", response["target"]?.Value<string>());
+ return response["arguments"]![0]!["value"]!.Value<string>();
+ }
+
+ Assert.Equal("Veuillez fournir un montant supérieur à 0", await PayError());
+ blob.StorefrontLanguage = null;
+ store.SetStoreBlob(blob);
+ await stores.UpdateStore(store);
+ Assert.Equal(amountError, await PayError());
+
+ tester.PayTester.GetService<ISettingsAccessor<PoliciesSettings>>().Settings.LangTranslation = "French";
+ await localizer.Load();
+ Assert.Equal("Salut", await RenderPublicPage(null, null));
+ }
[Fact(Timeout = TestTimeout)]
[Trait("Playwright", "Playwright")]
### BTCPayServer/Controllers/UIInvoiceController.UI.cs
@@ -19,6 +19,7 @@
using BTCPayServer.Payments;
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Payouts;
+using BTCPayServer.Plugins.Translations;
using BTCPayServer.Plugins.Wallets;
using BTCPayServer.Plugins.Webhooks.Views;
using BTCPayServer.Rating;
@@ -195,6 +196,7 @@ public async Task<IActionResult> Invoice(string invoiceId)
}
[XFrameOptions(null)]
+ [UseStoreLanguage]
[HttpGet("i/{invoiceId}/receipt")]
public async Task<IActionResult> InvoiceReceipt(string invoiceId, [FromQuery] bool print = false)
{
### BTCPayServer/Controllers/UIInvoiceController.cs
@@ -7,31 +7,32 @@
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Client.Models;
-using BTCPayServer.Services;
using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.HostedServices;
using BTCPayServer.Logging;
using BTCPayServer.Payments;
+using BTCPayServer.Payouts;
+using BTCPayServer.Plugins.Translations;
+using BTCPayServer.Plugins.Webhooks;
using BTCPayServer.Rating;
using BTCPayServer.Security.Greenfield;
+using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.PaymentRequests;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
+using Dapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Routing;
-using Newtonsoft.Json.Linq;
-using StoreData = BTCPayServer.Data.StoreData;
-using BTCPayServer.Payouts;
-using BTCPayServer.Plugins.Webhooks;
-using Dapper;
using Microsoft.AspNetCore.Mvc.Localization;
+using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Localization;
+using Newtonsoft.Json.Linq;
+using StoreData = BTCPayServer.Data.StoreData;
namespace BTCPayServer.Controllers
{
@@ -60,7 +61,6 @@ public partial class UIInvoiceController : Controller
private readonly AppService _appService;
private readonly UriResolver _uriResolver;
private readonly PermissionService _permissionService;
-
public WebhookSender WebhookNotificationManager { get; }
public IEnumerable<IGlobalCheckoutModelExtension> GlobalCheckoutModelExtensions { get; }
public IStringLocalizer StringLocalizer { get; }
### BTCPayServer/Controllers/UIPaymentRequestController.cs
@@ -17,9 +17,10 @@
using BTCPayServer.Forms.Models;
using BTCPayServer.Models;
using BTCPayServer.Models.PaymentRequestViewModels;
-using BTCPayServer.Plugins.Wallets.Views.ViewModels;
using BTCPayServer.PaymentRequest;
+using BTCPayServer.Plugins.Translations;
using BTCPayServer.Plugins.Wallets;
+using BTCPayServer.Plugins.Wallets.Views.ViewModels;
using BTCPayServer.Services;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Labels;
@@ -329,6 +330,7 @@ await _storeLabelRepository.SetStoreObjectLabels(
[HttpGet("{payReqId}")]
[AllowAnonymous]
+ [UseStoreLanguage]
public async Task<IActionResult> ViewPaymentRequest(string payReqId)
{
var vm = await _PaymentRequestService.GetPaymentRequest(payReqId, GetUserId());
@@ -355,6 +357,7 @@ public async Task<IActionResult> ViewPaymentRequest(string payReqId)
[HttpGet("{payReqId}/form")]
[HttpPost("{payReqId}/form")]
[AllowAnonymous]
+ [UseStoreLanguage]
[XFrameOptions(XFrameOptionsAttribute.XFrameOptions.Unset)]
public async Task<IActionResult> ViewPaymentRequestForm(string payReqId, FormViewModel viewModel)
{
@@ -415,6 +418,7 @@ public async Task<IActionResult> ViewPaymentRequestForm(string payReqId, FormVie
[HttpGet("{payReqId}/pay")]
[AllowAnonymous]
+ [UseStoreLanguage]
public async Task<IActionResult> PayPaymentRequest(string payReqId, bool redirectToInvoice = true,
decimal? amount = null, CancellationToken cancellationToken = default)
{
@@ -504,6 +508,7 @@ public async Task<IActionResult> PayPaymentRequest(string payReqId, bool redirec
[HttpGet("{payReqId}/cancel")]
[AllowAnonymous]
+ [UseStoreLanguage]
public async Task<IActionResult> CancelUnpaidPendingInvoice(string payReqId, bool redirect = true)
{
var result = await _PaymentRequestService.GetPaymentRequest(payReqId, GetUserId());
### BTCPayServer/Controllers/UIPullPaymentController.cs
@@ -11,9 +11,10 @@
using BTCPayServer.Data;
using BTCPayServer.HostedServices;
using BTCPayServer.Models;
-using BTCPayServer.Plugins.Wallets.Views.ViewModels;
using BTCPayServer.Payments;
using BTCPayServer.Payouts;
+using BTCPayServer.Plugins.Translations;
+using BTCPayServer.Plugins.Wallets.Views.ViewModels;
using BTCPayServer.Services;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
@@ -40,6 +41,7 @@ public class UIPullPaymentController(
public IStringLocalizer StringLocalizer { get; } = stringLocalizer;
[AllowAnonymous]
+ [UseStoreLanguage]
[HttpGet("pull-payments/{pullPaymentId}")]
public async Task<IActionResult> ViewPullPayment(string pullPaymentId)
{
@@ -167,6 +169,7 @@ public async Task<IActionResult> EditPullPayment(string storeId, string pullPaym
}
[AllowAnonymous]
+ [UseStoreLanguage]
[HttpPost("pull-payments/{pullPaymentId}")]
public async Task<IActionResult> ClaimPullPayment(string pullPaymentId, ViewPullPaymentModel vm, CancellationToken cancellationToken)
{
### BTCPayServer/Controllers/UIStoresController.Settings.cs
@@ -12,6 +12,7 @@
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Payments;
using BTCPayServer.Payments.Lightning;
+using BTCPayServer.Plugins.Translations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -32,6 +33,7 @@ public async Task<IActionResult> GeneralSettings(string storeId)
Id = store.Id,
StoreName = store.StoreName,
StoreWebsite = store.StoreWebsite,
+ StorefrontLanguage = storeBlob.StorefrontLanguage,
LogoUrl = await _uriResolver.Resolve(Request.GetAbsoluteRootUri(), storeBlob.LogoUrl),
CssUrl = await _uriResolver.Resolve(Request.GetAbsoluteRootUri(), storeBlob.CssUrl),
BrandColor = storeBlob.BrandColor,
@@ -49,10 +51,17 @@ public async Task<IActionResult> GeneralSettings(string storeId)
ShowRecommendedFee = storeBlob.ShowRecommendedFee,
RecommendedFeeBlockTarget = storeBlob.RecommendedFeeBlockTarget
};
+ return await GeneralSettingsView(vm);
+ }
- return View(vm);
+ private async Task<IActionResult> GeneralSettingsView(GeneralSettingsViewModel model)
+ {
+ model.StorefrontLanguages = await _localizer.GetTranslationsSelectList();
+ model.StorefrontLanguages.Insert(0, new SelectListItem(StringLocalizer["Default"].Value, ""));
+ return View(nameof(GeneralSettings), model);
}
+
[HttpPost("{storeId}/settings")]
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
public async Task<IActionResult> GeneralSettings(
@@ -93,11 +102,21 @@ public async Task<IActionResult> GeneralSettings(
if (!string.IsNullOrEmpty(model.BrandColor) && !ColorPalette.IsValid(model.BrandColor))
{
ModelState.AddModelError(nameof(model.BrandColor), StringLocalizer["The brand color needs to be a valid hex color code"]);
- return View(model);
+ return await GeneralSettingsView(model);
}
blob.BrandColor = model.BrandColor;
blob.ApplyBrandColorToBackend = model.ApplyBrandColorToBackend && !string.IsNullOrEmpty(model.BrandColor);
+ var storeLanguage = string.IsNullOrEmpty(model.StorefrontLanguage) ? null : model.StorefrontLanguage;
+ if(storeLanguage is not null && !LocalizerService.IsInstalledTranslation(storeLanguage, await _localizer.GetTranslations()))
+ {
+ ModelState.AddModelError(nameof(model.StorefrontLanguage), StringLocalizer["The selected language is not installed on this server."]);
+ }
+ else
+ {
+ blob.StorefrontLanguage = storeLanguage;
+ }
+
var userId = GetUserId();
if (userId is null)
return NotFound();
@@ -160,7 +179,7 @@ public async Task<IActionResult> GeneralSettings(
needUpdate = true;
}
if (!ModelState.IsValid)
- return View(model);
+ return await GeneralSettingsView(model);
if (CurrentStore.SetStoreBlob(blob))
{
### BTCPayServer/Controllers/UIStoresController.cs
@@ -9,6 +9,7 @@
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Plugins.Emails.Services;
using BTCPayServer.Plugins.Monetization;
+using BTCPayServer.Plugins.Translations;
using BTCPayServer.Plugins.Wallets;
using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
@@ -42,6 +43,7 @@ public UIStoresController(
RateFetcher rateFactory,
ExplorerClientProvider explorerProvider,
LanguageService langService,
+ LocalizerService localizer,
PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
PoliciesSettings policiesSettings,
IAuthorizationService authorizationService,
@@ -69,6 +71,7 @@ public UIStoresController(
_storeRepo = storeRepo;
_userManager = userManager;
_langService = langService;
+ _localizer = localizer;
_walletProvider = walletProvider;
_handlers = paymentMethodHandlerDictionary;
_policiesSettings = policiesSettings;
@@ -108,6 +111,7 @@ public UIStoresController(
private readonly CurrencyNameTable _currencyNameTable;
private readonly ExplorerClientProvider _explorerProvider;
private readonly LanguageService _langService;
+ private readonly LocalizerService _localizer;
private readonly PaymentMethodHandlerDictionary _handlers;
private readonly DefaultRulesCollection _defaultRules;
private readonly PoliciesSettings _policiesSettings;
### BTCPayServer/Data/StoreBlob.cs
@@ -77,6 +77,7 @@ public string GetDefaultCurrencyPairString()
}
public string DefaultLang { get; set; }
+ public string StorefrontLanguage { get; set; }
[DefaultValue(typeof(TimeSpan), "1.00:00:00")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
[JsonConverter(typeof(TimeSpanJsonConverter.Minutes))]
### BTCPayServer/Hosting/BTCPayServerServices.cs
@@ -502,6 +502,7 @@ CREATE INDEX IF NOT EXISTS idx_invoices_expired_cleanup
services.AddSingleton<APIKeyRepository>();
services.AddSingleton<IPermissionHandler, BuiltInPermissionHandler>();
services.AddSingleton<IPermissionScopeProvider, BuiltInPermissionScopeProvider>();
+ services.AddSingleton<RouteStoreResolver>();
services.AddSingleton<BuiltInPermissionScopeProvider.IStoreScopeProvider, BuiltInPermissionScopeProvider.SqlStoreScopeProvider>();
foreach (var routeDataToStoreId in new BuiltInPermissionScopeProvider.RouteValueToStoreIdQuery[]
### BTCPayServer/Hosting/UserLanguageMiddleware.cs
@@ -16,16 +16,14 @@ public class UserLanguageMiddleware(
{
public async Task Invoke(HttpContext httpContext, UserManager<ApplicationUser> userManager)
{
- var previousTranslations = translationsAccessor.RequestTranslations;
- try
+ using (translationsAccessor.BeginRequest())
{
- translationsAccessor.RequestTranslations = null;
if (httpContext.User.Identity is { IsAuthenticated: true } identity &&
identity.AuthenticationType == IdentityConstants.ApplicationScheme)
{
try
{
- translationsAccessor.RequestTranslations = await localizer.GetTranslationsForUser(httpContext.User, userManager);
+ translationsAccessor.UseStoreLanguage(await localizer.GetTranslationsForUser(httpContext.User, userManager));
}
catch (Exception ex)
{
@@ -35,9 +33,5 @@ public async Task Invoke(HttpContext httpContext, UserManager<ApplicationUser> u
await next(httpContext);
}
- finally
- {
- translationsAccessor.RequestTranslations = previousTranslations;
- }
}
}
### BTCPayServer/Models/StoreViewModels/GeneralSettingsViewModel.cs
@@ -1,8 +1,10 @@
+using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using BTCPayServer.Client.Models;
using BTCPayServer.Services.Rates;
using BTCPayServer.Validation;
using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc.Rendering;
namespace BTCPayServer.Models.StoreViewModels
{
@@ -23,6 +25,10 @@ public class GeneralSettingsViewModel
[MaxLength(500)]
public string StoreWebsite { get; set; }
+ [Display(Name = "Storefront language")]
+ public string StorefrontLanguage { get; set; }
+ public List<SelectListItem> StorefrontLanguages { get; set; } = new();
+
[Display(Name = "Brand Color")]
public string BrandColor { get; set; }
### BTCPayServer/PaymentRequest/PaymentRequestHub.cs
@@ -1,10 +1,13 @@
+using System;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Controllers;
+using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.HostedServices;
using BTCPayServer.Logging;
+using BTCPayServer.Plugins.Translations;
using BTCPayServer.Services;
using BTCPayServer.Services.PaymentRequests;
using Microsoft.AspNetCore.Builder;
@@ -19,6 +22,8 @@ namespace BTCPayServer.PaymentRequest
public class PaymentRequestHub : Hub
{
private readonly UIPaymentRequestController _PaymentRequestController;
+ private readonly TranslationsAccessor _translationsAccessor;
+ private readonly PaymentRequestRepository _paymentRequestRepository;
public const string InvoiceCreated = "InvoiceCreated";
public const string InvoiceConfirmed = "InvoiceConfirmed";
public const string PaymentReceived = "PaymentReceived";
@@ -27,9 +32,25 @@ public class PaymentRequestHub : Hub
public const string CancelInvoiceError = "CancelInvoiceError";
public const string InvoiceCancelled = "InvoiceCancelled";
- public PaymentRequestHub(UIPaymentRequestController paymentRequestController)
+ public PaymentRequestHub(UIPaymentRequestController paymentRequestController,
+ TranslationsAccessor translationsAccessor, PaymentRequestRepository paymentRequestRepository)
{
_PaymentRequestController = paymentRequestController;
+ _translationsAccessor = translationsAccessor;
+ _paymentRequestRepository = paymentRequestRepository;
+ }
+
+ private async Task<IActionResult> InStoreLanguage(string prId, Func<Task<IActionResult>> action)
+ {
+ var currentTranslations = _translationsAccessor.RequestTranslations;
+ using (_translationsAccessor.BeginRequest())
+ {
+ _translationsAccessor.UseStoreLanguage(currentTranslations);
+ var paymentRequest = await _paymentRequestRepository.FindPaymentRequest(prId, null);
+ if (paymentRequest?.StoreData is { } store)
+ await _translationsAccessor.UseStoreLanguage(store.GetStoreBlob().StorefrontLanguage);
+ return await action();
+ }
}
public async Task ListenToPaymentRequest(string prId)
@@ -53,7 +74,7 @@ public async Task Pay(string prId, decimal? amount = null)
return;
_PaymentRequestController.ControllerContext.HttpContext = Context.GetHttpContext();
var result =
- await _PaymentRequestController.PayPaymentRequest(prId, false, amount);
+ await InStoreLanguage(prId, () => _PaymentRequestController.PayPaymentRequest(prId, false, amount));
switch (result)
{
case OkObjectResult okObjectResult:
@@ -77,7 +98,7 @@ public async Task CancelUnpaidPendingInvoice(string prId)
return;
_PaymentRequestController.ControllerContext.HttpContext = Context.GetHttpContext();
var result =
- await _PaymentRequestController.CancelUnpaidPendingInvoice(prId, false);
+ await InStoreLanguage(prId, () => _PaymentRequestController.CancelUnpaidPendingInvoice(prId, false));
switch (result)
{
case OkObjectResult:
### BTCPayServer/Plugins/Translations/Translations.Default.cs
@@ -181,6 +181,7 @@ static Translations()
"Amount": "",
"Amount and currency are not editable once payment request has invoices": "",
"Amount must be greater than 0": "",
+ "Amount Paid": "",
"Amount requested": "",
"An error occurred while resetting user password": "",
"An error occurred while saving: {0}": "",
@@ -637,6 +638,7 @@ static Translations()
"Download a two-factor authenticator app like …": "",
"Download PSBT file": "",
"Downloaded language pack is invalid": "",
+ "Due": "",
"Due Diligence Advised:": "",
"Dynamic": "",
"Dynamic DNS allows you to have a stable DNS name pointing to your server, even if your IP address changes regularly. This is recommended if you are hosting BTCPay Server at home and wish to have a clearnet domain to access your server.": "",
@@ -1157,6 +1159,7 @@ static Translations()
"No deliveries for this webhook yet": "",
"No device connected.": "",
"No documentation": "",
+ "No due date": "",
"No email address has been configured for the Server. Configure an email address\n to\n begin sending emails.": "",
"No end date has been set": "",
"No expiry date has been set for this payment request": "",
@@ -1240,6 +1243,7 @@ static Translations()
"or sign in with": "",
"Order Id": "",
"Order ID": "",
+ "Order ID: {0}": "",
"Original transaction": "",
"Original Value": "",
"Other external services": "",
@@ -1291,6 +1295,7 @@ static Translations()
"Payjoin transaction": "",
"Payload URL": "",
"Payment": "",
+ "Payment {0}": "",
"Payment cancelled": "",
"Payment Details": "",
"Payment for <strong>{0}</strong>": "",
@@ -1429,6 +1434,7 @@ static Translations()
"Product list": "",
"Product list with cart": "",
"Profile Picture": "",
+ "Proof: {0}": "",
"Provide the 12 or 24 word recovery seed": "",
"Provide updated PSBT": "",
"Provider": "",
@@ -1465,6 +1471,7 @@ static Translations()
"Rate Source": "",
"Rate Spread": "",
"Rate unavailable: {0}": "",
+ "Rate: {0}": "",
"Rates": "",
"Read more": "",
"Ready to create wallet": "",
@@ -1574,6 +1581,8 @@ static Translations()
"Retired": "",
"Retiring": "",
"Retry": "",
+ "Return to {0}": "",
+ "Return to store": "",
"Reveal": "",
"Revoke": "",
"Revoke access token": "",
@@ -1679,6 +1688,7 @@ static Translations()
"Sent": "",
"Server": "",
"Server and account settings moved to the top-right menu, just look up!": "",
+ "Server default ({0})": "",
"Server Emails": "",
"Server IPN": "",
"Server Name": "",
@@ -1816,6 +1826,7 @@ static Translations()
"Store-based permissions will be applied for": "",
"Store-level": "",
"Store: {0}": "",
+ "Storefront language": "",
"Stores": "",
"Subject": "",
"Submit": "",
@@ -1925,6 +1936,8 @@ static Translations()
"The invoice currency, at the rate when the refund will be sent.": "",
"The invoice has been archived and will no longer appear in the invoice list by default.": "",
"The invoice has been unarchived and will appear in the invoice list by default again.": "",
+ "The invoice has detected a payment but is still waiting to be settled.": "",
+ "The invoice is not settled.": "",
"The label {0} will be deleted from all payment requests.": "",
"The label {0} will be removed from this wallet and its associated transactions.": "",
"The label could not be deleted.": "",
@@ -1969,6 +1982,7 @@ static Translations()
"The security device was removed successfully.": "",
"The seed was not found": "",
"The selected fee rate is too small. The minimum is {0} sat/byte": "",
+ "The selected language is not installed on this server.": "",
"The server is already using this domain.": "",
"The server might restart while this command is running, interrupting the connection. If that happens, please refresh the page.": "",
"The specified amount with the specified currency, at the rate when the refund will be sent.": "",
@@ -2080,6 +2094,7 @@ static Translations()
"This page exposes information to connect remotely to your full node via the RPC protocol.": "",
"This page exposes information to use the configured BTCPay Server Configurator to modify this setup.": "",
"This page is served in non-secure context (HTTPS, localhost or file://)": "",
+ "This page will refresh periodically until the invoice is settled.": "",
"This payment method requires javascript.": "",
"This permission is not available for your account.": "",
"This process disables 2FA until you verify your authenticator app. If you do not complete your authenticator app configuration you may lose access to your account.": "",
@@ -2261,6 +2276,7 @@ static Translations()
"User enabled": "",
"User is admin": "",
"User is approved": "",
+ "User Language": "",
"User not found": "",
"User not found or invalid password": "",
"User removed successfully.": "",
@@ -2418,6 +2434,7 @@ static Translations()
"Your password has been changed.": "",
"Your password has been set by the user who invited you.": "",
"Your password has been set.": "",
+ "Your personal language for the BTCPay administration UI.": "",
"Your plan does not allow you to log in.": "",
"Your plan will change at the end of your current billing period.": "",
"Your profile has been updated": "",
### BTCPayServer/Plugins/Translations/TranslationsAccessor.cs
@@ -1,17 +1,62 @@
#nullable enable
+using System;
using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
namespace BTCPayServer.Plugins.Translations;
-public class TranslationsAccessor(LocalizerService localizerService)
+public class TranslationsAccessor(LocalizerService localizerService, ILogger<TranslationsAccessor> logger)
{
- readonly AsyncLocal<LocalizerService.LoadedTranslations?> _requestTranslations = new();
+ sealed class RequestLanguage
+ {
+ public LocalizerService.LoadedTranslations? Translations { get; set; }
+ }
+
+ readonly AsyncLocal<RequestLanguage?> _request = new();
+
+ public LocalizerService.LoadedTranslations? RequestTranslations => _request.Value?.Translations;
+
+ public void UseStoreLanguage(LocalizerService.LoadedTranslations? translations)
+ {
+ if (_request.Value is { } current)
+ current.Translations = translations;
+ else
+ _request.Value = new RequestLanguage { Translations = translations };
+ }
- public LocalizerService.LoadedTranslations? RequestTranslations
+ public IDisposable BeginRequest()
{
- get => _requestTranslations.Value;
- set => _requestTranslations.Value = value;
+ var previous = _request.Value;
+ _request.Value = new RequestLanguage();
+ return new Restore(() => _request.Value = previous);
+ }
+
+ sealed class Restore(Action restore) : IDisposable
+ {
+ public void Dispose() => restore();
}
public LocalizerService.LoadedTranslations Current => RequestTranslations ?? localizerService.ServerTranslations;
+
+ public async Task UseStoreLanguage(string? translationName)
+ {
+ if (string.IsNullOrEmpty(translationName))
+ return;
+
+ if (translationName == localizerService.ServerLanguage)
+ {
+ UseStoreLanguage((LocalizerService.LoadedTranslations?)null);
+ return;
+ }
+ try
+ {
+ if (await localizerService.GetUserTranslations(translationName) is { } translations)
+ UseStoreLanguage(translations);
+ }
+ catch (Exception ex)
+ {
+ logger.LogWarning(ex, "Failed to load the language {Language} of a store, the page keeps its current language", translationName);
+ }
+ }
}
### BTCPayServer/Plugins/Translations/UseStoreLanguageAttribute.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Threading.Tasks;
+using BTCPayServer.Data;
+using BTCPayServer.Security;
+using BTCPayServer.Services.Stores;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace BTCPayServer.Plugins.Translations;
+
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+public class UseStoreLanguageAttribute() : TypeFilterAttribute(typeof(StoreLanguageFilter));
+
+internal class StoreLanguageFilter(TranslationsAccessor translationsAccessor, StoreRepository storeRepository,
+ RouteStoreResolver routeStoreResolver) : IAsyncActionFilter
+{
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
+ {
+ if (await routeStoreResolver.Resolve(context.RouteData) is RouteStoreResolver.Resolution.Resolved { StoreId: {} storeId } &&
+ await storeRepository.FindStore(storeId) is { } store)
+ await translationsAccessor.UseStoreLanguage(store.GetStoreBlob().StorefrontLanguage);
+ await next();
+ }
+}
### BTCPayServer/Security/BuiltInPermissionScopeProvider.cs
@@ -6,10 +6,6 @@
using BTCPayServer.Client;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Routing;
-using BTCPayServer.Data;
-using Dapper;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Caching.Memory;
namespace BTCPayServer.Security;
@@ -31,15 +27,11 @@ public interface IStoreScopeProvider
/// </summary>
public record RouteValueToStoreIdQuery(string RouteValue, string Sql);
- internal class SqlStoreScopeProvider(
- IEnumerable<RouteValueToStoreIdQuery> routeDataToStoreIds,
- ApplicationDbContextFactory dbContextFactory,
- IMemoryCache memoryCache) : IStoreScopeProvider
+ internal class SqlStoreScopeProvider(RouteStoreResolver routeStoreResolver) : IStoreScopeProvider
{
public async Task<string?> GetStoreId(AuthorizationHandlerContext authContext, ScopeProviderAuthorizationContext providerContext, RouteData routeData)
{
- await using var ctx = dbContextFactory.CreateContext();
var httpContext = providerContext.HttpContext;
var storeId = providerContext.HttpContext.GetCurrentStoreId();
var resolvedStoreIds = new HashSet<string>();
@@ -105,55 +97,28 @@ internal class SqlStoreScopeProvider(
return null;
}
- List<AdditionalScope> additionalScopes = new();
- foreach (var i in routeDataToStoreIds)
+ switch (await routeStoreResolver.Resolve(routeData))
{
- if (routeData.Values.TryGetValue(i.RouteValue, out var ido) && ido is string id)
- {
- var cacheKey = $"SqlStoreScopeProvider-{i.RouteValue}-{id}";
- memoryCache.TryGetValue(cacheKey, out var storeIdFromCache);
- var storeId2 = storeIdFromCache as string;
- if (storeId2 is null)
- {
- storeId2 = await ctx.Database.GetDbConnection().ExecuteScalarAsync<string>(i.Sql, new { id });
- if (storeId2 is not null)
- {
- var id2 = storeId2;
- memoryCache.GetOrCreate(cacheKey, cacheEntry =>
- {
- cacheEntry.SlidingExpiration = TimeSpan.FromMinutes(10);
- return id2;
- });
- }
- // If the route is "pull-payments/DO-NOT-EXIT/edit", this will returns 403
- // For legacy, if the route is "stores/{storeId}/pull-payments/DO-NOT-EXIT/edit", the action itself needs to handle 404.
- else if (storeId is null)
- {
- authContext.Fail();
- return null;
- }
- }
- storeId ??= storeId2;
-
- // Consider the route /stores/{storeId}/apps/{appId}
- // This check is making sure that the `storeId` is matching the scope resolved from `appId`.
- if (storeId2 != storeId)
+ case RouteStoreResolver.Resolution.Invalid:
+ authContext.Fail();
+ return null;
+ case RouteStoreResolver.Resolution.Resolved resolved:
+ if (storeId is not null && resolved.StoreId != storeId)
{
authContext.Fail();
return null;
}
-
- if (storeId2 is not null)
- additionalScopes.Add(new AdditionalScope(i.RouteValue, id));
- }
+ storeId = resolved.StoreId;
+ providerContext.HttpContext.Items[AdditionalScopeKey] = resolved.AdditionalScopes;
+ break;
+ case RouteStoreResolver.Resolution.Unscoped:
+ providerContext.HttpContext.Items[AdditionalScopeKey] = Array.Empty<RouteStoreResolver.AdditionalScope>();
+ break;
}
- providerContext.HttpContext.Items[AdditionalScopeKey] = additionalScopes;
return storeId;
}
}
- internal record AdditionalScope(string ScopeName, string Scope);
-
public const string AdditionalScopeKey = "BuiltInPermissionScopeProvider-AdditionalScope";
public async Task<string?> GetScope(AuthorizationHandlerContext authContext, ScopeProviderAuthorizationContext providerContext)
{
### BTCPayServer/Security/RouteStoreResolver.cs
@@ -0,0 +1,64 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using BTCPayServer.Data;
+using Dapper;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Caching.Memory;
+
+namespace BTCPayServer.Security;
+
+public class RouteStoreResolver(
+ IEnumerable<BuiltInPermissionScopeProvider.RouteValueToStoreIdQuery> queries,
+ ApplicationDbContextFactory dbContextFactory,
+ IMemoryCache memoryCache)
+{
+ public abstract record Resolution
+ {
+ private Resolution() { }
+
+ public sealed record Unscoped : Resolution;
+ public sealed record Resolved(string StoreId, IReadOnlyList<AdditionalScope> AdditionalScopes) : Resolution;
+ public sealed record Invalid : Resolution;
+ }
+
+ static readonly MemoryCacheEntryOptions CacheOptions = new() { SlidingExpiration = TimeSpan.FromMinutes(10) };
+
+ readonly BuiltInPermissionScopeProvider.RouteValueToStoreIdQuery[] _queries = queries.ToArray();
+
+ public record AdditionalScope(string ScopeName, string Scope);
+
+ private async Task<string?> FindStoreId(BuiltInPermissionScopeProvider.RouteValueToStoreIdQuery query, string id)
+ {
+ var cacheKey = $"{nameof(RouteStoreResolver)}-{query.RouteValue}-{query.Sql}-{id}";
+ if (memoryCache.TryGetValue(cacheKey, out string? cached) && cached is not null)
+ return cached;
+
+ await using var ctx = dbContextFactory.CreateContext();
+ var storeId = await ctx.Database.GetDbConnection().ExecuteScalarAsync<string>(query.Sql, new { id });
+ if (storeId is not null)
+ memoryCache.Set(cacheKey, storeId, CacheOptions);
+ return storeId;
+ }
+
+ public async Task<Resolution> Resolve(RouteData routeData)
+ {
+ var storeId = routeData.Values.TryGetValue("storeId", out var storeIdValue) ? storeIdValue as string : null;
+ List<AdditionalScope> additionalScopes = new();
+ foreach (var query in _queries)
+ {
+ if (!routeData.Values.TryGetValue(query.RouteValue, out var idValue) || idValue is not string id)
+ continue;
+
+ additionalScopes.Add(new AdditionalScope(query.RouteValue, id));
+ var found = await FindStoreId(query, id);
+ if (found is null || (storeId is not null && storeId != found))
+ return new Resolution.Invalid();
+ storeId ??= found;
+ }
+ return storeId is null ? new Resolution.Unscoped() : new Resolution.Resolved(storeId, additionalScopes);
+ }
+}
### BTCPayServer/Security/SetContextFilter.cs
@@ -50,7 +50,7 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE
httpContext.SetStoresData(stores);
//TODO: We should probably do this on controller specific filters, this would be better example for plugins
- if (httpContext.Items.TryGetValue(BuiltInPermissionScopeProvider.AdditionalScopeKey, out var o) && o is IEnumerable<BuiltInPermissionScopeProvider.AdditionalScope> additionalScopes)
+ if (httpContext.Items.TryGetValue(BuiltInPermissionScopeProvider.AdditionalScopeKey, out var o) && o is IEnumerable<RouteStoreResolver.AdditionalScope> additionalScopes)
{
foreach (var additionalScope in additionalScopes)
{
### BTCPayServer/Views/UIInvoice/InvoiceReceipt.cshtml
@@ -48,13 +48,13 @@
<div id="InvoiceSummary" class="tile d-flex flex-wrap align-items-center justify-content-center">
@if (isProcessing)
{
- <div class="lead text-center p-4 fw-semibold" id="invoice-processing">
+ <div class="lead text-center p-4 fw-semibold" id="invoice-processing" text-translate="true">
The invoice has detected a payment but is still waiting to be settled.
</div>
}
else if (!isSettled)
{
- <div class="lead text-center p-4 fw-semibold" id="invoice-unsettled">
+ <div class="lead text-center p-4 fw-semibold" id="invoice-unsettled" text-translate="true">
The invoice is not settled.
</div>
}
@@ -74,7 +74,7 @@
</div>
}
<div class="invoice-summary__amount-paid d-flex flex-column">
- <dd class="text-muted mb-0 fw-semibold">Amount Paid</dd>
+ <dd class="text-muted mb-0 fw-semibold" text-translate="true">Amount Paid</dd>
<dt class="fs-2 mb-0 text-nowrap fw-semibold">@DisplayFormatter.Currency(Model.PaidAmount, Model.Currency, DisplayFormatter.CurrencyFormat.Symbol)</dt>
</div>
@if (Model.TaxIncluded != 0.0m)
@@ -96,14 +96,14 @@
</div>
}
</dl>
- <a href="?print=true" class="invoice-receipt__print-link flex-grow-0 align-self-start btn btn-secondary d-print-none fs-4" target="_blank" id="ReceiptLinkPrint">Print</a>
+ <a href="?print=true" class="invoice-receipt__print-link flex-grow-0 align-self-start btn btn-secondary d-print-none fs-4" target="_blank" id="ReceiptLinkPrint" text-translate="true">Print</a>
</div>
}
</div>
@if (isProcessing)
{
- <small class="d-block text-muted text-center px-4">This page will refresh periodically until the invoice is settled.</small>
+ <small class="d-block text-muted text-center px-4" text-translate="true">This page will refresh periodically until the invoice is settled.</small>
}
else if (isSettled)
{
@@ -128,16 +128,16 @@
if (Model.Payments?.Any() is true)
{
<div id="PaymentDetails" class="tile">
- <h2 class="h4 mb-3">Payment Details</h2>
+ <h2 class="h4 mb-3" text-translate="true">Payment Details</h2>
<div class="table-responsive my-0 d-print-none">
<table class="invoice table table-borderless">
<thead>
<tr>
- <th class="fw-normal text-secondary">Destination</th>
- <th class="fw-normal text-secondary">Payment</th>
- <th class="fw-normal text-secondary">Rate</th>
- <th class="fw-normal text-secondary">Payment Method</th>
- <th class="fw-normal text-secondary text-nowrap">Date</th>
+ <th class="fw-normal text-secondary" text-translate="true">Destination</th>
+ <th class="fw-normal text-secondary" text-translate="true">Payment</th>
+ <th class="fw-normal text-secondary" text-translate="true">Rate</th>
+ <th class="fw-normal text-secondary" text-translate="true">Payment Method</th>
+ <th class="fw-normal text-secondary text-nowrap" text-translate="true">Date</th>
</tr>
</thead>
@foreach (var payment in Model.Payments)
@@ -162,7 +162,7 @@
@if (!string.IsNullOrEmpty(payment.PaymentProof))
{
<tr>
- <th class="fw-normal text-nowrap text-secondary">
+ <th class="fw-normal text-nowrap text-secondary" text-translate="true">
Payment Proof
</th>
<td class="fw-normal" colspan="4">
@@ -178,10 +178,10 @@
@foreach (var payment in Model.Payments)
{
<div class="mb-4">
- <strong>@payment.PaidFormatted</strong> = @payment.Amount @payment.PaymentMethod, Rate: @payment.RateFormatted
+ <strong>@payment.PaidFormatted</strong> = @payment.Amount @payment.PaymentMethod, @StringLocalizer["Rate: {0}", payment.RateFormatted]
@if (!string.IsNullOrEmpty(payment.PaymentProof))
{
- <div>Proof: @payment.PaymentProof</div>
+ <div>@StringLocalizer["Proof: {0}", payment.PaymentProof]</div>
}
</div>
}
@@ -191,7 +191,7 @@
}
@if (!string.IsNullOrEmpty(Model.RedirectUrl))
{
- <a href="@Model.RedirectUrl" class="btn btn-secondary rounded-pill mx-auto mt-3" rel="noreferrer noopener" target="_blank" id="StoreLink">Return to @(string.IsNullOrEmpty(Model.StoreName) ? "store" : Model.StoreName)</a>
+ <a href="@Model.RedirectUrl" class="btn btn-secondary rounded-pill mx-auto mt-3" rel="noreferrer noopener" target="_blank" id="StoreLink">@(string.IsNullOrEmpty(Model.StoreName) ? StringLocalizer["Return to store"] : StringLocalizer["Return to {0}", Model.StoreName])</a>
}
</div>
</main>
### BTCPayServer/Views/UIInvoice/InvoiceReceiptPrint.cshtml
@@ -108,7 +108,7 @@
<div class="my-2 text-center small">
@if (!string.IsNullOrEmpty(Model.OrderId))
{
- <div>Order ID: @Model.OrderId</div>
+ <div>@StringLocalizer["Order ID: {0}", Model.OrderId]</div>
}
@Model.Timestamp.ToBrowserDate()
</div>
@@ -153,7 +153,7 @@
@if (posData.ItemsTotal != null)
{
<tr class="sums-data">
- <td class="key text-secondary">Items total</td>
+ <td class="key text-secondary" text-translate="true">Items total</td>
<td class="val text-end">@posData.ItemsTotal</td>
</tr>
}
@@ -228,15 +228,15 @@
@if (Model.Payments.Count > 1)
{
<tr>
- <td colspan="2" class="text-nowrap text-secondary">Payment @(i + 1)</td>
+ <td colspan="2" class="text-nowrap text-secondary">@StringLocalizer["Payment {0}", i + 1]</td>
</tr>
<tr class="payment-data">
<td class="text-nowrap">Received</td>
<td>@payment.ReceivedDate.ToBrowserDate()</td>
</tr>
}
<tr class="payment-data">
- <td class="text-nowrap text-secondary">@(Model.Payments.Count == 1 ? "Paid" : "")</td>
+ <td class="text-nowrap text-secondary">@(Model.Payments.Count == 1 ? StringLocalizer["Paid"].Value : "")</td>
<td class="text-end">@payment.AmountFormatted</td>
</tr>
<tr class="payment-data">
### BTCPayServer/Views/UIPaymentRequest/ViewPaymentRequest.cshtml
@@ -108,12 +108,12 @@
<p>
@if (Model.IsPending && Model.ExpiryDate.HasValue)
{
- <span class="text-muted">Due</span>
+ <span class="text-muted" text-translate="true">Due</span>
<span>@Model.ExpiryDate.Value.ToBrowserDate(ViewsRazor.DateDisplayFormat.Relative)</span>
}
else
{
- <span class="text-muted">No due date</span>
+ <span class="text-muted" text-translate="true">No due date</span>
}
</p>
<dl class="mt-n1 mb-4" v-if="srvModel.amountCollected > 0 && srvModel.amountDue > 0">
### BTCPayServer/Views/UIStores/GeneralSettings.cshtml
@@ -52,11 +52,16 @@
</button>
</div>
</div>
- <div class="form-group mb-0">
+ <div class="form-group">
<label asp-for="StoreWebsite" class="form-label"></label>
<input asp-for="StoreWebsite" class="form-control" />
<span asp-validation-for="StoreWebsite" class="text-danger"></span>
</div>
+ <div class="form-group mb-0">
+ <label asp-for="StorefrontLanguage" class="form-label"></label>
+ <select asp-for="StorefrontLanguage" asp-items="Model.StorefrontLanguages" class="form-select w-auto"></select>
+ <span asp-validation-for="StorefrontLanguage" class="text-danger"></span>
+ </div>
</div>
<h3 id="branding" class="settings-section__heading" text-translate="true">Branding</h3>Why this scored 24/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.