40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.JSInterop;
|
|
using SoloX.BlazorJsonLocalization;
|
|
|
|
namespace UI.Config.Register
|
|
{
|
|
public class LocalizationHttpClient : HttpClient { }
|
|
|
|
public static class LocalizationSetup
|
|
{
|
|
public static IServiceCollection RegLocalization(
|
|
this IServiceCollection services,
|
|
string address
|
|
)
|
|
{
|
|
services.AddHttpClient<LocalizationHttpClient>(sp =>
|
|
{
|
|
sp.BaseAddress = new Uri(address);
|
|
});
|
|
services.AddJsonLocalization(builder =>
|
|
{
|
|
builder
|
|
.UseHttpClientJson(options =>
|
|
{
|
|
|
|
options.ResourcesPath = "resources";
|
|
options.Assemblies = [typeof(LayoutLib.RCL.SharedRes).Assembly, typeof(Auth.RCL.SharedRes).Assembly, typeof(ECommerce.RCL.SharedRes).Assembly];
|
|
options.HttpClientBuilder = sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient(nameof(LocalizationHttpClient));
|
|
|
|
});
|
|
}, ServiceLifetime.Singleton);
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|