Auto-generating Localization in Visual Studio 2005

An entry about asp.net | visual studio Publication date 17. March 2007 00:00

The implicit declarative binding syntax (phew, that's a mouthfull) meta:resourcekey can be used to localize ASP.NET Controls in a much more tidy manner than using it's explicit counterpart. Basically, instead of doing stuff like:

<asp:Button
    ID="_submitBtn"
    runaT="server"
    Text='<%$ resources: Buttons, SubmitButton.Text %>'
    ToolTip='<%$ resources: Buttons, SubmitButton.Tooltip %>'
    OnClick="Submit" />

you can get away with the much more elegant:

<asp:Button
    ID="_submitBtn"
    runaT="server"
    meta:resourcekey='SubmitButton' />

which then will automatically look for SubmitButton.Text and SubmitButton.ToolTip (and any other resource-able properties) in local resource files.

However, the neat trick is that with Visual Studio 2005, you can just forget all about localization when you're writing the markup. Yep, just go ahead and hard-code those literals right in there. Afterwards, simply hit 'Generate Local Resource' on the Tools menu, and VS will do just that, moving all your hard-coded literals into a resource file.

The only downside is that the 'Generate' function is only available in Design Mode. Which, if you're like me and like to hand-type your markup, will probably find a bit annoying. Hopefully this should get sorted in Orcas however :)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

NDC 2010

The conference to attend this summer happens June 16th-18th in Oslo, Norway. Are you going? Be sure to catch my talk on AOP while you're there!

 

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS