Skip to content

Commit

Permalink
Update CultureValue.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored Nov 7, 2024
1 parent 1904a47 commit 9b91767
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ namespace OrchardCore.DisplayManagement.Liquid.Values;

internal sealed class CultureValue : FluidValue
{
private readonly CultureInfo _culture;

public CultureValue() => _culture = CultureInfo.CurrentUICulture;

public override FluidValues Type => FluidValues.Object;

public override bool Equals(FluidValue other)
Expand Down Expand Up @@ -43,11 +39,11 @@ public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder enco
protected override FluidValue GetValue(string name, TemplateContext context)
=> name switch
{
nameof(CultureInfo.Name) => new StringValue(_culture.Name),
"Dir" => new StringValue(_culture.GetLanguageDirection()),
nameof(CultureInfo.NativeName) => new StringValue(_culture.NativeName),
nameof(CultureInfo.DisplayName) => new StringValue(_culture.DisplayName),
nameof(CultureInfo.TwoLetterISOLanguageName) => new StringValue(_culture.TwoLetterISOLanguageName),
nameof(CultureInfo.Name) => new StringValue(CultureInfo.CurrentUICulture.Name),
"Dir" => new StringValue(CultureInfo.CurrentUICulture.GetLanguageDirection()),
nameof(CultureInfo.NativeName) => new StringValue(CultureInfo.CurrentUICulture.NativeName),
nameof(CultureInfo.DisplayName) => new StringValue(CultureInfo.CurrentUICulture.DisplayName),
nameof(CultureInfo.TwoLetterISOLanguageName) => new StringValue(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName),
_ => NilValue.Instance
};
}

0 comments on commit 9b91767

Please sign in to comment.