Are there any performance issues or caveats with resource (.resx) files?

后端 未结 8 1942
遇见更好的自我
遇见更好的自我 2020-12-15 22:16

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 amo
8条回答
  •  不思量自难忘°
    2020-12-15 22:17

    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:

    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:

    • feedback: https://multilingualapptoolkit.uservoice.com/
    • visual studio extension: https://marketplace.visualstudio.com/items?itemName=MultilingualAppToolkit.MultilingualAppToolkit-18308
    • knowledge base: https://multilingualapptoolkit.uservoice.com/knowledgebase
    • github of Cameron (Microsoft) who manages this project: https://github.com/TheMATDude

提交回复
热议问题