10

I need to create Resources(resx-files) in my .NET Core based application. Until now I used to use ResxResourceWriter from System.Windows.Forms for that. Any suggestions how to handle this task in .NET Core?

Beside our existing software, which has it's own localization approach based on some binary file, the new software should benefit from existing expensive translations and even have some translation synchronization of terms, when they added to the binary file.

Of course, you can use XmlSerialization. The question is, whether there is a formal way to create/manage Resx-files in .NET Core.

Maxim Fleitling
  • 542
  • 4
  • 14
  • It is almost always a bug, the class was meant to implement your own Visual Studio designer. Which you should never do with .NETCore. Use normal XML serialization or make a minimal effort to describe why you think you need it. – Hans Passant Feb 13 '17 at 09:18
  • I'm looking to do a similar thing where I want to have a custom `IStringLocalizer` that can automatically append to a `resx` file for translations. It would be sweet to be able to do it with a resource writer rather then custom xml serialisation. – span Mar 11 '18 at 19:48
  • Did you find a solution? – Vijay Nirmal Jul 19 '19 at 06:47
  • With WinForms open sourced, one could modify the original source to remove windows-specific dependencies https://github.com/dotnet/winforms/blob/master/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs – farlee2121 Feb 17 '20 at 16:37

2 Answers2

9

Tada! https://www.nuget.org/packages/ResXResourceReader.NetStandard

I extracted ResXReourceWriter and ResXResourceReader from the Winforms github and packaged them for .NetStandard

farlee2121
  • 2,959
  • 4
  • 29
  • 41
0

I happen to have a library with full .resx support. You can find the usual ResXResourceReader, ResXResourceWriter or ResXResourceSet classes. I addressed a lot of security issues of the original WinForms version, while you can enforce full compatibility.

I introduced a lot of new features as well, for example, my ResXResrouceSet can be expanded, and there are several new types such as ResXResourceManager that works as a regular ResourceManager but works directly on .resx files and it supports adding new resources during runtime.

I already offered it for the .NET codebase so maybe it will be migrated at some time. Until then, it is available from NuGet.

György Kőszeg
  • 17,093
  • 6
  • 37
  • 65