diff --git a/BTCPayServer.Abstractions/Extensions/ITempDataDictionaryExtensions.cs b/BTCPayServer.Abstractions/Extensions/ITempDataDictionaryExtensions.cs index ddbd1679c..c9ed39e83 100644 --- a/BTCPayServer.Abstractions/Extensions/ITempDataDictionaryExtensions.cs +++ b/BTCPayServer.Abstractions/Extensions/ITempDataDictionaryExtensions.cs @@ -8,6 +8,14 @@ namespace BTCPayServer.Abstractions.Extensions; public static class SetStatusMessageModelExtensions { + public static void SetStatusSuccess(this ITempDataDictionary tempData, string statusMessage) + { + tempData.SetStatusMessageModel(new StatusMessageModel() + { + Severity = StatusMessageModel.StatusSeverity.Success, + Message = statusMessage + }); + } public static void SetStatusMessageModel(this ITempDataDictionary tempData, StatusMessageModel statusMessage) { if (statusMessage == null) diff --git a/BTCPayServer.Tests/UtilitiesTests.cs b/BTCPayServer.Tests/UtilitiesTests.cs index e98619a3f..54de670aa 100644 --- a/BTCPayServer.Tests/UtilitiesTests.cs +++ b/BTCPayServer.Tests/UtilitiesTests.cs @@ -16,11 +16,13 @@ using BTCPayServer.Client.Models; using BTCPayServer.Controllers; using ExchangeSharp; using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Extensions.FileSystemGlobbing; using NBitcoin; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -349,6 +351,8 @@ retry: { defaultTranslatedKeys.Add(k); } + + AddLocalizers(defaultTranslatedKeys, txt); } // Go through all cshtml file, search for text-translate or ViewLocalizer usage @@ -360,21 +364,11 @@ retry: { var filePath = file.FullName; var txt = File.ReadAllText(file.FullName); - foreach (string localizer in new[] { "ViewLocalizer", "StringLocalizer" }) - { - if (txt.Contains(localizer)) - { - var matches = Regex.Matches(txt, localizer + "\\[\"(.*?)\"[\\],]"); - foreach (Match match in matches) - { - defaultTranslatedKeys.Add(match.Groups[1].Value); - } - } - } + AddLocalizers(defaultTranslatedKeys, txt); filePath = filePath.Replace(Path.Combine(soldir.FullName, "BTCPayServer"), "/"); var item = engine.FileSystem.GetItem(filePath); - + var node = (DocumentIntermediateNode)engine.Process(item).Items[typeof(DocumentIntermediateNode)]; var w = new TranslatedKeyNodeWalker(defaultTranslatedKeys, txt); w.Visit(node); @@ -397,6 +391,24 @@ retry: content += defaultTranslation.Substring(endIdx); File.WriteAllText(path, content); } + + private static void AddLocalizers(List defaultTranslatedKeys, string txt) + { + foreach (string localizer in new[] { "ViewLocalizer", "StringLocalizer" }) + { + if (txt.Contains(localizer)) + { + var matches = Regex.Matches(txt, localizer + "\\[\"(.*?)\"[\\],]"); + foreach (Match match in matches) + { + var k = match.Groups[1].Value; + k = k.Replace("\\", ""); + defaultTranslatedKeys.Add(k); + } + } + } + } + class DisplayNameWalker : CSharpSyntaxWalker { public List Keys = new List(); diff --git a/BTCPayServer/Components/MainNav/Default.cshtml b/BTCPayServer/Components/MainNav/Default.cshtml index 0f6a6afa0..9ccd36a0d 100644 --- a/BTCPayServer/Components/MainNav/Default.cshtml +++ b/BTCPayServer/Components/MainNav/Default.cshtml @@ -107,13 +107,13 @@ @if (ViewData.IsCategoryActive(typeof(WalletsNavPages), scheme.WalletId.ToString()) || ViewData.IsPageActive([WalletsNavPages.Settings], scheme.WalletId.ToString()) || ViewData.IsPageActive([StoreNavPages.OnchainSettings], categoryId)) { } @@ -143,7 +143,7 @@ @if (ViewData.IsPageActive([StoreNavPages.Lightning, StoreNavPages.LightningSettings], $"{Model.Store.Id}-{scheme.CryptoCode}")) { } diff --git a/BTCPayServer/Components/StoreLightningBalance/Default.cshtml b/BTCPayServer/Components/StoreLightningBalance/Default.cshtml index 8ab1c3d52..59c40733e 100644 --- a/BTCPayServer/Components/StoreLightningBalance/Default.cshtml +++ b/BTCPayServer/Components/StoreLightningBalance/Default.cshtml @@ -5,7 +5,7 @@ }
-
Lightning Balance
+
Lightning Balance
@if (Model.CryptoCode != Model.DefaultCurrency && Model.Balance != null) {
@@ -29,7 +29,7 @@

@Model.TotalOffchain

- @Model.CryptoCode in channels + @ViewLocalizer["{0} in channels", @Model.CryptoCode]
@@ -41,7 +41,7 @@ @Model.Balance.OffchainBalance.Opening - @Model.CryptoCode opening channels + @ViewLocalizer["{0} opening channels", @Model.CryptoCode]
} @@ -52,7 +52,7 @@ @Model.Balance.OffchainBalance.Local - @Model.CryptoCode local balance + @ViewLocalizer["{0} local balance", @Model.CryptoCode]
} @@ -63,7 +63,7 @@ @Model.Balance.OffchainBalance.Remote - @Model.CryptoCode remote balance + @ViewLocalizer["{0} remote balance", @Model.CryptoCode]
} @@ -74,7 +74,7 @@ @Model.Balance.OffchainBalance.Closing - @Model.CryptoCode closing channels + @ViewLocalizer["{0} closing channels", @Model.CryptoCode] } @@ -87,7 +87,7 @@

