Skip to content
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

Move CultureValue to OC.Localization module #16971

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
using Fluid.Values;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Liquid;
using OrchardCore.Localization;

namespace OrchardCore.DisplayManagement.Liquid.Values;
namespace OrchardCore.Localization.Liquid;

internal sealed class CultureValue : FluidValue
{
Expand Down
12 changes: 12 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Localization/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Fluid;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -8,6 +9,7 @@
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Environment.Shell;
using OrchardCore.Localization.Drivers;
using OrchardCore.Localization.Liquid;
using OrchardCore.Localization.Models;
using OrchardCore.Localization.Services;
using OrchardCore.Modules;
Expand Down Expand Up @@ -97,3 +99,13 @@ public override void ConfigureServices(IServiceCollection services)
options.AddInitialRequestCultureProvider(new AdminCookieCultureProvider(_shellSettings, _adminOptions)));
}
}

[RequireFeatures("OrchardCore.Liquid")]
public sealed class LocalizationLiquidStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<TemplateOptions>(options
=> options.Scope.SetValue("Culture", new CultureValue()));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Globalization;
using Fluid;
using Fluid.Values;
using Microsoft.AspNetCore.Html;
Expand All @@ -13,12 +12,10 @@
using OrchardCore.DisplayManagement.Liquid.Filters;
using OrchardCore.DisplayManagement.Liquid.TagHelpers;
using OrchardCore.DisplayManagement.Liquid.Tags;
using OrchardCore.DisplayManagement.Liquid.Values;
using OrchardCore.DisplayManagement.Razor;
using OrchardCore.DisplayManagement.Shapes;
using OrchardCore.DisplayManagement.Zones;
using OrchardCore.Liquid;
using OrchardCore.Localization;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -69,8 +66,6 @@ public static OrchardCoreBuilder AddLiquidViews(this OrchardCoreBuilder builder)
o.MemberAccessStrategy.Register<ZoneHolding>("*", new ShapeAccessor());
o.MemberAccessStrategy.Register<ShapeMetadata>();

o.Scope.SetValue("Culture", new CultureValue());

o.Scope.SetValue("Environment", new ObjectValue(new LiquidEnvironmentAccessor()));
o.MemberAccessStrategy.Register<LiquidEnvironmentAccessor, FluidValue>((obj, name, ctx) =>
{
Expand Down