Skip to content

Commit

Permalink
Fixed bug in language loading
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Sep 29, 2024
1 parent d9b4f82 commit ad24daa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Mirivoice/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public override void Initialize()
InitializeCulture();
}

public static string[] Languages = new string[] { "en-US", "ko-KR"};

public override void OnFrameworkInitializationCompleted()
{

Expand Down Expand Up @@ -89,13 +91,15 @@ public static void SetLanguage(string language)
}
var translations = App.Current.Resources.MergedDictionaries.OfType<ResourceInclude>().FirstOrDefault(x => x.Source?.OriginalString?.Contains("/Lang/") ?? false);

if (!File.Exists( new Uri($"avares://Mirivoice.Main/Assets/Lang/{language}.axaml").LocalPath))
if (Languages.Contains(language) == false)
{
Log.Warning($"Language {language} is not supported. Defaulting to en-US.");
language = "en-US";
MainManager.Instance.Setting.Langcode = language;
MainManager.Instance.Setting.Save();
}


if (translations != null)
App.Current.Resources.MergedDictionaries.Remove(translations);

Expand Down
8 changes: 4 additions & 4 deletions Mirivoice/Mirivoice.Core/Managers/MainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public void LoadVoicerManager()
}
public void LoadSetting()
{
if (File.Exists(PathM.SettingsPath))
if (File.Exists(MainManager.Instance.PathM.SettingsPath))
{
var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(ReadTxtFile(PathM.SettingsPath));
Setting = YamlSerializer.Deserialize<UserSetting>(yamlUtf8Bytes);
var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(ReadTxtFile(MainManager.Instance.PathM.SettingsPath));
MainManager.Instance.Setting = YamlSerializer.Deserialize<UserSetting>(yamlUtf8Bytes);
}
else
{
Setting.Save();
MainManager.Instance.Setting.Save();
}
}
private static void DeleteExtractedZip(string zipFilePath)
Expand Down

0 comments on commit ad24daa

Please sign in to comment.