Search code examples
c#winformslocalizationresx

Windows forms localization using *.resx and Common.resx


Lets say there are bunch of forms: A.cs, B.cs, C.cs...

Each form is localized - A.resx, A.NL-nl.resx, etc.

These forms contain some specific labels and some common in all forms used labels. So specific strings go to A.resx (A.NL-nl.resx) and common ones - to lets say Common.resx (Common.NL-nl.resx)

Is there any way to force when form is initialized to use resource strings from A.resx and from Common.resx where all common strings go? Of course I could in some OnLoad method set captions for my form layout items, but then built in localization functionality would be lost.

The reason I would like such functionality, because there are lot of commonly used strings in different forms and it would much easier to manage/translate these *.resx files.

I've done some reading about localization in C#, but probably I am missing something.


Solution

  • From my experience I can say:

    1. You will be better of to create one locatization resx file for all the forms.
    2. Assign all localizable strings manually (I did that in constructor).
    3. Store each string for each form in different localizable property, like Form1_OkButtonText, Form2_OkButtonText.

    The last one really does matter, when you translate your app to different languages, because translation may really depend on context. And on one form default button may be named OK and on the other it should be named Accept. While in English both buttons may be named Ok, in some other languages, this will sound awkward, and different names will be required. This is be problematic, if you use same resource strings for all buttons.

    And to mitigate the problems of translating several same strings many times, you should use some software for translator, that keep dictionary of string, and supply you with already translated ones.