mirror of
https://github.com/nomi-san/parsec-vdd.git
synced 2026-08-07 05:20:44 +00:00
Add msgbox translation support
This commit is contained in:
+15
-12
@@ -55,27 +55,30 @@ namespace ParsecVDisplay
|
||||
return;
|
||||
}
|
||||
|
||||
base.OnStartup(e);
|
||||
LoadLanguages();
|
||||
|
||||
var status = ParsecVDD.QueryStatus();
|
||||
if (status != Device.Status.OK)
|
||||
{
|
||||
if (status == Device.Status.RESTART_REQUIRED)
|
||||
{
|
||||
MessageBox.Show("You must restart your PC to complete the driver setup.",
|
||||
MessageBox.Show(GetTranslation("t_msg_must_restart_pc"),
|
||||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else if (status == Device.Status.DISABLED)
|
||||
{
|
||||
MessageBox.Show($"{ParsecVDD.ADAPTER} is disabled, please enable it.",
|
||||
MessageBox.Show(GetTranslation("t_msg_driver_is_disabled", ParsecVDD.ADAPTER),
|
||||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else if (status == Device.Status.NOT_INSTALLED)
|
||||
{
|
||||
MessageBox.Show("Please install the driver first.",
|
||||
MessageBox.Show(GetTranslation("t_msg_please_install_driver"),
|
||||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"The driver is not OK, please check again. Current status: {status}.",
|
||||
MessageBox.Show(GetTranslation("t_msg_driver_status_not_ok", status),
|
||||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
|
||||
@@ -85,7 +88,7 @@ namespace ParsecVDisplay
|
||||
|
||||
if (ParsecVDD.Init() == false)
|
||||
{
|
||||
MessageBox.Show("Failed to obtain the device handle, please check the driver installation again.",
|
||||
MessageBox.Show(GetTranslation("t_msg_failed_to_obtain_handle"),
|
||||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
|
||||
Shutdown();
|
||||
@@ -100,9 +103,6 @@ namespace ParsecVDisplay
|
||||
}
|
||||
});
|
||||
|
||||
base.OnStartup(e);
|
||||
LoadLanguages();
|
||||
|
||||
// Disable GPU to prevent flickering when adding display
|
||||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
|
||||
}
|
||||
@@ -166,13 +166,16 @@ namespace ParsecVDisplay
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTranslation(string key)
|
||||
public static string GetTranslation(string key, params object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var trans = Current.FindResource(key);
|
||||
if (trans != null && trans is string)
|
||||
return trans as string;
|
||||
var translation = Current.FindResource(key);
|
||||
if (translation != null && translation is string t)
|
||||
{
|
||||
t = t.Replace("\\n", "\n");
|
||||
return string.Format(t, args);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ParsecVDisplay.Components
|
||||
// Check negative values & limit 8K resolution
|
||||
if (width < 0 || width > 7680 || height < 0 || height > 4320 || hz < 0)
|
||||
{
|
||||
MessageBox.Show($"Found invalid value in slot {i / 3 + 1}.",
|
||||
MessageBox.Show(App.GetTranslation("t_msg_custom_invalid_slot", i / 3 + 1),
|
||||
App.NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace ParsecVDisplay.Components
|
||||
var args = $"-custom \"{Display.DumpModes(modes)}\" \"{parentGPU}\"";
|
||||
if (Helper.RunAdminTask(args) == false)
|
||||
{
|
||||
MessageBox.Show("Could not set custom resolutions, access denied!",
|
||||
MessageBox.Show(App.GetTranslation("t_msg_custom_access_denied"),
|
||||
App.NAME, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
+18
-1
@@ -11,7 +11,6 @@
|
||||
<system:String x:Key="t_custom">Custom...</system:String>
|
||||
<system:String x:Key="t_apply">Apply</system:String>
|
||||
<system:String x:Key="t_parent_gpu">Parent GPU</system:String>
|
||||
<system:String x:Key="t_driver_status">Driver status</system:String>
|
||||
<system:String x:Key="t_language">Language</system:String>
|
||||
|
||||
<!--Context menu-->
|
||||
@@ -32,4 +31,22 @@
|
||||
<system:String x:Key="t_keep_screen_on">Keep screen on</system:String>
|
||||
<system:String x:Key="t_check_for_update">Check for update</system:String>
|
||||
<system:String x:Key="t_exit">Exit</system:String>
|
||||
|
||||
<!--Dialog messages-->
|
||||
<system:String x:Key="t_msg_up_to_date">Your app version is up-to-date.</system:String>
|
||||
<system:String x:Key="t_msg_update_available">A new version — v{0} is available.\nTo keep your experience optimal, please update it now."</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_custom_access_denied">Could not apply custom resolutions, access denied!</system:String>
|
||||
<system:String x:Key="t_msg_custom_invalid_slot">Found invalid value in slot #{0}.</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_exceeded_display_limit">Could not add more virtual displays, you have exceeded the maximum number ({0}).</system:String>
|
||||
<system:String x:Key="t_msg_prompt_leave_all">All added virtual displays will be unplugged.\nDo you still want to exit?.</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_driver_status">Driver status</system:String>
|
||||
<system:String x:Key="t_msg_must_restart_pc">You must restart your PC to complete the driver setup.</system:String>
|
||||
<system:String x:Key="t_msg_driver_is_disabled">{0} is disabled, please enable it in Device Manager.</system:String>
|
||||
<system:String x:Key="t_msg_please_install_driver">Please install the driver first.</system:String>
|
||||
<system:String x:Key="t_msg_driver_status_not_ok">The driver is not OK, please check again. Current status: {0}.</system:String>
|
||||
<system:String x:Key="t_msg_failed_to_obtain_handle">Failed to obtain the device handle, please check the driver installation again.</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
+15
-1
@@ -34,6 +34,20 @@
|
||||
<system:String x:Key="t_exit">Thoát</system:String>
|
||||
|
||||
<!--Dialog messages-->
|
||||
<system:String x:Key="t_msg_">Thoát</system:String>
|
||||
<system:String x:Key="t_msg_up_to_date">Bạn đang sử dụng phiên bản mới nhất.</system:String>
|
||||
<system:String x:Key="t_msg_update_available">Có bản cập nhật mới — v{0}.\nHãy cập nhật ngay để trải nghiệm các tính năng mới."</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_custom_access_denied">Không thể áp dụng độ phân giải tùy chỉnh, quyền truy cập bị từ chối!</system:String>
|
||||
<system:String x:Key="t_msg_custom_invalid_slot">Giá trị không hợp lệ ở slot #{0}.</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_exceeded_display_limit">Không thể cắm thêm màn hình ảo, bạn đã đạt đến con số giới hạn ({0}).</system:String>
|
||||
<system:String x:Key="t_msg_prompt_leave_all">Tất cả màn hình ảo sẽ bị tháo bỏ.\nBạn có muốn thoát không?.</system:String>
|
||||
|
||||
<system:String x:Key="t_msg_driver_status">Trạng thái driver</system:String>
|
||||
<system:String x:Key="t_msg_must_restart_pc">Bạn phải khởi động lại PC để driver hoạt động.</system:String>
|
||||
<system:String x:Key="t_msg_driver_is_disabled">{0} đã bị vô hiệu, vui lòng bật nó trong Device Manager.</system:String>
|
||||
<system:String x:Key="t_msg_please_install_driver">Vui lòng cài đặt driver trước.</system:String>
|
||||
<system:String x:Key="t_msg_driver_status_not_ok">Driver không được OK, vui lòng kiểm tra lại. Trạng thái hiện tại: {0}.</system:String>
|
||||
<system:String x:Key="t_msg_failed_to_obtain_handle">Không thể lấy 'device handle', vui lòng kiểm tra cài đặt driver và thử lại.</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
+9
-13
@@ -28,9 +28,6 @@ namespace ParsecVDisplay
|
||||
// setup tray context menu
|
||||
ContextMenu.DataContext = this;
|
||||
ContextMenu.Resources = App.Current.Resources;
|
||||
|
||||
Tray.Init(this, ContextMenu);
|
||||
ContextMenu = null;
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
@@ -68,6 +65,9 @@ namespace ParsecVDisplay
|
||||
{
|
||||
Loaded -= Window_Loaded;
|
||||
|
||||
Tray.Init(this, ContextMenu);
|
||||
ContextMenu = null;
|
||||
|
||||
if (App.Silent)
|
||||
Hide();
|
||||
|
||||
@@ -128,8 +128,7 @@ namespace ParsecVDisplay
|
||||
{
|
||||
if (ParsecVDD.DisplayCount >= ParsecVDD.MAX_DISPLAYS)
|
||||
{
|
||||
MessageBox.Show(this,
|
||||
$"Could not add more virtual displays, you have exceeded the maximum number ({ParsecVDD.MAX_DISPLAYS}).",
|
||||
MessageBox.Show(this, App.GetTranslation("t_msg_exceeded_display_limit", ParsecVDD.MAX_DISPLAYS),
|
||||
Title, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else
|
||||
@@ -176,16 +175,15 @@ namespace ParsecVDisplay
|
||||
var status = ParsecVDD.QueryStatus();
|
||||
var version = ParsecVDD.QueryVersion();
|
||||
|
||||
MessageBox.Show(this,
|
||||
$"Parsec Virtual Display v{version}\nDriver status: {status}",
|
||||
MessageBox.Show(this, $"Parsec Virtual Display v{version}\n" +
|
||||
$"{App.GetTranslation("t_msg_driver_status")}: {status}",
|
||||
App.NAME, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void ExitApp(object sender, EventArgs e)
|
||||
{
|
||||
if (ParsecVDD.DisplayCount > 0)
|
||||
if (MessageBox.Show(this,
|
||||
"All added virtual displays will be unplugged.\nDo you still want to exit?",
|
||||
if (MessageBox.Show(this, App.GetTranslation("t_msg_prompt_leave_all"),
|
||||
App.NAME, MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
@@ -211,9 +209,7 @@ namespace ParsecVDisplay
|
||||
var newVersion = await Updater.CheckUpdate();
|
||||
if (!string.IsNullOrEmpty(newVersion))
|
||||
{
|
||||
var ret = MessageBox.Show(this,
|
||||
$"A new version — v{newVersion} is available!\n" +
|
||||
$"To keep your experience optimal, please update it now.",
|
||||
var ret = MessageBox.Show(this, App.GetTranslation("t_msg_update_available", newVersion),
|
||||
App.NAME, MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (ret == MessageBoxResult.Yes)
|
||||
{
|
||||
@@ -222,7 +218,7 @@ namespace ParsecVDisplay
|
||||
}
|
||||
else if (sender != null)
|
||||
{
|
||||
MessageBox.Show(this, "Your app version is up-to-date.",
|
||||
MessageBox.Show(this, App.GetTranslation("t_msg_up_to_date"),
|
||||
App.NAME, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user