MVC & Globalization / Localization

Last post 08-28-2008 11:52 AM by timstewart. 7 replies.

Sort Posts:

  • MVC & Globalization / Localization

    01-16-2008, 7:41 PM
    • Loading...
    • jbgoldcoast
    • Joined on 12-13-2006, 6:58 AM
    • Gold Coast, QLD Aust
    • Posts 9

    Thus far I haven't seen any information on MVC support for Globalization and Localization.
    But from my research, ASP.NET 2.0 handles it via any tag that has runat=server, something that MVC hasn't got.
    I have my ideas about how it might be done, but I will leave the question open-ended, hear what Microsoft has to say.

    No doubt ScottGu will eventually do an awesome post on it, but I can't really wait that long, my employer is on the eve of embarking on a web application with globalization concerns, and we are also assessing the MVC framework.
     

  • Re: MVC & Globalization / Localization

    01-17-2008, 1:42 AM
    • Loading...
    • dimi3
    • Joined on 12-13-2007, 5:02 PM
    • Posts 133

     I am also deeply interested in that subject and hope to see something clean about it soon.

  • Re: MVC & Globalization / Localization

    02-14-2008, 7:01 PM
    • Loading...
    • pure.krome
    • Joined on 05-28-2006, 4:45 AM
    • Melbourne, Australia
    • Posts 258

    Yep - same here. In fact, it's a must, for converting our website.

    So, lets try and nut this out.

    Here is the asp.net official quickstart tutorial for localization: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/default.aspx

    Supposedly, ScottGu says that localization should work Out Of the Box with the current release of the ASP.NET MVC

    scotty:

    http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx

    The MVC framework supports using the existing ASP.NET .ASPX, .ASCX, and .Master markup files as "view templates" (meaning you can easily use existing ASP.NET features like nested master pages, <%= %> snippets, declarative server controls, templates, data-binding, localization, etc).

    So lets try a traditional way ... :-

    a) Create a view -> \Views\Index.aspx
    b) Create a resource folder and files:-
       \Views\App_LocalResources\Index.aspx.resx   <-- default or culture neutral
       \Views\App_LocalResources\Index.aspx.fr.resx  <-- French
       \Views\App_LocalResources\Index.aspx.de.resx  <-- german
    c) wireup some text / html to be 'localized' :-
       <asp:Literal runat="server" text="<%$ Resources:SomeKeyInTheResourceFile %>" />

    .. and that works :)

    To test this out, you can make the page AUTO DETECT the browser 'language' setting, and then play around with the browsers language list preferences.

     

    That said, i was hoping to do this without the use of an asp:control ... like..
       <span><%$ Resources:SomeKeyInTheResourceFile %></span>   <-- insert localized content.

    ... but that doesn't work .. and i have no idea how to do it without an asp.control :(

    :: Never underestimate the predictability of stupidity ::
  • Re: MVC & Globalization / Localization

    02-15-2008, 12:24 AM
    • Loading...
    • wcpierce
    • Joined on 09-02-2005, 9:45 PM
    • Colorado, US
    • Posts 16

    Here is an approach that is a little simpler. 

    http://forums.asp.net/p/1198465/2079186.aspx#2079186 

  • Re: MVC & Globalization / Localization

    02-15-2008, 2:47 AM
    • Loading...
    • mrfleck
    • Joined on 12-19-2007, 2:12 AM
    • Posts 93

    I am using the simpler approach of global resources as mentioned above and it works like a charm. There is also a database provider that makes things even easier. It caches on load -up so the speed is the same. Here is that project if you want to check it out. : http://www.west-wind.com/tools/wwDbResourceProvider/docs/ It is an older version but still works without too much tweaking.

  • Re: MVC & Globalization / Localization

    02-15-2008, 10:03 AM

    pure.krome:

    That said, i was hoping to do this without the use of an asp:control ... like..
       <span><%$ Resources:SomeKeyInTheResourceFile %></span>   <-- insert localized content.

    ... but that doesn't work .. and i have no idea how to do it without an asp.control :(

     Here's what I've been doing and it works great:   

    <span><%= Resources.ResourceClassName.Resource_Key %></span>
     
  • Re: MVC & Globalization / Localization

    02-15-2008, 9:23 PM
    • Loading...
    • pure.krome
    • Joined on 05-28-2006, 4:45 AM
    • Melbourne, Australia
    • Posts 258

    sweet dude :) i have to give that a go, next week at work.

     uber cheers!

    3 cheers to these MVC forums :)

    :: Never underestimate the predictability of stupidity ::
  • Re: MVC & Globalization / Localization

    08-28-2008, 11:52 AM
    • Loading...
    • timstewart
    • Joined on 08-28-2008, 11:49 AM
    • Posts 1

     Based on this thread, I decided to go ahead and try to use the West Wind provider, but so far haven't been able to get it working... I just get an empty admin tool, even when I add records to the Localizations table manually.

     Would you mind detailing how you managed to get it to work, including the LocalizationAdmin tool?

     

    TIA,

     

    -= Tim

Page 1 of 1 (8 items)
Microsoft Communities
Page view counter