Closed ramedey closed 6 years ago
TranslateInitialAttributeRoutes is just a more or less convenient helper method. There is nothing to stop you call your own logic. You could use AttributeRouteProcessing.None
or skip calling TranslateInitialAttributeRoutes
and run this in your Translate
function:
localization.Configuration.UseUntranslatedAttributePrefixes = false;
localization.Configuration.AddCultureAsRoutePrefix = false;
localization.Configuration.LocalizationCollectionRoutes.ForEach(
route => localization.AddTranslation(route.Route.Url(), "en", (LocalizationCollectionRoute)route.Route));
localization.Configuration.AddCultureAsRoutePrefix = true;
localization.Configuration.LocalizationCollectionRoutes.ForEach(
route => localization.AddTranslation(route.Route.Url(), "nl", (LocalizationCollectionRoute)route.Route));
Please let me know if this works for you and happy new year.
Yes, you are right. I think this might solve my problem.
Thanks!
Hi,
I have support for two cultures in my website, EN and NL (the default is EN), but I want to have the culture as a prefix only for NL. I also need to generate all routes for NL using the attribute routes automatically with localization.TranslateInitialAttributeRoutes(). For example, for the pricing page I need these two routes:
/pricing /nl/pricing
For some reason, I can't implement this. If I use AttributeRouteProcessing = AddAsNeutralRoute, it won't generate all NL routes, and if I use AttributeRouteProcessing = AddAsNeutralAndDefaultCultureRoute, it will generate this:
/pricing /en/pricing /nl/pricing
Any ideas? Thanks!