0

我有一个带有 Index 方法的 HorseController,例如:

 [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)
        {
...
}

我把这条路线翻译成:

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

问题是现在,丹麦用户的网址是:

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

我的问题是如何翻译查询参数呢?

我无法在文档中找到它。

4

2 回答 2

0

我不认为你可以。MVC 路由中的查询字符串被视为传递的任何不适合 URL 的数据的通用转储场。如果它不是您在设计时不知道的通用数据,那么它应该只是您的 URL 的一部分。如果它是通用数据,那么显然无法为可能出现在查询字符串中的任何和所有无关数据提供翻译。

于 2013-04-01T15:43:12.813 回答
0

您可以接受已翻译的参数,并在控制器方法中使用 StringsLocalized 进行翻译。

于 2013-12-16T11:30:06.367 回答