2

I've read tutorials etc on the web about localization in Asp.Net and MVC, but I don't think I get it. It all seems like a very messy way of handling pages if you do it as described...

Say I have a bunch of views with lots of paragraphs of text. The below would only be a partial example, there would usually be much more on a page:

<div id="homePageSidebar" class="roundedBox">
    <div class="infoBoxHeader">
        <h2>
            <%:Html.ActionLink("Who are we?", "About") %>
        </h2>
    </div>
    <div class="infoBoxContent">
        <p>
            Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
        </p>
        <p id="frontpagedesc">
             Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
        </p>
       <p id="frontpagedesc">
             Bla bla bla bla <a href="blabla">bla bla bla</a> bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla <i>bla bla bla</i> bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.
        </p>
    </div>

</div>

So if I understand correctly, I am supposed to replace the text in each

tag with something like <%=ViewRes.SharedStrings.Blabla_paragraph%>, <%=ViewRes.SharedStrings.Blabla2_paragraph%> etc?

And on top of it, this text (with sometimes rather long paragraphs) should be entered in an editor that seems far from adapted to editing long paragraphs of text (the database-like editor for resource files)?

And then, instead of having easily edited view files I will have files filled with these resource identifiers (which I am sure will seem rather cryptic after a while)? And to edit content, I will have to jump back and forward from the resource file and the view...

And what about links, italics, etc. Will these be hardcoded in raw html in the resource file, or should the text be fragmented even further (text up until a link as one resource, and the link another resource, and the remaining text in the sentence a third resource)? I saw an example in one of the tutorials that looked like that, and this would make it even more absurd.

I find it hard to believe this is really the way you have to do it. So I feel like I'm probably missing something basic? Have I misunderstood the process of localizing an Asp.Net MVC site completely?

Anders
  • 12,556
  • 24
  • 104
  • 151

2 Answers2

1

I find it hard to believe this is really the way you have to do it. So I feel like I'm probably missing something basic? Have I misunderstood the process of localizing an Asp.Net MVC site completely?

No, you are not missing anything. That's the process involved in localizing an ASP.NET MVC application.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    Wow... Ok, I'll take your word for it. It just seems like the developers of MVC have done a hell of a job making web development structured, clean and simple, and then this seems to mess all that up! But ok, thanks for the answer, then I know what I have to do... – Anders May 22 '11 at 12:37
  • Sadly, MVC has just inherited the standard ASP.NET way of doing it. To be honest I'd be happy with it if the RESX editor GUI wasn't so horrible to use. – James McCormack May 23 '11 at 13:53
1

You can always use the approach of providing a separate routing and views for different languages. Some people do that and some CMS implementations favor this approach. That way you don't have to use the resource files. The downside is that if you want to change anything, you have to do it in several places. An example given by Darin presumes "best practices" suggested by most of the experts, which may not suit you best. There is a heated discussion on this subject. I would recommend to study offered solutions and choose what suits you the best for specific project.

For more information on the subject I can suggest the following stack overflow posts:

I had a link on a great blog post where a Russian guy explained approach of separate views for English and Russian (same principle applies to any combination) but I can't find it right now. Will post it if I find it later.

Also go to this link for a small tool to make it easier to edit and compare different language resource files side by side.

Community
  • 1
  • 1
Dragan B.
  • 411
  • 4
  • 9