Resource files seem great for localization of labels and messages, but are they perfect?
For example:
- 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)
- Is this a good method for storing the other types of data, such as images, icons, audio files, regular files, etc.?
- Is it a best practice to store your .resx files in a stand-alone project for easier updates/compiling?
- Are there any other issues that you have run into when using .resx files?
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.
I've seen it work with images...but that's it. (not sure with other media/files)
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)
Besides being really annoying to maintain, and the fact that visual studio doesn't provide the neatest tools for working with them...no.
Here is my take on resource files:
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.
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.
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.).
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.
Never seen any problems with resx resources, they are being cached perfectly. We have used them in WinForms, asp.net mvc, wpf, etc...
One thing you should do is use the Microsoft MAT (Multilingual App Toolkit) extension for Visual Studio.
You can control your translations, export them to send to translators (e.g. not the locked translations), import them again and verify them or comment on it, recycle existing translations (saving you a lot of time!)
and it works with the industry standard xlf format!
If you sign up with the Azure api you can even automatically translate resources (you have a few thousand words free of monthly credit on azure). See: https://multilingualapptoolkit.uservoice.com/knowledgebase/articles/1167898-microsoft-translator-moves-to-the-azure-portal
you can even see how much work already has been done in a project:
Oh and it comes with a handy editor which your translators can also use!
To get started:
Now you only add strings to your default Resources.resx file (the language should be same as the "NeutralResourcesLanguage" you added in AssemblyInfo.cs. For the translations you DONT add strings to the ...nl.resx files, you work with the .xlf files, located in the MultiLingualResources folder.
(after you have done lots of translations, a rebuild might be needed so that the translated .xlf files update the translated .resx files)
Where to get it:
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).
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 we found Creating a Data Driven ASP.NET Localization Resource Provider and Editor.
I recently used a .resx file with 5 million strings (normal length, like this sentence), compiled in different DLLS about 1 GB in size. It still works fine in an Azure web project.
The load time is unknown, maybe few seconds or so, since it always can heat up in stages, I never noticed it.