-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add supported_cultures liquid filter
Fix #16202
- Loading branch information
1 parent
8ef3a02
commit b7619ad
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Filters/SupportedCulturesFilter.cs
This file contains 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,26 @@ | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Fluid; | ||
using Fluid.Values; | ||
using OrchardCore.Liquid; | ||
using OrchardCore.Localization; | ||
|
||
namespace OrchardCore.DisplayManagement.Liquid.Filters; | ||
|
||
public class SupportedCulturesFilter : ILiquidFilter | ||
{ | ||
private readonly ILocalizationService _localizationService; | ||
|
||
public SupportedCulturesFilter(ILocalizationService localizationService) | ||
{ | ||
_localizationService = localizationService; | ||
} | ||
|
||
public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext context) | ||
{ | ||
var supportedCultures = await _localizationService.GetSupportedCulturesAsync(); | ||
|
||
return new ArrayValue(supportedCultures.Select(x => new ObjectValue(CultureInfo.GetCultureInfo(x))).ToArray()); | ||
} | ||
} |
This file contains 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 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