-
Notifications
You must be signed in to change notification settings - Fork 95
Display Header names dynamically #753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
infofromca
wants to merge
16
commits into
OrchardCMS:main
Choose a base branch
from
infofromca:DisplayName
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0e5f46c
Dynamic display Price terms by IOptions<T> pattern
infofromca 5a18f8a
Add TableHeaders
infofromca 0d5cd17
use OrchardCore_Commerce_HeadersDisplayNames
infofromca 4c027d7
Merge branch 'main' into DisplayName
infofromca f6557ef
Apply IOptions<HeadersDisplayNamesOptions> options; on CheckoutStripe…
infofromca ec21612
Remove using on Startup.cs
infofromca 1c66ccf
backward compability by section.Exists()
infofromca 2e500c4
Clean
infofromca 0339dd9
use GetLocalizedShoppingCartHeaders method name
infofromca 7737b20
Update src/OrchardCore.Commerce.Web/appsettings.json
infofromca 11480a2
Update src/Modules/OrchardCore.Commerce/Startup.cs
infofromca 472e55d
use IHtmlLocalizer<HeadersDisplayNamesOptions> htmlLocalizer
infofromca e47f6b0
Merge branch 'DisplayName' of https://github.com/infofromca/OrchardCo…
infofromca c593d31
rename to _shellConfiguration
infofromca f5e13c1
Rename to LocalizationHelpers
infofromca 796f9ee
Add GetLocalizedGrossPriceName
infofromca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/Libraries/OrchardCore.Commerce.Abstractions/HeadersDisplayNamesOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace OrchardCore.Commerce.Abstractions; | ||
|
|
||
| public class HeadersDisplayNamesOptions | ||
| { | ||
| public string Price { get; set; } = "Price"; | ||
| public string NetPrice { get; set; } = "Net Price"; | ||
| public string GrossPrice { get; set; } = "Gross Price"; | ||
| public string OldPrice { get; set; } = "Old Price"; | ||
| public string Product { get; set; } = "Product"; | ||
| public string Quantity { get; set; } = "Quantity"; | ||
| public string Action { get; set; } = "Action"; | ||
| } |
42 changes: 42 additions & 0 deletions
42
src/Libraries/OrchardCore.Commerce.Abstractions/Helpers/LocalizationHelpers.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using Microsoft.AspNetCore.Mvc.Localization; | ||
| using OrchardCore.Commerce.Abstractions.Abstractions; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace OrchardCore.Commerce.Abstractions.Helpers; | ||
|
|
||
| public static class LocalizationHelpers | ||
| { | ||
| public static IList<LocalizedHtmlString> GetLocalizedShoppingCartHeaders(IHtmlLocalizer<HeadersDisplayNamesOptions> htmlLocalizer, HeadersDisplayNamesOptions options) => | ||
| [ | ||
| htmlLocalizer[options.Product], | ||
| htmlLocalizer[options.Quantity], | ||
| htmlLocalizer[options.Price], | ||
| htmlLocalizer[options.Action], | ||
| ]; | ||
|
|
||
| /// <summary> | ||
| /// Gets the localized string for Net Price. | ||
| /// </summary> | ||
| public static LocalizedHtmlString GetLocalizedNetPriceName( | ||
| IHtmlLocalizer<HeadersDisplayNamesOptions> htmlLocalizer, | ||
| HeadersDisplayNamesOptions options) => | ||
| htmlLocalizer[options.NetPrice]; | ||
|
|
||
| /// <summary> | ||
| /// Gets the localized string for Gross Price. | ||
| /// </summary> | ||
| public static LocalizedHtmlString GetLocalizedGrossPriceName( | ||
| IHtmlLocalizer<HeadersDisplayNamesOptions> htmlLocalizer, | ||
| HeadersDisplayNamesOptions options) => | ||
| htmlLocalizer[options.GrossPrice]; | ||
|
|
||
| /// <summary> | ||
| /// Formats a localized price label alongside an amount/total. | ||
| /// (e.g., "Net Price : $10.00") | ||
| /// </summary> | ||
| public static LocalizedHtmlString FormatPriceWithLabel( | ||
| IHtmlLocalizer<HeadersDisplayNamesOptions> htmlLocalizer, | ||
| string priceName, | ||
| object amount) => | ||
| htmlLocalizer["{0} : {1}", htmlLocalizer[priceName], amount]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
src/Modules/OrchardCore.Commerce/Views/PriceDisplaySettings.Edit.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
options.Value.NetPriceandoptions.Value.GrossPriceare not localized here. Add a helper toTableHeadersfor these, because they recur in other places as well.