Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a multi-language user control

I'm developing a user control and now (quite at the end of the work) I'm facing the problem of making it multi-language. I think I could proceed in this way:

  1. For UI part I could set Localizable = true on control and let VS generates all "records" I need for default language.
  2. Then I have to manually add all the strings I use for dynamic menus, messages and so on
  3. Finally I need to create all resources file for languages I need

So using code from MSDN

Assembly myAssembly = this.GetType().Assembly;
ResourceManager mgr = new ResourceManager("namespace.resource", myAssembly);
mgr.GetString(...) 

my job could (easily) be done.
But I have some question:

  1. When my control (generated DLL) is used from an end-user, can I have some trouble using new ResourceManager(...) because of main namespace changes in target app?
    Consider I don't know which namespace end-user is going to use.
  2. When I create languages resources, VS generates satellite assemblies: is there a way I can "integrate" these files inside my target DLL?
    I'd like to deploy just one file if possible...
  3. Is there a better way to accomplish my task?
  4. Is there something I really have to care when I develop a multilaguage control?

Thanks to everybody


UPDATE: (thanks to @lak-b for some suggestion)

I answer some question after some research:

  1. It's true, I can hardcode namespace and that won't be changed when end-user puts my control on his form
  2. Well, it seems there's not an easy way.
    Anyway this SO post provides a wonderful lesson and a great solution!!
  3. ... no, for this question I'm still waiting for someone to tell me a better/easier way
  4. Some critical point was specified from lak-b.
    Is there something else I have to be worried about?

Thanks again

like image 665
Marco Avatar asked Nov 04 '22 12:11

Marco


1 Answers

Take a look Best practice to make a multi language application in C#/WinForms?

  1. You can to "hardcode" assembly name here.
  2. Try this http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx
    1. You just have to goole about it and try it in action! :) In short - you have to care about a lot of things:
      • DateTime
      • Currency
      • First Day of the Week
      • Right-to-Left or Left-to-Right and so on.
like image 168
lak-b Avatar answered Nov 14 '22 21:11

lak-b