Frage

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);
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top