0

I have a HorseController with its Index method like:

 [GET("Index", TranslationKey = "HorseIndex")]
    [AllowAnonymous]
    public ActionResult Index(int? page, HorseTypes? type, HorseGenders? gender, HorseBreeds? breed, HorseJumps? jump,
        HorseDressages? dressage, String maxAge, String priceFrom, String priceTo, Country? country, bool? hasPicture, bool? hasVideo)
        {
...
}

and I translate this route like:

 provider.AddTranslations()
       .ForKey("HorseIndex", new Dictionary<string, string>
            {
                { "da", "heste-til-salg" },
                { "en", "horses-for-sale" }
            })

The issue is that now, the url for a danish user is:

http://localhost:12623/heste-til-salg?page=1&hasPicture=False&hasVideo=False

My question is how to translate query parameters too?

I am not able to find this in documentation.

Cristian Boariu
  • 9,603
  • 14
  • 91
  • 162

2 Answers2

0

I don't think you can. The querystring in MVC routes is treated as a generic dumping ground for any data passed along that doesn't fit in the URL. If it's not generic data that you don't know about at design time, then it should just be part of your URL. If it is generic data, then there's obviously no way to provide a translation for any and all extraneous data that might show up in a querystring.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
0

you can accept translated parameters and in the controller method use StringsLocalized to translate.