One of the things that went surprisingly well from even the earliest beginnings of EyeFetch was the global footprint we could establish. It was always my hope that we would see people from around the world participate – you could see this plan from the start by having the little country flags showing very prominently – but the breadth and depth of our global reach echoes even now, with comments from all over the world still showing up.
Needless to say, this is one of the areas of the old EyeFetch I not only want to retain, but ideally would like to build out further. The original EyeFetch was built on classic ASP, which didn’t really have any decent support for localization and globalization. While many pieces of the platform migrated over the years onto the newer .Net platform, merging localization in was something I never got to, and eventually turned out to be too much work. So, one of the many advantages of starting from scratch, is that full globalization can be built in right from the start.
Technical Details – Building a Custom Database Resource Provider in .Net (4.0)
The goals here were pretty simple:
- Move the resource storage from .resx files into a database, so dynamic updates can be made, and a web-based admin interface to edit localization can be built in the future
- Allow users to select their preferred language through a simple UI (for now, just a drop-down to test)
Luckily with the introduction of the provider model in .Net 2.0 this should have been pretty simple. Additionally, I assumed a lot of other folks would have attempted this before, and plenty of (clear) documentation should be available. To my surprise, I spent the last two days struggling with this, and only thanks to a couple of very insightful articles could finally put this all in place. I suspect a number of other folks will run into similar problems, so here are the key resources that sent me down the right path:
While the articles above should give anybody interested a good enough view to be able to build their own Custom Resource Provider, there is a single piece of information I wish I could have understood earlier, and judging from a few articles I found during my research I’m not the only one who has run into this challenge. If you ever get to the point during implementation of your own Custom Resource Provider at which the compiler either throws out odd compilation errors (or, as in my case, even crashes Visual Studio 2010 completely), remember this:
- Even explicit global localization will cause the compiler to check for existence of the neutral language for the resource key you are referencing!
Read the statement again, and let it sink in. Basically, this means you need to make sure you have the entire resource provider set up, registered in the web.config and enough data in your database to support every key you are referencing throughout your code. Furthermore, if you end up running into problems in the design-time piece of your custom resource provider, add a break point in the override for CreateGlobalResourceProvider, then open a separate instance of Visual Studio, and attach yourself to the devenv.exe process. Then compile the default project which references your custom resource provider classes in the original instance of Visual Studio, and the break point will be reached during compilation, as the compiler reaches the pages that utilize a global resource.
Say what?
For the non-techies following along, this is what this all means to you: Go to eyefetch.com, and click the little “login” link on the top right. Note, logins do not work yet. The login page is a placeholder for now so I can lay the foundation of the various platform features I want to enable in the new EyeFetch. In the header, you will notice a sentence, stating “EyeFetch login -….”, and on the right top you can see a drop-down with a few language choices (for now, the choices are only in English). Change the drop-down, and you will see the sentence in the header change language. Hooray! What does this mean for EyeFetch? It means I will implement this base functionality throughout the Site, and then we will simply need to store translations of every piece of text we have on the Site (maybe with the help from some of you) and we will be able to offer EyeFetch in other languages and make our little corner of the Internet even more accessible to all four corners of the world.