Best alternatives to using Resource files in .net site
In the past I have used asp.net's built in Resource files for handling localization. It's worked pretty well and we find it easy to use and maintain in our business.
There is one big drawback though - our client's support teams can't update the resource files themselves. We have a big project starting soon and the option to allow the external support team manage localization is a main requirement. Up until now we have had clients just contact us, we get the piece translated and then roll the updated resx file to the live server.
I know that updating a resx file causes the application to recompile and I don't like the idea of allowing non techies download and mess around with a resx file (not to mention having the site uncompiled in a live environment) so I'm wondering if there are any other options available to us other than going down the database route?
If we do have to build this type of localization functionality into a few database tables, does anyone have any good templates for starting off?
Not sure if it helps knowing or not but the site we're talking about buildi开发者_StackOverflow中文版ng here would be localized into about 15 different languages including chineese and arabic. The translations would be applied onto the aspx pages and in the XML that would leave our system to third parties.
Whatever you do, you will probably need to write custom ResourceProvider.
You may think of using XML as a source for your localizable resources - in that case you can use uncompiled resx files, but I guess that is what you are complaining about. Otherwise, you can use bundle files, similar to Java properties, I mean plain text file with key=value pairs. That should be very easy to edit.
Sure - use a config file. This is basically an XML file.
<messages locale="DE">
<message id="FileNotFound" Value="Die Datei wird nicht gefunden" />
<message id="FatalErr" Value="Es ist ein schwerwiegender Fehler gewesen. Das Programm muss beendet." />
...
</messages>
You can have one file for each language, or combine them in one file.
Believe it or not, you're not the first one with the idea! :) Here's an article I found a few years ago on how to implement a custom resource provider for .NET. You can keep your old resource-based approach in your code, and have the provider take the data from wherever you like.
Instead of writing your own resource provider maybe an online translator like ResX Online Translator would help? The translators don't have to download any resx, and the files are automatically uploaded to your live (or dev) asp.net application.
Use Microsoft MAT or write your own provider for MAT. More info on their website: https://developer.microsoft.com/en-us/windows/develop/multilingual-app-toolkit ;-)
精彩评论