mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Move locale info, fix RTL layout in context menus
This commit is contained in:
parent
8dfd12b7f0
commit
8fd3fd7737
@ -29,8 +29,6 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
public static LaunchSettings LaunchSettings { get; private set; } = null!;
|
public static LaunchSettings LaunchSettings { get; private set; } = null!;
|
||||||
|
|
||||||
public static CultureInfo CurrentCulture { get; set; } = CultureInfo.InvariantCulture;
|
|
||||||
|
|
||||||
public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute<BuildMetadataAttribute>()!;
|
public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute<BuildMetadataAttribute>()!;
|
||||||
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
const string LOG_IDENT = "App::OnStartup";
|
const string LOG_IDENT = "App::OnStartup";
|
||||||
|
|
||||||
CurrentCulture = Thread.CurrentThread.CurrentUICulture;
|
Locale.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
|
||||||
|
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
internal static class Locale
|
internal static class Locale
|
||||||
{
|
{
|
||||||
|
public static CultureInfo CurrentCulture = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> SupportedLocales = new()
|
public static readonly Dictionary<string, string> SupportedLocales = new()
|
||||||
{
|
{
|
||||||
{ "nil", Strings.Enums_Theme_Default }, // /shrug
|
{ "nil", Strings.Enums_Theme_Default }, // /shrug
|
||||||
@ -72,17 +74,29 @@ namespace Bloxstrap
|
|||||||
if (identifier == "nil")
|
if (identifier == "nil")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
App.CurrentCulture = new CultureInfo(identifier);
|
CurrentCulture = new CultureInfo(identifier);
|
||||||
|
|
||||||
CultureInfo.DefaultThreadCurrentUICulture = App.CurrentCulture;
|
CultureInfo.DefaultThreadCurrentUICulture = CurrentCulture;
|
||||||
Thread.CurrentThread.CurrentUICulture = App.CurrentCulture;
|
Thread.CurrentThread.CurrentUICulture = CurrentCulture;
|
||||||
|
|
||||||
RoutedEventHandler? handler = null;
|
RoutedEventHandler? handler = null;
|
||||||
|
|
||||||
if (identifier == "ar" || identifier == "he")
|
if (identifier == "ar" || identifier == "he")
|
||||||
handler = new((window, _) => ((Window)window).FlowDirection = FlowDirection.RightToLeft);
|
{
|
||||||
|
handler = new((sender, _) =>
|
||||||
|
{
|
||||||
|
var window = (Window)sender;
|
||||||
|
|
||||||
|
window.FlowDirection = FlowDirection.RightToLeft;
|
||||||
|
|
||||||
|
if (window.ContextMenu is not null)
|
||||||
|
window.ContextMenu.FlowDirection = FlowDirection.RightToLeft;
|
||||||
|
});
|
||||||
|
}
|
||||||
else if (identifier == "th")
|
else if (identifier == "th")
|
||||||
|
{
|
||||||
handler = new((window, _) => ((Window)window).FontFamily = new System.Windows.Media.FontFamily(new Uri("pack://application:,,,/Resources/Fonts/"), "./#Noto Sans Thai"));
|
handler = new((window, _) => ((Window)window).FontFamily = new System.Windows.Media.FontFamily(new Uri("pack://application:,,,/Resources/Fonts/"), "./#Noto Sans Thai"));
|
||||||
|
}
|
||||||
|
|
||||||
// https://supportcenter.devexpress.com/ticket/details/t905790/is-there-a-way-to-set-right-to-left-mode-in-wpf-for-the-whole-application
|
// https://supportcenter.devexpress.com/ticket/details/t905790/is-there-a-way-to-set-right-to-left-mode-in-wpf-for-the-whole-application
|
||||||
if (handler is not null)
|
if (handler is not null)
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
WriteLine($"[{identifier}] {ex}");
|
WriteLine($"[{identifier}] {ex}");
|
||||||
|
|
||||||
Thread.CurrentThread.CurrentUICulture = App.CurrentCulture;
|
Thread.CurrentThread.CurrentUICulture = Locale.CurrentCulture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void WriteToLog(string message)
|
private async void WriteToLog(string message)
|
||||||
|
Loading…
Reference in New Issue
Block a user