restart app after language change, fix display of current language in settings
This commit is contained in:
parent
1bcf1d6f0f
commit
9956e6c57c
|
@ -24,6 +24,19 @@ namespace uploader
|
|||
Base = JsonConvert.DeserializeObject<LocalizationBase>(context);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
var settings = Settings.LoadSettings();
|
||||
if (!string.IsNullOrEmpty(settings.Language))
|
||||
{
|
||||
Load(settings.Language);
|
||||
}
|
||||
else
|
||||
{
|
||||
Base = new LocalizationBase();
|
||||
}
|
||||
}
|
||||
|
||||
// Used to create Json for new version
|
||||
public static void Export()
|
||||
{
|
||||
|
|
|
@ -28,15 +28,7 @@ namespace uploader
|
|||
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
|
||||
//LocalizationHelper.Export();
|
||||
|
||||
var settings = Settings.LoadSettings();
|
||||
if (!string.IsNullOrEmpty(settings.Language))
|
||||
{
|
||||
LocalizationHelper.Load(settings.Language);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalizationHelper.Base = new LocalizationBase();
|
||||
}
|
||||
LocalizationHelper.Update();
|
||||
|
||||
dragLabel.Text = LocalizationHelper.Base.MainForm_DragFile;
|
||||
moreLabel.Text = LocalizationHelper.Base.MainForm_More;
|
||||
|
|
|
@ -20,6 +20,11 @@ namespace uploader
|
|||
|
||||
public static void SaveSettings(Settings settings)
|
||||
{
|
||||
if (settings.Language.Contains("Default"))
|
||||
{
|
||||
settings.Language = "";
|
||||
}
|
||||
|
||||
var serialized = JsonConvert.SerializeObject(settings);
|
||||
var file = GetSettingsFilename();
|
||||
|
||||
|
@ -27,6 +32,8 @@ namespace uploader
|
|||
File.Delete(file);
|
||||
|
||||
File.WriteAllText(file, serialized);
|
||||
|
||||
LocalizationHelper.Update();
|
||||
}
|
||||
|
||||
public static Settings LoadSettings()
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace uploader
|
|||
var settings = Settings.LoadSettings();
|
||||
|
||||
apiTextbox.Text = settings.ApiKey;
|
||||
languageCombo.Text = settings.Language;
|
||||
|
||||
var languages = LocalizationHelper.GetLanguages();
|
||||
languageCombo.Items.Clear();
|
||||
|
@ -39,6 +38,17 @@ namespace uploader
|
|||
languageCombo.Items.Add(language);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(settings.Language))
|
||||
{
|
||||
var defaultLanguage = languageCombo.Items.Add("Default (Build-in English)");
|
||||
languageCombo.SelectedIndex = defaultLanguage;
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = languageCombo.Items.IndexOf(settings.Language);
|
||||
languageCombo.SelectedIndex = index;
|
||||
}
|
||||
|
||||
generalGroupBox.Text = LocalizationHelper.Base.SettingsForm_General;
|
||||
apiLabel.Text = LocalizationHelper.Base.SettingsForm_Key;
|
||||
getApiButton.Text = LocalizationHelper.Base.SettingsForm_Get;
|
||||
|
@ -74,7 +84,12 @@ namespace uploader
|
|||
};
|
||||
|
||||
Settings.SaveSettings(settings);
|
||||
statusLabel.Text = LocalizationHelper.Base.Message_Saved;
|
||||
//statusLabel.Text = LocalizationHelper.Base.Message_Saved;
|
||||
MessageBox.Show(LocalizationHelper.Base.Message_Saved, "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information); // TODO: custom messagebox with dark theme (because default win32 one is annoying)
|
||||
|
||||
// Needs full restart to initialize main form strings again
|
||||
Application.Restart();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void getApiButton_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue