ASP.Net MVC 5寻呼机号码更改语言 [英] ASP.Net MVC 5 Pager number change language

查看:168
本文介绍了ASP.Net MVC 5寻呼机号码更改语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用ASP.Net MVC 5建立我的web应用程序,并为分页目的我也跟着下面的教程。

I have been using ASP.Net MVC 5 to build my web application, and for pagination purpose I followed the below tutorial.

<一个href=\"http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application\" rel=\"nofollow\">http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application

一切工作如预期。但我的项目需要在寻呼机所示的页面列表将在孟加拉语,而不是英语,这取决于文化信息。

Everything works out as expected. But my project requires the page list shown in pager to be in Bengali instead of English, depending on the culture information.

例如。我在我的网页以下

E.g. I have the following in my page

1 2 3

但我需要它是

1 3

这样的数字折算。

有没有办法实现,使用我用PagedList.MVC组成部分?

Is there a way to achieve that using the PagedList.MVC component I used?

推荐答案

您可以使用 PagedListRenderOptions 来指定一个功能来格式化您的数字。改编自文档在GitHub上的例子:

You can use PagedListRenderOptions to specify a function to format your numbers. Example adapted from documentation on GitHub:

@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts,
    page => Url.Action("Index", new { page = page }),
    new PagedListRenderOptions {
        FunctionToDisplayEachPageNumber =
            page => page.ToString()
    }
)

关键点是这样的说明:页=&GT; page.ToString(),默认实现确实的String.Format(LinkToIndividualPageFormat,页),但你可以用自己的函数替换它(如在previous例子)。

Key point is this instructions: page => page.ToString(), default implementation simply does String.Format(LinkToIndividualPageFormat , page) but you can replace it with your own function (like in previous example).

不幸的是 page.ToString(新的CultureInfo(BN-IN))将不打印 1 作为 1 所以你必须用手工做。一个非常简单的例子(不使用这个,这是可怕的和低效)只是为了说明我的意思:

Unfortunately page.ToString(new CultureInfo("bn-IN")) won't print 1 as so you have to do it by hand. A very naive example (do not use this, it's terrible and inefficient) just to explain what I mean:

page => page.ToString()
    .Replace("1", "\u09e7") 
    .Replace("2", "\u09e8")
    .Replace("3", "\u09e9"); // And so on...

这篇关于ASP.Net MVC 5寻呼机号码更改语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