Skip to content

Commit

Permalink
feat(templates): Render currency symbol correctly in Boilerplate #9752 (
Browse files Browse the repository at this point in the history
  • Loading branch information
msynk authored Jan 30, 2025
1 parent 91b4cab commit c594106
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<BitText Typography="BitTypography.H1">@product.Name</BitText>
</BitLink>
<BitText Typography="BitTypography.H6" Class="carousel-desc">@product.Description</BitText>
<BitText Typography="BitTypography.H4">@product.Price.ToString("C")</BitText>
<BitText Typography="BitTypography.H4">@product.FormattedPrice</BitText>

</BitStack>
</BitStack>
Expand All @@ -53,7 +53,7 @@
<ProductImage Src="@GetProductImageUrl(product)" Width="100%" />
<BitText>@product.Name</BitText>
<BitText Typography="BitTypography.Body2">@product.Description</BitText>
<BitText Typography="BitTypography.H6">@product.Price.ToString("C")</BitText>
<BitText Typography="BitTypography.H6">@product.FormattedPrice</BitText>
</BitStack>
</BitCard>
</BitLink>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//+:cnd:noEmit
using Boilerplate.Shared.Dtos.Products;
using Boilerplate.Shared.Dtos.Statistics;
using Boilerplate.Shared.Controllers.Products;
using Boilerplate.Shared.Controllers.Statistics;

//#if(module == "Sales")
using Boilerplate.Shared.Dtos.Products;
//#endif
namespace Boilerplate.Client.Core.Components.Pages;

public partial class HomePage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<BitText Typography="BitTypography.H2">@product.Name</BitText>
<BitText Color="BitColor.Info">@product.CategoryName</BitText>
<BitText Typography="BitTypography.H6">@product.Description</BitText>
<BitText Typography="BitTypography.H4">@product.Price.ToString("C")</BitText>
<BitText Typography="BitTypography.H4">@product.FormattedPrice</BitText>
</BitStack>
</BitStack>
</BitCard>
Expand Down Expand Up @@ -102,7 +102,7 @@
<ProductImage Src="@GetProductImageUrl(prd)" Width="100%" />
<BitText>@prd.Name</BitText>
<BitText Typography="BitTypography.Body2">@prd.Description</BitText>
<BitText Typography="BitTypography.H6">@prd.Price.ToString("C")</BitText>
<BitText Typography="BitTypography.H6">@prd.FormattedPrice</BitText>
</BitStack>
</BitCard>
</BitLink>
Expand Down Expand Up @@ -148,7 +148,7 @@
<ProductImage Src="@GetProductImageUrl(prd)" Width="100%" />
<BitText>@prd.Name</BitText>
<BitText Typography="BitTypography.Body2">@prd.Description</BitText>
<BitText Typography="BitTypography.H6">@prd.Price.ToString("C")</BitText>
<BitText Typography="BitTypography.H6">@prd.FormattedPrice</BitText>
</BitStack>
</BitCard>
</BitLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@ public partial class ProductDto
? null
: new Uri(absoluteServerAddress, $"/api/Attachment/GetProductImage/{Id}?v={ConcurrencyStamp}").ToString();
}

public string FormattedPrice => FormatPrice();

private string FormatPrice()
{
if (CultureInfoManager.MultilingualEnabled)
{
return CultureInfo.CurrentCulture.TextInfo.IsRightToLeft
? $"{Price:N0} {CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol}"
: Price.ToString("C");
}

return Price.ToString("N0");
}
}

0 comments on commit c594106

Please sign in to comment.