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:
- For UI part I could set
Localizable = true
on control and let VS generates all "records" I need for default language.
- Then I have to manually add all the strings I use for dynamic menus, messages and so on
- 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:
- 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.
- 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...
- Is there a better way to accomplish my task?
- 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:
- It's true, I can hardcode namespace and that won't be changed when end-user puts my control on his form
- Well, it seems there's not an easy way.
Anyway this SO post provides a wonderful lesson and a great solution!!
- ... no, for this question I'm still waiting for someone to tell me a better/easier way
- Some critical point was specified from lak-b.
Is there something else I have to be worried about?
Thanks again
Take a look Best practice to make a multi language application in C#/WinForms?
- You can to "hardcode" assembly name here.
- Try this http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx
- 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.