Skip to content

Custom Route Translation and UiCulture Constraint #290

@BoasE

Description

@BoasE

I translate routes with a custom translator. But a user can now call both. The origin (nontranslated) url and the translated url .

I want the user to only call the translated ur. I expected the ConstrainTranslatedRoutesByCurrentUICulture todo so but it doesn't
This only prevents the user to call other localizations but does not prevent the user to to call the untranslated url.

Am I doing something wrong or is this an expected behavior ?

        public override string GetTranslation(string key, string cultureName)
        {
            if (key == "url_users")
            {
                return "foo";
            }

            return null;
        }

i've a controller like this:

   public class HomeController : Controller
    {
        [GET("users", TranslationKey = "url_users")]

        public ActionResult Users()
        {
            return View();
        }
    }

and my configuration method looks like that:

         var translator = new AttributeRoutingTranslator();
            routes.MapAttributeRoutes(config =>
            {
                config.AddRoutesFromAssembly(typeof(AttributeRoutingConfig).Assembly);
                config.AddTranslationProvider(translator);
                config.ConstrainTranslatedRoutesByCurrentUICulture = true;
            });

        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions