Hi @Boucourt,
Firstly, you may misspell the word, it should be typeof(SharedResource)
instead of typeof(SharedResources)
.
Be sure configure the localization in Program.cs like below:
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
builder.Services
.AddMvc()
.AddDataAnnotationsLocalization(
options =>
{
options.DataAnnotationLocalizerProvider =
(type, factory) =>
{
var assemblyName =
new AssemblyName(
typeof(SharedResource)
.GetTypeInfo()
.Assembly.FullName!);
return factory.Create("SharedResource", assemblyName.Name!);
};
});
var app = builder.Build();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
var supportedCultures = new[]
{
new CultureInfo("en-US"), // Default culture
new CultureInfo("fr-CA"), // French culture
// Add more cultures as needed
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
If the.resx file content which you shared in the question is SharedResource.fr-CA.resx. You need send request https://localhost:portNumber/xxx?culture=fr-CA.
The label will display the value:Photo depicting the episode
.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Rena