0

I am creating an application with support for multilingual operating system . At one place in the application I am using following line of code.

Type t = typeof(System.Windows.Forms.NotifyIcon);
BindingFlags hidden = BindingFlags.NonPublic | BindingFlags.Instance;
t.GetField("text", hidden).SetValue(notifyIcon, notificationToolTip);

Will it run smoothly on different language Operating system , or I have to change the required fields for different language. For example , for french operating system I have to make the following changes.

t.GetField("texte",hidden),SetValue(notifyIcon,notificationToopTip);
Tobia Zambon
  • 7,479
  • 3
  • 37
  • 69
Gaurav
  • 113
  • 6

1 Answers1

6

No, the names of members are not dependent on the language settings of the operating system. When you declare a class like this:

public class Foo
{
    public string Name { get; set; }
}

... it's not like the compiler automatically translates that into Nom in French etc.

On the other hand, the names of non-public members can change between different versions of the library - the whole point of them being non-public is that you're not meant to use them, which means the library author is entirely at liberty to change them later. That's the aspect of your code which is brittle - not the internationalization aspect.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • @ Jon Skeet I am talking about different language operating system,like Windows installed in french or some other language and not in English. – Gaurav Jul 15 '13 at 08:11
  • @G10, Jon Skeet's response is pertinent to that also. – Moo-Juice Jul 15 '13 at 08:19
  • 1
    @g10: It doesn't matter at all. The program code still isn't going to be translated. (Think about it: when you declare a field do you really expect that something's going to automatically translate it?) – Jon Skeet Jul 15 '13 at 08:23