Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Route Translation and UiCulture Constraint #290

Open
BoasE opened this issue Jul 3, 2014 · 0 comments
Open

Custom Route Translation and UiCulture Constraint #290

BoasE opened this issue Jul 3, 2014 · 0 comments

Comments

@BoasE
Copy link

BoasE commented Jul 3, 2014

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;
            });

        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant