diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index bdda0c7..f803039 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -29,7 +29,7 @@ namespace Bloxstrap public static LaunchSettings LaunchSettings { get; private set; } = null!; - public static CultureInfo CurrentCulture { get; private set; } = CultureInfo.InvariantCulture; + public static CultureInfo CurrentCulture { get; set; } = CultureInfo.InvariantCulture; public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute()!; public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; @@ -113,8 +113,7 @@ namespace Bloxstrap { const string LOG_IDENT = "App::OnStartup"; - CultureInfo.DefaultThreadCurrentUICulture = CurrentCulture; - Thread.CurrentThread.CurrentUICulture = CurrentCulture; + CurrentCulture = Thread.CurrentThread.CurrentUICulture; base.OnStartup(e); @@ -147,6 +146,7 @@ namespace Bloxstrap Settings.Load(); State.Load(); FastFlags.Load(); + Locale.Set(); } LaunchSettings.ParseRoblox(); diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 04536e2..0d54636 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -302,6 +302,16 @@ namespace Bloxstrap _launchCommandLine += "production"; else _launchCommandLine += App.Settings.Prop.Channel.ToLowerInvariant(); + + if (App.Settings.Prop.ForceRobloxLanguage) + { + if (_launchCommandLine.StartsWith("roblox-player:1")) + _launchCommandLine += "+robloxLocale:"; + else + _launchCommandLine += " -robloxLocale "; + + _launchCommandLine += App.CurrentCulture.Name.Replace('-', '_'); + } } // whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes diff --git a/Bloxstrap/InstallChecker.cs b/Bloxstrap/InstallChecker.cs index 8ea5b49..1cac129 100644 --- a/Bloxstrap/InstallChecker.cs +++ b/Bloxstrap/InstallChecker.cs @@ -130,6 +130,7 @@ namespace Bloxstrap App.IsSetupComplete = false; App.FastFlags.Load(); + Frontend.ShowLanguageSelection(); Frontend.ShowMenu(); // exit if we don't click the install button on installation diff --git a/Bloxstrap/Locale.cs b/Bloxstrap/Locale.cs new file mode 100644 index 0000000..8db0491 --- /dev/null +++ b/Bloxstrap/Locale.cs @@ -0,0 +1,80 @@ +using System; +using System.Windows; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Bloxstrap.Resources; + +namespace Bloxstrap +{ + internal static class Locale + { + // TODO: put translated names + public static readonly Dictionary SupportedLocales = new() + { + { "nil", Strings.Enums_Theme_Default }, // /shrug + { "en", "English" }, + { "en-US", "English (United States)" }, + { "ar", "Arabic" }, + { "bn", "Bengali" }, + { "bs", "Bosnian" }, + { "bg", "Bulgarian" }, + { "zh-CN", "Chinese (Simplified)" }, + { "zh-TW", "Chinese (Traditional)" }, + { "cs", "Czech" }, + { "dk", "Danish" }, + { "nl", "Dutch" }, + { "fl", "Filipino" }, + { "fi", "Finnish" }, + { "fr", "French" }, + { "de", "German" }, + { "he", "Hebrew" }, + { "hi", "Hindi" }, + { "hu", "Hungarian" }, + { "id", "Indonesian" }, + { "it", "Italian" }, + { "ja", "Japanese" }, + { "ko", "Korean" }, + { "lt", "Lithuanian" }, + { "no", "Norwegian" }, + { "pl", "Polish" }, + { "pt-BR", "Portuguese" }, + { "ro", "Romanian" }, + { "ru", "Russian" }, + { "es", "Spanish" }, + { "sv-SE", "Swedish" }, + { "th", "Thai" }, + { "tr", "Turkish" }, + { "uk", "Ukrainian" }, + { "vi", "Vietnamese" } + }; + + public static string GetIdentifierFromName(string language) => Locale.SupportedLocales.Where(x => x.Value == language).First().Key; + + public static void Set() + { + string identifier = App.Settings.Prop.Locale; + + if (!SupportedLocales.ContainsKey(identifier)) + identifier = "nil"; + + if (identifier == "nil") + return; + + App.CurrentCulture = new CultureInfo(identifier); + + CultureInfo.DefaultThreadCurrentUICulture = App.CurrentCulture; + Thread.CurrentThread.CurrentUICulture = App.CurrentCulture; + + if (identifier == "ar" || identifier == "he") + { + // TODO: credit the SO post i took this from + EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((window, _) => + { + ((Window)window).FlowDirection = FlowDirection.RightToLeft; + })); + } + } + } +} diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index 9c6b082..1f51a17 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -13,6 +13,8 @@ namespace Bloxstrap.Models public bool CheckForUpdates { get; set; } = true; public bool CreateDesktopIcon { get; set; } = true; public bool ConfirmLaunches { get; set; } = false; + public string Locale { get; set; } = "nil"; + public bool ForceRobloxLanguage { get; set; } = false; // channel configuration public string Channel { get; set; } = RobloxDeployment.DefaultChannel; diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index cc35677..2e4f42c 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -693,6 +693,25 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Choose preferred language. + /// + public static string Dialog_LanguageSelector_Header { + get { + return ResourceManager.GetString("Dialog.LanguageSelector.Header", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Choose a language before continuing with installation. + ///Scroll for more languages.. + /// + public static string Dialog_LanguageSelector_Subtext { + get { + return ResourceManager.GetString("Dialog.LanguageSelector.Subtext", resourceCulture); + } + } + /// /// Looks up a localized string similar to 2008. /// @@ -1144,7 +1163,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to System Default. + /// Looks up a localized string similar to System default. /// public static string Enums_Theme_Default { get { @@ -1497,6 +1516,24 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Scroll to see more. A relaunch is required for changes to take effect.. + /// + public static string Menu_Appearance_Language_Description { + get { + return ResourceManager.GetString("Menu.Appearance.Language.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language. + /// + public static string Menu_Appearance_Language_Title { + get { + return ResourceManager.GetString("Menu.Appearance.Language.Title", resourceCulture); + } + } + /// /// Looks up a localized string similar to Preview. /// @@ -1596,6 +1633,24 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Roblox will be forced to display the same language that Bloxstrap is presently using.. + /// + public static string Menu_Behaviour_ForceRobloxLanguage_Description { + get { + return ResourceManager.GetString("Menu.Behaviour.ForceRobloxLanguage.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Force Roblox language. + /// + public static string Menu_Behaviour_ForceRobloxLanguage_Title { + get { + return ResourceManager.GetString("Menu.Behaviour.ForceRobloxLanguage.Title", resourceCulture); + } + } + /// /// Looks up a localized string similar to Roblox will be installed fresh on next launch.. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index b88f07b..a8030a0 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -484,7 +484,7 @@ Click for more information Dark - System Default + System default Light @@ -1023,4 +1023,23 @@ Selecting 'No' will ignore this warning and continue installation. Bloxstrap Menu + + Choose preferred language + + + Choose a language before continuing with installation. +Scroll for more languages. + + + Language + + + Scroll to see more. A relaunch is required for changes to take effect. + + + Force Roblox language + + + Roblox will be forced to display the same language that Bloxstrap is presently using. + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Dialogs/LanguageSelectorDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/LanguageSelectorDialog.xaml new file mode 100644 index 0000000..cc290b0 --- /dev/null +++ b/Bloxstrap/UI/Elements/Dialogs/LanguageSelectorDialog.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + +