1

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

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

But I need it to be

so the numbers are translated.

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

Tau
  • 468
  • 3
  • 13

1 Answers1

1

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

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).

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...
Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
  • 1
    Superb!!... just the thing I was looking for. I can handle the conversion and everything, but just couldn't find this option. Thanku! – Tau Jan 19 '15 at 12:03
  • @Tau you welcome, with this I had the chance to add more details to [this post](http://stackoverflow.com/a/27229590/1207195)! – Adriano Repetti Jan 19 '15 at 12:25