views:

450

answers:

6

Resource files seem great for localization of labels and messages, but are they perfect?

For example:

  1. Is there a better solution if there is a huge amount of resources? Like 100,000 strings in a .resx file? (Theoretically, I do not actually have this problem)
  2. Is this a good method for storing the other types of data, such as Images, Icons, Audio Files, Regular Files?
  3. Is it a best practice to store your .resx files in a stand alone project for easier updates/compiling?
  4. Are there any other issues that you have run into when using .resx files?

Thanks in advance!

A: 

No takers after 40 minutes, time to take matters into my own hands...

here is my take on resource files:

  1. I would assume that if there is a LARGE amount of string, that using a database might be the best method to allow for searching and sorting of the data. It would probably not be too difficult to account for multiple languages in a resource table, and the speed should best fast.
  2. I would think that this is a good method for storing static resources, or things that might be changed by a client. As for dynamic resources, it might be better to use a database, either alone, or in conjunction with the file system. I think in the new SQL Server there is a new type that is an optimal hybrid of using a database and the file system.
  3. I read in another question (don't know which) that using resource files in an external project is a good practice, because you wouldn't have to recompile an entire project when resources change. Just recompile the resource project. This would also allow for (fairly) easy edits to be made by clients, where they would only need to "source code" for the resource project, and not your other real code (API code, etc).
  4. I have not used resource files enough to make any claims about their reliability, extensibility, or any potential issues that you might have when working with them.
SkippyFire
A: 

For point#4.
I have been using .resx files for all strings on our site that must be localized into many languages and haven't had any major issues with them.

The one thing that you need to think about is if you want this text to be searchable. For some of the sites I work on there are some localized resources that need to be searchable so I must keep them in the database. However, when I have the choice I prefer the .resx file for similar reasons mentioned above.

Matthew Manela
A: 

I will not answer your question in great details as you did.

I will simply add that you should look for custom implementations (or do you own) of the resource provider (provider model like the membership provider) to store your resources in a database. That's what we did for our CMS and it's very useful.

When we first looked for an example back then there was this one : http://www.west-wind.com/presentations/wwDbResourceProvider/

W3Max
Why would you want to store these non-changing resources in a Database? That seems like a great way to run into scalability problems fairly soon.
UpTheCreek
@Sosh, who said resources are "non-changing". On the contrary, resources are like any other content, constantly changing and you probably want a web based interface to managed them so that a none technical person can do that. And the thing about scalability can be handled in many ways... I didn't know that storing data in databases would necessarily imply scalability problems...
W3Max
+1  A: 

I have had two problems with resource files, both about performance of the translators (People), rather then the speed of string lookup.

The sales staff at the oversee office that did the translators could not cope with editing XML or learning any new tool.

So they just used Excel to edit the translations. Therefore we might as well have stored the translated strings as a CVS file, so avoiding having to copy the translated strings into the resource files.

A new build needs to be done so as to need the effect of any translations.

Once again if the translated strings were stored as a CSV file, we could have cached them in the ASP.NET cache. Then any changes to the translations would show up on the next page load.


So we could have used a custom implementation of the resource provider and keep to the standard asp.net resource lookup system. Or just ignore the standard resource lookup system if it does not help in your case – depends on how your pages are written.


You may find at some point that you wish to be able to override strings for a single customer, if so you will need a multi stage lookup system. Otherwise you have to merge the customer’s custom strings with the translated string each time you ship a new version of the system.

Ian Ringrose
I think there is an external .resx editor tool...
SkippyFire
@SkippyFire, the problem with the "external .resx editor tool" is that a translator has to learn how to use it.
Ian Ringrose
Dude, the resgen tool can transform resx to key=value text files that are trivial for translators to use. Then you can use resgen to transform the key=value files back into xml resx files.
Andrew Arnott
There is a simple free tool, can't remember the name, that opens the resx file in a spreadsheet like fashion. There is really nothing to learn at all.
Pete
@Pete, but the tool has to be installed and more often then not in my experience the translations are done by a "sales person" in the local sales office. Not someone that is good at learning how to use new software however easy it is to use..
Ian Ringrose
+1  A: 
  1. Is there a better solution if there is a huge amount of resources? Like 100,000 strings in a .resx file? (Theoretically, I do not actually have this problem). I've used Alfresco as an alternative content repository on Java projects. RESX files, from a maintaince standpoint (because of encoding issues I guess) can really stink.
  2. Is this a good method for storing the other types of data, such as Images, Icons, Audio Files, Regular Files? I've seen it work with images...but that's it.
  3. Is it a best practice to store your .resx files in a stand alone project for easier updates/compiling? I don't, but you can edit a resx file on a live site and then edit will go through, I believe. Certainly that's the way it works in development (except for the global resx, I think)
  4. Are there any other issues that you have run into when using .resx files? Besides being really annoying to maintain, and the fact that visual studio doesn't provide the neatest tools for working with them...no.
scottschulthess
+1  A: 

We have been using resource files on a relatively large .NET Windows Forms application (over 500 various forms, approximately 20 resource strings per form) and we've had no performance issues regarding resources from .resx files. We have used Babylon.NET as a tool for managing translations (has a free version just for translators). You did not specify if your project will be web or desktop application. One functionality that resource files offers for desktop applications is the ability to also localize control positions and size which IMHO is not possible using other tools (unless you are using something like DevExpress layout control which has automatic sizing).