Open LazZiya opened 1 year ago
Check if you have a culture paramter setup already made in page route, if so remove it because the code below is already adding the culture parameter to all routes.
.AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))
Or delete the above line if you want to use your own culture parameter setup.
@LazZiya
After remove this line -> .AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))
when choosing language -> error
This localhost page can’t be foundNo webpage was found for the web address: https://localhost:44349/ar HTTP ERROR 404
After removing that line you need to manually add the culture parameter to the routes {culture}
add to this line -> like this <language-nav cookie-handler-url="@Url.Action("SetCultureCookie", "Home", "{culture}",new { area="", cltr="{0}", returnUrl="{1}", culture=CultureInfo.CurrentCulture.Name })">
So if it is ok now we can close this issue, is it?
@LazZiya
sir, when using the package LazZiya.ExpressLocalization
after running the code shown in this route -> https://localhost:44349/en/Identity/Account/Login/?ReturnUrl=/en/
so, this route is wrong and this true route -> https://localhost:44349/Account/Login/?culture=en
so how to edit my route to be true
and this is my code in program.cs
CultureInfo us = new CultureInfo("en-US"); var cultures = new CultureInfo[] { new CultureInfo("en"), new CultureInfo("ar") { DateTimeFormat = us.DateTimeFormat } };
// Add services to the container. builder.Services.AddControllersWithViews()
.AddExpressLocalization<LocSource>(
ops =>
{
ops.ResourcesPath = "LocalizationResources";
ops.RequestLocalizationOptions = o =>
{
o.SupportedCultures = cultures;
o.SupportedUICultures = cultures;
o.DefaultRequestCulture = new RequestCulture("en");
};
});
app.UseRequestLocalization();
Well, I see you are using LazZiya.ExpressLocalization
, I recommend you switch to XLocalizer
, it is much better in terms of flexibility and provides better support for newer frameworks.
After removing that line you need to manually add the culture parameter to the routes {culture}
@LazZiya
how invested this lin by parameter {culture}
.AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))
please tell me step by step
With reference to XLocalizer version of RouteTemplateModelConventionMvc()
, it adds a route parameter named {culture?}
to all routes in the app, so you don't have to add it manually to each route in the routing table.
// e.g.:
[controller]/[action] --> {culture?}/[controller]/[action]
Hi @Malkawi1 ,
Do you still need support with this issue?
Originally posted by @Malkawi1 in https://github.com/LazZiya/XLocalizer/issues/2#issuecomment-1328900840
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)