Are there any performance issues or caveats with r

2019-02-06 03:19发布

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, etc.?
  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?

8条回答
老娘就宠你
2楼-- · 2019-02-06 03:46

 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, etc.?

I've seen it work with images...but that's it. (not sure with other media/files)

 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.

查看更多
够拽才男人
3楼-- · 2019-02-06 03:48

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.

查看更多
女痞
4楼-- · 2019-02-06 03:59

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:

enter image description here

Oh and it comes with a handy editor which your translators can also use!

enter image description here

To get started:

  1. install the MAT Visual Studio extension
  2. Go to your project in Visual Studio
  3. Click Properties --> open AssemblyInfo.cs
  4. Add this attribute: [assembly: System.Resources.NeutralResourcesLanguage("en")]
  5. Select your project in Solution Explorer and to in Visual Studio to [Tools] --> [Multilingual App Toolkit] --> [Enable selection]
  6. This will add a new folder "MultilingualResources" to your project
  7. Right mouse click your project --> [Multilingual App Toolkit] --> [Add translation languages…] --> select the language you want to translate (e.g. Dutch).
  8. In the "MultilingualResources" folder you will see a new file "....nl.xlf", double click it, it will open with the Multilingual Editor. (if not right mouse click and change the default "Open With" to the multilingual editor)

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:

查看更多
我只想做你的唯一
5楼-- · 2019-02-06 04:00

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).

查看更多
聊天终结者
6楼-- · 2019-02-06 04:04

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.

查看更多
Lonely孤独者°
7楼-- · 2019-02-06 04:06

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.

查看更多
登录 后发表回答