views:

2643

answers:

4

I am looking at globalizing an application that I have developed in asp.net mvc.

I am currently using resource files to store messages that I present to the user (i.e., when I save something to the database, and the user is shown the message "The whatever was correctly saved", that text is stored in a resource file so that I can easily localize the message for another language.

The question I have is how to do this in a view as a whole? Right now, I've got some views that are mostly HTML with some small amount of presentation logic.

What is the best practice for localizing a view? I've taken a look here:

The approach in that post seems like an interesting way to go, but I wonder how easy it will be to maintain separate views for every language.

NOTE: I have not done much globalization or localization in asp.net generally, so there may be some best practices from the non-mvc world that I am missing.

+3  A: 

We ran into the same problem with our new MVC application and our solution is here. Maintaining separate views could be hard work, but maintaining the same view with different languages appears to be just as difficult, we decided that maintaining the whole view would give us more power, which would be required to make a release for Asian countries.

Hopefully it helps you.

Odd
A: 

Use an App_LocalResources for each view folder and place resources for each view in the folder and each culture.

More info here.

Andrei Rinea
A: 

You could try setting up your routes to be something like:

    RouteTable.Routes.MapRoute(
        "Globalization",
        "{localization}/{controller}/{action}/{id}",
        new { localization = "en-us", controller = "Globalization", action = "Index", id = "" }
        );

and then have localization as a parameter to your actions, just as id is a parameter.

ccook
A: 

Hi

I have implemented globalization with app_localresources and

RouteTable.Routes.MapRoute(
        "Globalization",
        "{localization}/{controller}/{action}/{id}",
        new { localization = "en-us", controller = "Globalization", action = "Index", id = "" }
        );

my problem is with the error page that doesn't get localized properly

in web.config i have default set to "/Error" or tried also "/Home/Error"

my problem is when an error happens on page /fr/home/index , global.asax application_error gets fired and sends me to /Error or /Home/Error , I lose my current culture.

how can i get it to send to /fr/error or /fr/home/error ?

freddoo