Localization

This commit is contained in:
glax 2024-02-21 22:27:48 +01:00
parent f18e6744f4
commit 04be9d6fab
8 changed files with 151 additions and 9 deletions

View File

@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CS2GSI_002FResources/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -11,11 +11,12 @@ public class CS2GSI
private CS2GameState? _lastLocalGameState = null;
private readonly ILogger? _logger;
public bool IsRunning => this._gsiServer.IsRunning;
public CS2GameState? CurrentGameState => _lastLocalGameState;
public CS2GSI(ILogger? logger = null)
{
this._logger = logger;
this._logger?.Log(LogLevel.Information, "Installing GSI-Configfile...");
this._logger?.Log(LogLevel.Information, Resources.Installing_GSI_File);
try
{
GsiConfigInstaller.InstallGsi();
@ -23,7 +24,7 @@ public class CS2GSI
catch (Exception e)
{
this._logger?.Log(LogLevel.Error, e.StackTrace);
this._logger?.Log(LogLevel.Critical, "Could not install GSI-Configfile. Exiting.");
this._logger?.Log(LogLevel.Critical, Resources.Installing_GSI_File_Failed);
return;
}
this._gsiServer = new GSIServer(3000, logger);
@ -34,7 +35,7 @@ public class CS2GSI
{
JObject jsonObject = JObject.Parse(messageJson);
CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject);
this._logger?.Log(LogLevel.Debug, $"Received State:\n{newState.ToString()}");
this._logger?.Log(LogLevel.Debug, $"{Resources.Received_State}:\n{newState.ToString()}");
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
{
@ -43,7 +44,7 @@ public class CS2GSI
InvokeEvents(generatedEvents);
}
this._lastLocalGameState = newState.UpdateGameStateForLocal(_lastLocalGameState);
this._logger?.Log(LogLevel.Debug, $"\nUpdated Local State:\n{_lastLocalGameState}");
this._logger?.Log(LogLevel.Debug, $"\n{Resources.Updated_Local_State}:\n{_lastLocalGameState}");
_allGameStates.Add(newState);
}
@ -90,7 +91,7 @@ public class CS2GSI
CS2Event.OnBombExploded => this.OnBombExploded,
CS2Event.AnyEvent => this.AnyEvent,
CS2Event.AnyMessage => this.AnyMessage,
_ => throw new ArgumentException("Unknown Event", nameof(cs2Event))
_ => throw new ArgumentException(Resources.Unknown_Event, nameof(cs2Event))
};
}

View File

@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Title>CS2GSI</Title>
<Authors>Glax</Authors>
<RepositoryUrl>https://github.com/C9Glax/CS2GSI</RepositoryUrl>

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeEditing/Localization/MoveToResource/LastResourceFile/@EntryValue">F2272524-6CDD-4ACD-8CFF-64B9AF98D54A/f:Resources.resx</s:String></wpf:ResourceDictionary>

View File

@ -42,8 +42,8 @@ internal static class GsiConfigInstaller
path = "~/.local/share/Steam/steamapps/libraryfolders.vdf";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
path = "~/Library/Application Support/Steam/steamapps/libraryfolders.vdf";
else throw new Exception("Could not get Installation FolderPath");
return path ?? throw new FileNotFoundException("No libraryfolders.vdf found");
else throw new Exception(Resources.No_Installation_Folderpath);
return path ?? throw new FileNotFoundException(Resources.No_Libraryfolders_vdf);
}
[SupportedOSPlatform("windows")]
@ -51,7 +51,7 @@ internal static class GsiConfigInstaller
{
string steamInstallation =
(string)(Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null) ??
throw new DirectoryNotFoundException("No Steam Installation found."));
throw new DirectoryNotFoundException(Resources.No_Steam));
return Path.Combine(steamInstallation, "steamapps\\libraryfolders.vdf");
}
}

View File

@ -89,5 +89,77 @@ namespace CS2GSI {
return ResourceManager.GetString("GSI_CFG_Content", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Installing GSI-Configfile....
/// </summary>
internal static string Installing_GSI_File {
get {
return ResourceManager.GetString("Installing_GSI_File", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not install GSI-Configfile. Exiting..
/// </summary>
internal static string Installing_GSI_File_Failed {
get {
return ResourceManager.GetString("Installing_GSI_File_Failed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not get Steam-Installation FolderPath.
/// </summary>
internal static string No_Installation_Folderpath {
get {
return ResourceManager.GetString("No_Installation_Folderpath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No libraryfolders.vdf found.
/// </summary>
internal static string No_Libraryfolders_vdf {
get {
return ResourceManager.GetString("No_Libraryfolders_vdf", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No Steam Installation found..
/// </summary>
internal static string No_Steam {
get {
return ResourceManager.GetString("No_Steam", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Received State.
/// </summary>
internal static string Received_State {
get {
return ResourceManager.GetString("Received_State", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown Event.
/// </summary>
internal static string Unknown_Event {
get {
return ResourceManager.GetString("Unknown_Event", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Updated Local State.
/// </summary>
internal static string Updated_Local_State {
get {
return ResourceManager.GetString("Updated_Local_State", resourceCulture);
}
}
}
}

38
CS2GSI/Resources.de.resx Normal file
View File

@ -0,0 +1,38 @@
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Installing_GSI_File" xml:space="preserve">
<value>Installiere GSI-Konfigurationsdatei...</value>
</data>
<data name="Installing_GSI_File_Failed" xml:space="preserve">
<value>GSI-Konfigurationsdatei nicht installiert.</value>
</data>
<data name="No_Installation_Folderpath" xml:space="preserve">
<value>Steam-Installationspfad konnte nicht gefunden werden.</value>
</data>
<data name="No_Libraryfolders_vdf" xml:space="preserve">
<value>libraryfolders.vdf nicht gefunden</value>
</data>
<data name="No_Steam" xml:space="preserve">
<value>Keine Steam Installation gefunden.</value>
</data>
<data name="Received_State" xml:space="preserve">
<value>Erhaltener Zustand</value>
</data>
<data name="Unknown_Event" xml:space="preserve">
<value>Unbekanntes Ereignis</value>
</data>
<data name="Updated_Local_State" xml:space="preserve">
<value>Erneuerter Lokaler Zustand</value>
</data>
</root>

View File

@ -21,4 +21,29 @@
<data name="GSI_CFG_Content" type="System.Resources.ResXFileRef">
<value>gamestate_integration_cs2gsi.cfg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral</value>
</data>
<data name="Unknown_Event" xml:space="preserve">
<value>Unknown Event</value>
<comment>Event is not defined</comment>
</data>
<data name="Installing_GSI_File" xml:space="preserve">
<value>Installing GSI-Configfile...</value>
</data>
<data name="Installing_GSI_File_Failed" xml:space="preserve">
<value>Could not install GSI-Configfile. Exiting.</value>
</data>
<data name="Received_State" xml:space="preserve">
<value>Received State</value>
</data>
<data name="Updated_Local_State" xml:space="preserve">
<value>Updated Local State</value>
</data>
<data name="No_Installation_Folderpath" xml:space="preserve">
<value>Could not get Steam-Installation FolderPath</value>
</data>
<data name="No_Libraryfolders_vdf" xml:space="preserve">
<value>No libraryfolders.vdf found</value>
</data>
<data name="No_Steam" xml:space="preserve">
<value>No Steam Installation found.</value>
</data>
</root>