Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luludotdev committed Sep 21, 2021
1 parent f3346ab commit 0adfeff
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ModAssistant/Classes/Languages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace ModAssistant
{
class Languages
internal class Languages
{
public static string LoadedLanguage { get; private set; }
public static List<CultureInfo> LoadedLanguages { get => availableCultures.ToList(); }
public static List<CultureInfo> LoadedLanguages => availableCultures.ToList();
public static bool FirstRun = true;
private static readonly string[] availableLanguageCodes = { "de", "en", "es", "fr", "it", "ko", "nb", "nl", "pl", "ru", "sv", "th", "zh" };
private static IEnumerable<CultureInfo> availableCultures;
Expand All @@ -29,9 +29,10 @@ public static void LoadLanguages()
// If no language code was saved, load system language
if (!LoadLanguage(CultureInfo.CurrentUICulture.Name))
{
LoadLanguage("en");
_ = LoadLanguage("en");
}
}

UpdateUI(LoadedLanguage);
}

Expand All @@ -54,7 +55,11 @@ public static ResourceDictionary LanguagesDict

public static bool LoadLanguage(string languageCode)
{
if (string.IsNullOrEmpty(languageCode)) return false;
if (string.IsNullOrEmpty(languageCode))
{
return false;
}

try
{
LanguagesDict.Source = new Uri($"Localisation/{languageCode}.xaml", UriKind.Relative);
Expand All @@ -67,6 +72,7 @@ public static bool LoadLanguage(string languageCode)
{
return LoadLanguage(languageCode.Split('-').First());
}

return false;
}
}
Expand Down

0 comments on commit 0adfeff

Please sign in to comment.