views:

16

answers:

2

I need to localize an asp.net webapp with lots of pages.

So far what i'm doing is replace all text with literals where needed and i'm adding <%$ Resources: restype, reskey %> tags wherever needed. All the strings come from my database.

The problem is putting all the text in the database it's just a huge time spender. I really don't want to be putting all the text in the database manually because everytime i finish a new page i have to go over the same excercise again.

So i came up with an idea: What if i extended the localization resource handler with a default value like this (pseude code):

<asp:literal runat="server" Text='<%$ Resources: restype, reskey, 'This was the hard coded text' %>' />

When the page was first loaded the string resource wouldnt be in the database, but having the default text i can add it with the known resource type and key to my database. I could prefix the default values with a question mark for example. This allows me to check my table with strings and everywhere i see a text with a question mark i know it needs translating.

This way i only have to add resource tags to my markup and i avoid inserting all the text in my database. I just have to make sure to load every page once, which i can do locally in debug and then send the non-translated labels to a translator.

Please advise on this approach.

+1  A: 

What we do here where I work is to declare string resources using special helper class. When the application is run, new string resources defined in code are auto-inserted into the database with their default value. The application works without any preparation steps. Later you can change the strings.

But yes, it requires some wrapper code to write.

Developer Art
+1  A: 

Sounds like a nice idea, especially if you can't go along with the standard resource files mechanism which is automatically generated by VS.

Rick Strahl has written a solution for localizing ASP.net webapps to the DB. He's written some kind of Ajax UI which would even allow your users to translate the Webapp. The source code is also open, so you may take a look at it when developing your own solution.

Here's the link: http://www.west-wind.com/WestWindWebToolkit/

Juri
For sure i will check that out. Looks interesting. It would be great if i could let a translator access my site and edit in place.
Jeroen