Do to my lack of knowledge I've edited this question
I am making a UserControl
with DataGridView
in it and I want to simplify implementation process as much as possible, so I am wondering should I do that with localization?
Do to my knowledge and research thus far, my approach for localization is this:
For example say I have one button on my form/UserControl
with text property set to "hello" , now I want to localize my form/UserControl
for Italian language.
English is by default so i already have .resx
file in my form, but after this VS will generate resources for Italian with button.Text
property as key and "ciao" as value, if i understood correctly, but what happens if someone comes and change button.Text
property from hello to "hello world", then my Italian resources won't be correct unless they are changed manually, is there a way to somehow do this change automatically?
I am wondering this, because when my UserControl
with DataGridView
is implemented on some form
, I can't tell which columns will my DataGridView
have, so I am wondering should I leave localization process to the person who implements my control?
Thank you, I really appreciate the help, and sorry for edit.
The best option is to set the (localized) text using code (use one Resource file).
You can do this in your form's/user control's constructor for example.
Try to avoid using a resx per form/user control because this will probably lead to unmaintainable code (duplicated key/values) unless you use a third party tool to localize the entire app like (Infralution Globalizer )
The above tool is not free,but it's the only one I've used
The code in your constructor will look like this (Assuming you have a YourResourceFile.resx)
public MyUserControl()
{
columnFirstName.Header = YourResourceFile.FirstName;
columnLastName.Header = YourResourceFile.LastName;
}
If you want to add more columns on your grid,you'll add:
In fact,step 1,usually, will not be necessary since the key will probably be there
Update:
There seems to be a popular VS plugin called ResXManager or (here).