Code to save to an XML file and fixing localization issues.

This commit is contained in:
2017-06-16 13:03:38 -05:00
parent 16f5c54ee9
commit b62155c76e
3 changed files with 145 additions and 61 deletions

View File

@ -322,11 +322,15 @@ namespace EduNetworkBuilder
/// Find the global random number generator.
/// </summary>
/// <returns>A valid random number generator</returns>
public static CultureInfo GetCulture()
public static CultureInfo GetCulture(NBSettings theSettings = null)
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
CultureInfo CI=null;
NBSettings oursettings = NB.GetSettings();
NBSettings oursettings;
if (theSettings == null) oursettings = NB.GetSettings();
else oursettings = theSettings;
if (myWin != null)
{
CI = myWin.GetCulture();
@ -419,13 +423,14 @@ namespace EduNetworkBuilder
/// </summary>
/// <param name="key">The key for the item we are translating</param>
/// <returns>A string of the translated information</returns>
public static string Translate(string key)
public static string Translate(string key, NBSettings theSettings=null)
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null)
{
ResourceManager RM = GetResource();
CultureInfo CI = GetCulture();
CultureInfo CI = GetCulture(theSettings);
string answer="";
answer = RM.GetString(key, CI);
if (answer == null) return "";
@ -467,11 +472,15 @@ namespace EduNetworkBuilder
return mystring;
}
public static void ChangeLanguage()
public static void ChangeLanguage(NBSettings theSettings=null)
{
//Find the window. If it exists, use /set the language setting there. If not, use / set the default.
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
NBSettings oursettings = NB.GetSettings();
NBSettings oursettings;
if (theSettings == null) oursettings = NB.GetSettings();
else oursettings = theSettings;
string lang = oursettings.ChosenLanguage;
if (lang == "") lang = "en";