I have the following C# code. For reasons I won\'t go into, this is the required way of localising.
My problem is, I cannot for the life of me figure out what path is no
Consider using a dictionary
private static Dictionary<string,string> stringDict = new Dictionary<string,string>();
Add the strings
// Add default strings
stringDict.Add("AppName", ResMain.GetString("$this.Text"));
stringDict.Add("MinimizeToTray", "Closing the program ...");
stringDict.Add("ReallyExit1", "Do you really ...");
// Add culture specific strings
stringDict.Add("en-GB;AppName", ResMain.GetString("$this.Text"));
stringDict.Add("en-GB;MinimizeToTray", "Closing the program ...");
stringDict.Add("en-GB;ReallyExit1", "Do you really ...");
The you can get the strings very quickly with
// Get culture specific string
string culture = Thread.CurrentThread.CurrentUICulture.ToString();
string s;
If (stringDict.TryGetValue(culture + ";" + Name, out s)) {
return s;
}
// Get default
If (stringDict.TryGetValue(Name, out s)) {
return s;
}
return String.Format("String '{0}' not found!", Name);
This is easier to maintain.
(As other have already pointed out, there is a return-statement missing at the very end of your method and the boolean variable is superfluous.)