@Model.TotalOnchain

- @Model.CryptoCode on-chain + @ViewLocalizer["{0} on-chain", @Model.CryptoCode]
@@ -98,7 +98,7 @@ @Model.Balance.OnchainBalance.Confirmed - @Model.CryptoCode confirmed + @ViewLocalizer["{0} confirmed", @Model.CryptoCode]
} @@ -109,7 +109,7 @@ @Model.Balance.OnchainBalance.Unconfirmed - @Model.CryptoCode unconfirmed + @ViewLocalizer["{0} unconfirmed", @Model.CryptoCode] } @@ -120,7 +120,7 @@ @Model.Balance.OnchainBalance.Reserved - @Model.CryptoCode reserved + @ViewLocalizer["{0} reserved", @Model.CryptoCode] } @@ -132,7 +132,7 @@ { } } @@ -140,7 +140,7 @@ {
- Loading... + Loading...
- + @if (Model.WalletEnabled) { - + } else {
-
This store is ready to accept transactions, good job!
+
This store is ready to accept transactions, good job!
- +
-
Set up a Lightning node
+
Set up a Lightning node
- +
-
Set up a wallet
+
Set up a wallet
- +
} - + @if (Model.LightningEnabled) { - - + + } @if (Model.WalletEnabled) { - + } - + @foreach (var app in Model.Apps) { - - + + }
} else { -

To start accepting payments, set up a wallet or a Lightning node.

- +

To start accepting payments, set up a wallet or a Lightning node.

+
- +
-
Create your store
+
Create your store
@if (Model.Network is BTCPayNetwork) @@ -113,40 +113,41 @@ else @if (!Model.WalletEnabled) { - +
-
Set up a wallet
+
Set up a wallet
- +
} else {
- +
-
Set up a wallet
+
Set up a wallet
} } - @if (Model.LightningSupported) { + @if (Model.LightningSupported) + { if (!Model.LightningEnabled) { - +
-
Set up a Lightning node
+
Set up a Lightning node
- +
} else {
- +
-
Set up a Lightning node
+
Set up a Lightning node
} diff --git a/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml b/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml index 55805c5df..85b3de9d5 100644 --- a/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml +++ b/BTCPayServer/Views/UIStores/SetupLightningNode.cshtml @@ -1,7 +1,7 @@ @model LightningNodeViewModel @{ Layout = "_LayoutWalletSetup.cshtml"; - ViewData.SetActivePage(StoreNavPages.LightningSettings, "Connect to a Lightning node", Context.GetStoreData().Id); + ViewData.SetActivePage(StoreNavPages.LightningSettings, StringLocalizer["Connect to a Lightning node"], Context.GetStoreData().Id); } @section PageHeadContent { @@ -28,10 +28,10 @@
@@ -40,24 +40,24 @@
@if (Model.CanUseInternalNode) { -

Using the BTCPay Server internal node for this store requires no further configuration. Click the save button below to start accepting Bitcoin through the Lightning Network.

+

Using the BTCPay Server internal node for this store requires no further configuration. Click the save button below to start accepting Bitcoin through the Lightning Network.

} else { -

Your instance administrator has disabled the use of the Internal node for non-admin users.

+

Your instance administrator has disabled the use of the Internal node for non-admin users.

}
- +
- +
-

BTCPay Server currently supports:

+

BTCPay Server currently supports:

diff --git a/BTCPayServer/Views/UIUserStores/_CreateStoreForm.cshtml b/BTCPayServer/Views/UIUserStores/_CreateStoreForm.cshtml index 7fb54b81f..12938aa26 100644 --- a/BTCPayServer/Views/UIUserStores/_CreateStoreForm.cshtml +++ b/BTCPayServer/Views/UIUserStores/_CreateStoreForm.cshtml @@ -18,7 +18,7 @@
-
The recommended price source gets chosen based on the default currency.
+
The recommended price source gets chosen based on the default currency.
diff --git a/BTCPayServer/_ViewImports.cshtml b/BTCPayServer/_ViewImports.cshtml index 126ef2fb6..f7629b2a8 100644 --- a/BTCPayServer/_ViewImports.cshtml +++ b/BTCPayServer/_ViewImports.cshtml @@ -11,6 +11,7 @@ @using Microsoft.AspNetCore.Routing; @using BTCPayServer.Abstractions.Extensions; @inject Microsoft.AspNetCore.Mvc.Localization.ViewLocalizer ViewLocalizer +@inject Microsoft.Extensions.Localization.IStringLocalizer StringLocalizer @inject Safe Safe @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, BTCPayServer