-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
182 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
|
||
namespace CavernPipeServer.Consts { | ||
/// <summary> | ||
/// Handle fetching of language strings and translations. | ||
/// </summary> | ||
static class Language { | ||
/// <summary> | ||
/// Get the <see cref="MainWindow"/>'s translation. | ||
/// </summary> | ||
public static ResourceDictionary GetMainWindowStrings() => mainWindowCache ??= GetFor("MainWindowStrings"); | ||
|
||
/// <summary> | ||
/// Show the message in an error dialog with the localized "Error" title. | ||
/// </summary> | ||
public static void ShowError(string message) => | ||
MessageBox.Show(message, (string)GetMainWindowStrings()["Error"], MessageBoxButton.OK, MessageBoxImage.Error); | ||
|
||
/// <summary> | ||
/// Get the translation of a resource file in the user's language, or in English if a translation couldn't be found. | ||
/// </summary> | ||
static ResourceDictionary GetFor(string resource) { | ||
if (Array.BinarySearch(supported, CultureInfo.CurrentUICulture.Name) >= 0) { | ||
resource += '.' + CultureInfo.CurrentUICulture.Name; | ||
} | ||
return new() { | ||
Source = new Uri($";component/Resources/{resource}.xaml", UriKind.RelativeOrAbsolute) | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Languages supported that are not the default English. | ||
/// </summary> | ||
static readonly string[] supported = ["hu-HU"]; | ||
|
||
/// <summary> | ||
/// The loaded translation of the <see cref="MainWindow"/> for reuse. | ||
/// </summary> | ||
static ResourceDictionary mainWindowCache; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
CavernSamples/CavernPipeServer/Resources/MainWindowStrings.hu-HU.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib"> | ||
<!-- Context menu --> | ||
<system:String x:Key="MOpen">Megnyitás</system:String> | ||
<system:String x:Key="MRest">Szerver újraindítása</system:String> | ||
<system:String x:Key="MExit">Kilépés</system:String> | ||
|
||
<!-- Errors --> | ||
<system:String x:Key="Error">Hiba</system:String> | ||
<system:String x:Key="ERest">A CavernPipe szerver már fut, és készen áll a lejátszásra.</system:String> | ||
<system:String x:Key="EServ">A CavernPipe szerver újraindítása már folyamatban van.</system:String> | ||
<system:String x:Key="EPipe">A CavernPipe szerver nem tudott elindulni 3 másodpercen keresztül. Menj biztosra, hogy nincs CavernPipe nevű named pipe, | ||
és használd az értesítési sáv CavernPipe ikonjának jobbklikkes menüjét, hogy újraindítsd a pipe-ot.</system:String> | ||
</ResourceDictionary> |
15 changes: 15 additions & 0 deletions
15
CavernSamples/CavernPipeServer/Resources/MainWindowStrings.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:system="clr-namespace:System;assembly=mscorlib"> | ||
<!-- Context menu --> | ||
<system:String x:Key="MOpen">Open</system:String> | ||
<system:String x:Key="MRest">Restart server</system:String> | ||
<system:String x:Key="MExit">Exit</system:String> | ||
|
||
<!-- Errors --> | ||
<system:String x:Key="Error">Error</system:String> | ||
<system:String x:Key="ERest">The CavernPipe server is already running and ready for playback.</system:String> | ||
<system:String x:Key="EServ">The CavernPipe server is already being restarted.</system:String> | ||
<system:String x:Key="EPipe">CavernPipe server failed to start for 3 seconds. Make sure no named pipe is called CavernPipe, and use the right click menu | ||
of the CavernPipe icon on your system tray to restart the pipe.</system:String> | ||
</ResourceDictionary> |