diff --git a/Languages.cs b/Languages.cs new file mode 100644 index 00000000..0269a26c --- /dev/null +++ b/Languages.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Windows; +using ModAssistant.Pages; + +namespace ModAssistant +{ + internal class Languages + { + public static string LoadedLanguage { get; private set; } + public static List LoadedLanguages => availableCultures.ToList(); + public static bool FirstRun = true; + private static readonly string[] availableLanguageCodes = { "de", "en", "es", "fr", "it", "ko", "nb", "nl", "pl","pt", "ru", "sv", "th", "zh" }; + private static IEnumerable availableCultures; + + public static void LoadLanguages() + { + var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures); + + // Get CultureInfo for any of the available translations + availableCultures = allCultures.Where(cultureInfo => availableLanguageCodes.Any(code => code.Equals(cultureInfo.Name))); + + string savedLanguageCode = Properties.Settings.Default.LanguageCode; + if (!LoadLanguage(savedLanguageCode)) + { + // If no language code was saved, load system language + if (!LoadLanguage(CultureInfo.CurrentUICulture.Name)) + { + _ = LoadLanguage("en"); + } + } + + UpdateUI(LoadedLanguage); + } + + public static void UpdateUI(string languageCode) + { + if (Options.Instance != null && Options.Instance.LanguageSelectComboBox != null) + { + Options.Instance.LanguageSelectComboBox.ItemsSource = availableCultures.Select(cultureInfo => cultureInfo.NativeName).ToList(); + Options.Instance.LanguageSelectComboBox.SelectedIndex = LoadedLanguages.FindIndex(cultureInfo => cultureInfo.Name.Equals(languageCode)); + } + } + + public static ResourceDictionary LanguagesDict + { + get + { + return Application.Current.Resources.MergedDictionaries[1]; + } + } + + public static bool LoadLanguage(string languageCode) + { + if (string.IsNullOrEmpty(languageCode)) + { + return false; + } + + try + { + LanguagesDict.Source = new Uri($"Localisation/{languageCode}.xaml", UriKind.Relative); + LoadedLanguage = languageCode; + return true; + } + catch (IOException) + { + if (languageCode.Contains("-")) + { + return LoadLanguage(languageCode.Split('-').First()); + } + + return false; + } + } + } +} diff --git a/ModAssistant.csproj b/ModAssistant.csproj new file mode 100644 index 00000000..2315b4d5 --- /dev/null +++ b/ModAssistant.csproj @@ -0,0 +1,328 @@ + + + + + Debug + AnyCPU + {6A224B82-40DA-40B3-94DC-EFBEC2BDDA39} + WinExe + ModAssistant + ModAssistant + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Resources\icon.ico + + + + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + OneClickStatus.xaml + + + Intro.xaml + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Invalid.xaml + + + Loading.xaml + + + Mods.xaml + + + About.xaml + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Options.xaml + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + PublicSettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + \ No newline at end of file diff --git a/ModAssistant/Localisation/pt.xaml b/ModAssistant/Localisation/pt.xaml index 675dc2db..03237452 100644 --- a/ModAssistant/Localisation/pt.xaml +++ b/ModAssistant/Localisation/pt.xaml @@ -158,7 +158,7 @@ Mostrar janela do instalador do "Um Clique" Sim Fechar - Notification + Notificação Não Diagnóstico Abrir Logs @@ -232,8 +232,8 @@ Número máximo de tentativas alcançadas: Saltando em {0} O limite foi atingido. Continuando em {0} Falha no Download: {0} - OneClick™ installation finished - Starting to download playlist + Instalação concluída + Baixando playlist Feito