diff --git a/PostCodeSerialMonitor/App.axaml.cs b/PostCodeSerialMonitor/App.axaml.cs index 24965d4..ff6d07c 100644 --- a/PostCodeSerialMonitor/App.axaml.cs +++ b/PostCodeSerialMonitor/App.axaml.cs @@ -1,8 +1,7 @@ +using System.Linq; using Avalonia; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Data.Core; using Avalonia.Data.Core.Plugins; -using System.Linq; using Avalonia.Markup.Xaml; using PostCodeSerialMonitor.ViewModels; using PostCodeSerialMonitor.Views; @@ -32,6 +31,10 @@ public override void OnFrameworkInitializationCompleted() var mainWindowViewModel = services.GetRequiredService(); + //@todo Load language setting in cofig.json. + // + //Assets.Resources.Culture = new CultureInfo("en-US"); + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { // Avoid duplicate validations from both Avalonia and the CommunityToolkit. diff --git a/PostCodeSerialMonitor/Assets/Resources.Designer.cs b/PostCodeSerialMonitor/Assets/Resources.Designer.cs new file mode 100644 index 0000000..2861f1b --- /dev/null +++ b/PostCodeSerialMonitor/Assets/Resources.Designer.cs @@ -0,0 +1,632 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PostCodeSerialMonitor.Assets { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("VS Code RESX Editor", "1.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PostCodeSerialMonitor.Assets.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// In Models/JsonConverters.cs file + /// + public static string ExpectedStringToken { + get { + return ResourceManager.GetString("ExpectedStringToken", resourceCulture); + } + } + + /// + /// In Models/JsonConverters.cs file + /// + public static string FailedReadingString { + get { + return ResourceManager.GetString("FailedReadingString", resourceCulture); + } + } + + /// + /// In Models/JsonConverters.cs file + /// + public static string InvalidBase64String { + get { + return ResourceManager.GetString("InvalidBase64String", resourceCulture); + } + } + + /// + /// In Services/ConfigurationService.cs + /// + public static string ConfigurationSaved { + get { + return ResourceManager.GetString("ConfigurationSaved", resourceCulture); + } + } + + /// + /// In Services/ConfigurationService.cs + /// + public static string FailedSaveConfiguration { + get { + return ResourceManager.GetString("FailedSaveConfiguration", resourceCulture); + } + } + + /// + /// In Services/ConfigurationService.cs + /// + public static string ConfigurationUpdated { + get { + return ResourceManager.GetString("ConfigurationUpdated", resourceCulture); + } + } + + /// + /// In Services/ConfigurationService.cs + /// + public static string FailedUpdateConfiguration { + get { + return ResourceManager.GetString("FailedUpdateConfiguration", resourceCulture); + } + } + + /// + /// In Services/MetaDefinitionService.cs + /// + public static string MetaFileNotExist { + get { + return ResourceManager.GetString("MetaFileNotExist", resourceCulture); + } + } + + /// + /// In Services/MetaDefinitionService.cs + /// + public static string UnexpectedMetaType { + get { + return ResourceManager.GetString("UnexpectedMetaType", resourceCulture); + } + } + + /// + /// In Services/MetaUpdateService.cs + /// + public static string MetaContent { + get { + return ResourceManager.GetString("MetaContent", resourceCulture); + } + } + + /// + /// In Services/MetaUpdateService.cs + /// + public static string FailedDownloadMetaEntry { + get { + return ResourceManager.GetString("FailedDownloadMetaEntry", resourceCulture); + } + } + + /// + /// In Services/MetaUpdateService.cs + /// + public static string FailedDeserializingMetaDefinition { + get { + return ResourceManager.GetString("FailedDeserializingMetaDefinition", resourceCulture); + } + } + + /// + /// In Services/MetaUpdateService.cs + /// + public static string FailedDownloadMetaDefinition { + get { + return ResourceManager.GetString("FailedDownloadMetaDefinition", resourceCulture); + } + } + + /// + /// In Services/SerialLineDecoder.cs + /// + public static string DecoderIgnoringLine { + get { + return ResourceManager.GetString("DecoderIgnoringLine", resourceCulture); + } + } + + /// + /// In Services/SerialLineDecoder.cs + /// + public static string UemOsError { + get { + return ResourceManager.GetString("UemOsError", resourceCulture); + } + } + + /// + /// In Services/SerialService.cs + /// + public static string FailedEnterRepl { + get { + return ResourceManager.GetString("FailedEnterRepl", resourceCulture); + } + } + + /// + /// In Services/SerialService.cs + /// + public static string FailedFwVersion { + get { + return ResourceManager.GetString("FailedFwVersion", resourceCulture); + } + } + + /// + /// In Services/SerialService.cs + /// + public static string FailedParseConfig { + get { + return ResourceManager.GetString("FailedParseConfig", resourceCulture); + } + } + + /// + /// In Services/SerialService.cs + /// + public static string FailedGetVersion { + get { + return ResourceManager.GetString("FailedGetVersion", resourceCulture); + } + } + + /// + /// In Services/SerialService.cs + /// + public static string FailedGetState { + get { + return ResourceManager.GetString("FailedGetState", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string Unavailable { + get { + return ResourceManager.GetString("Unavailable", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string ScanButtonText { + get { + return ResourceManager.GetString("ScanButtonText", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string NotConnected { + get { + return ResourceManager.GetString("NotConnected", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string Never { + get { + return ResourceManager.GetString("Never", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string NewMetadataAvailable { + get { + return ResourceManager.GetString("NewMetadataAvailable", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string NewMetadataAvailableInformation { + get { + return ResourceManager.GetString("NewMetadataAvailableInformation", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedUpdateMetadata { + get { + return ResourceManager.GetString("FailedUpdateMetadata", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string Error { + get { + return ResourceManager.GetString("Error", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string Warning { + get { + return ResourceManager.GetString("Warning", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedUpdateMetadataMessageBoxError { + get { + return ResourceManager.GetString("FailedUpdateMetadataMessageBoxError", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedLoadLocalMetadata { + get { + return ResourceManager.GetString("FailedLoadLocalMetadata", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedLoadLocalMetadataMessageBoxWarning { + get { + return ResourceManager.GetString("FailedLoadLocalMetadataMessageBoxWarning", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedLoadMetadata { + get { + return ResourceManager.GetString("FailedLoadMetadata", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedLoadLocalMetadataMessageBoxError { + get { + return ResourceManager.GetString("FailedLoadLocalMetadataMessageBoxError", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string SaveLogFiles { + get { + return ResourceManager.GetString("SaveLogFiles", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string LogFiles { + get { + return ResourceManager.GetString("LogFiles", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string ErrorSavingLogFile { + get { + return ResourceManager.GetString("ErrorSavingLogFile", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string ErrorSavingLogFileMessageBoxError { + get { + return ResourceManager.GetString("ErrorSavingLogFileMessageBoxError", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string ErrorConection { + get { + return ResourceManager.GetString("ErrorConection", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string ErrorConectionMessageBoxError { + get { + return ResourceManager.GetString("ErrorConectionMessageBoxError", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedGetMainWindow { + get { + return ResourceManager.GetString("FailedGetMainWindow", resourceCulture); + } + } + + /// + /// In ViewModels/MainWindowViewModel.cs + /// + public static string FailedGetApplicationLifetime { + get { + return ResourceManager.GetString("FailedGetApplicationLifetime", resourceCulture); + } + } + + /// + /// In Views/ConfigurationDialog.axaml + /// + public static string Configuration { + get { + return ResourceManager.GetString("Configuration", resourceCulture); + } + } + + /// + /// In Views/ConfigurationDialog.axaml + /// + public static string LanguageSettings + { + get + { + return ResourceManager.GetString("LanguageSettings", resourceCulture); + } + } + + /// + /// In Views/ConfigurationDialog.axaml + /// + public static string UpdateSettings { + get { + return ResourceManager.GetString("UpdateSettings", resourceCulture); + } + } + + /// + /// In Views/ConfigurationDialog.axaml + /// + public static string CheckApplicationUpdates { + get { + return ResourceManager.GetString("CheckApplicationUpdates", resourceCulture); + } + } + + /// + /// In Views/ConfigurationDialog.axaml + /// + public static string ApplicationUpdateUrl { + get { + return ResourceManager.GetString("ApplicationUpdateUrl", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string CheckCodeUpdates { + get { + return ResourceManager.GetString("CheckCodeUpdates", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string CodeMetaUrl { + get { + return ResourceManager.GetString("CodeMetaUrl", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string CheckFirmwareUpdates { + get { + return ResourceManager.GetString("CheckFirmwareUpdates", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string FirmwareUpdateUrl { + get { + return ResourceManager.GetString("FirmwareUpdateUrl", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string Cancel { + get { + return ResourceManager.GetString("Cancel", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string Save { + get { + return ResourceManager.GetString("Save", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string XboxPostCodeSerialMonitor { + get { + return ResourceManager.GetString("XboxPostCodeSerialMonitor", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string RefreshPorts { + get { + return ResourceManager.GetString("RefreshPorts", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string Connect { + get { + return ResourceManager.GetString("Connect", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string Disconnect { + get { + return ResourceManager.GetString("Disconnect", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string SaveLog { + get { + return ResourceManager.GetString("SaveLog", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string AppVersion { + get { + return ResourceManager.GetString("AppVersion", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml + /// + public static string VisitXboxResearch { + get { + return ResourceManager.GetString("VisitXboxResearch", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml.cs + /// + public static string PicoFirmware { + get { + return ResourceManager.GetString("PicoFirmware", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml.cs + /// + public static string MetadataUpdate { + get { + return ResourceManager.GetString("MetadataUpdate", resourceCulture); + } + } + + /// + /// In Views/MainWindow.axaml.cs + /// + public static string FailedOpenUrl { + get { + return ResourceManager.GetString("FailedOpenUrl", resourceCulture); + } + } + } +} \ No newline at end of file diff --git a/PostCodeSerialMonitor/Assets/Resources.pt-BR.resx b/PostCodeSerialMonitor/Assets/Resources.pt-BR.resx new file mode 100644 index 0000000..36d3f13 --- /dev/null +++ b/PostCodeSerialMonitor/Assets/Resources.pt-BR.resx @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Era esperado uma string de token + In Models/JsonConverters.cs file + + + Falha ao ler o campo como um texto + In Models/JsonConverters.cs file + + + Texto base64-urlsafe inválido + In Models/JsonConverters.cs file + + + Configuração salva com sucesso + In Services/ConfigurationService.cs + + + Falha ao salvar a configuração + In Services/ConfigurationService.cs + + + Configuração atualizada com sucesso + In Services/ConfigurationService.cs + + + Falha ao atualizar a configuração + In Services/ConfigurationService.cs + + + LoadMetaDefinitions: Arquivo {0} não existe + In Services/MetaDefinitionService.cs + + + LoadMetaDefinitions: Tipo de MetaType inesperado: {0} + In Services/MetaDefinitionService.cs + + + Conteúdo de Meta: {0} + In Services/MetaUpdateService.cs + + + Falha ao baixar MetaEntry {0} + In Services/MetaUpdateService.cs + + + Falha ao deserializar MetaDefinition + In Services/MetaUpdateService.cs + + + Falha ao baixar MetaDefinition de {0} + In Services/MetaUpdateService.cs + + + Decodificador: Ignorando linha {0} + In Services/SerialLineDecoder.cs + + + UEM / OS Error + In Services/SerialLineDecoder.cs + + + Falha ao entrar no modo REPL. Talvez você esteja usando a porta serial errada? + In Services/SerialService.cs + + + Falha ao processar a informação sobre a versão. Você está usando o firwmare v0.2.3 ou superior? + In Services/SerialService.cs + + + Falha ao processar as informações de configuração. + In Services/SerialService.cs + + + Falha para obter resposta do comando version! + In Services/SerialService.cs + + + Falha para obter o estado da configuração! + In Services/SerialService.cs + + + Indisponível + In ViewModels/MainWindowViewModel.cs + + + Pressione para escanear + In ViewModels/MainWindowViewModel.cs + + + Não conectado + In ViewModels/MainWindowViewModel.cs + + + Nunca + In ViewModels/MainWindowViewModel.cs + + + Uma nova versão de definição do metadata está disponível. + In ViewModels/MainWindowViewModel.cs + + + Esta atualização contém os códigos de post e definições de erro mais recentes para o seu console. Você gostaria de atualizar? + In ViewModels/MainWindowViewModel.cs + + + Falha ao ataulizar o metadata + In ViewModels/MainWindowViewModel.cs + + + Erro + In ViewModels/MainWindowViewModel.cs + + + Aviso + In ViewModels/MainWindowViewModel.cs + + + Falha ao atualizar o medata: {0} + In ViewModels/MainWindowViewModel.cs + + + Falha ao carregar a definição local de metadata + In ViewModels/MainWindowViewModel.cs + + + Falha ao carregar a definição local de metadata. A aplicação continuará sem o metadata. + In ViewModels/MainWindowViewModel.cs + + + Falha ao carregar as definições de metadata + In ViewModels/MainWindowViewModel.cs + + + Falha ao carregar as definições de metadata: {0} + In ViewModels/MainWindowViewModel.cs + + + Salvar Arquivo Log + In ViewModels/MainWindowViewModel.cs + + + Arquivos Log + In ViewModels/MainWindowViewModel.cs + + + Erro ao salvar o arquivo de log + In ViewModels/MainWindowViewModel.cs + + + Erro ao salvar o arquivo de log: {0} + In ViewModels/MainWindowViewModel.cs + + + Erro de conexão + In ViewModels/MainWindowViewModel.cs + + + Falha ao conectar na porta serial: {0} + In ViewModels/MainWindowViewModel.cs + + + Falha para obter MainWindow + In ViewModels/MainWindowViewModel.cs + + + Falha para obter ApplicationLifetime + In ViewModels/MainWindowViewModel.cs + + + Configuração + In Views/ConfigurationDialog.axaml + + + Configurações de Idioma + In Views/ConfigurationDialog.axaml + + + Configurações de Atualização + In Views/ConfigurationDialog.axaml + + + Verifique atualizações do aplicativo + In Views/ConfigurationDialog.axaml + + + URL de atualização do aplicativo + In Views/ConfigurationDialog.axaml + + + Verifique atualizações dos códigos + In Views/ConfigurationDialog.axaml + + + URL do arquivo meta de códigos + In Views/ConfigurationDialog.axaml + + + Verifique atualizações de firmware + In Views/ConfigurationDialog.axaml + + + URL de atualização do firmware + In Views/ConfigurationDialog.axaml + + + Cancelar + In Views/ConfigurationDialog.axaml + + + Salvar + In Views/ConfigurationDialog.axaml + + + Xbox PostCode Serial Monitor + In Views/MainWindow.axaml + + + Atualizar portas + In Views/MainWindow.axaml + + + Conectar + In Views/MainWindow.axaml + + + Desconectar + In Views/MainWindow.axaml + + + Salvar Log + In Views/MainWindow.axaml + + + Versão do App: + In Views/MainWindow.axaml + + + Visite XboxResearch.com + In Views/MainWindow.axaml + + + Pico Firmware: + In Views/MainWindow.axaml + + + Metadata Update: + In Views/MainWindow.axaml + + + Falha ao abrir URL: {0} + In Views/MainWindow.axaml.cs + + diff --git a/PostCodeSerialMonitor/Assets/Resources.resx b/PostCodeSerialMonitor/Assets/Resources.resx new file mode 100644 index 0000000..ac64898 --- /dev/null +++ b/PostCodeSerialMonitor/Assets/Resources.resx @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Expected a string token + In Models/JsonConverters.cs file + + + Failed reading field as string + In Models/JsonConverters.cs file + + + Invalid base64-urlsafe string + In Models/JsonConverters.cs file + + + Configuration saved successfully + In Services/ConfigurationService.cs + + + Failed to save configuration + In Services/ConfigurationService.cs + + + Configuration updated successfully + In Services/ConfigurationService.cs + + + Failed to update configuration + In Services/ConfigurationService.cs + + + LoadMetaDefinitions: File {0} does not exist + In Services/MetaDefinitionService.cs + + + LoadMetaDefinitions: Unexpected MetaType: {0} + In Services/MetaDefinitionService.cs + + + Meta content: {0} + In Services/MetaUpdateService.cs + + + Failed to download MetaEntry {0} + In Services/MetaUpdateService.cs + + + Failed deserializing MetaDefinition + In Services/MetaUpdateService.cs + + + Failed to download MetaDefinition from {0} + In Services/MetaUpdateService.cs + + + Decoder: Ignoring line {0} + In Services/SerialLineDecoder.cs + + + UEM / OS Error + In Services/SerialLineDecoder.cs + + + Failed to enter REPL. Maybe you are using the wrong serial device? + In Services/SerialService.cs + + + Failed to parse version information. Are you on FW v0.2.3 or greater? + In Services/SerialService.cs + + + Failed to parse config information. + In Services/SerialService.cs + + + Failed to get version reply! + In Services/SerialService.cs + + + Failed to get config state! + In Services/SerialService.cs + + + Unavailable + In ViewModels/MainWindowViewModel.cs + + + Press button to scan + In ViewModels/MainWindowViewModel.cs + + + Not connected + In ViewModels/MainWindowViewModel.cs + + + Never + In ViewModels/MainWindowViewModel.cs + + + A new metadata definition is available. + In ViewModels/MainWindowViewModel.cs + + + This update contains the latest post codes and error definitions for your console. Would you like to update? + In ViewModels/MainWindowViewModel.cs + + + Failed to update metadata + In ViewModels/MainWindowViewModel.cs + + + Error + In ViewModels/MainWindowViewModel.cs + + + Warning + In ViewModels/MainWindowViewModel.cs + + + Failed to update metadata: {0} + In ViewModels/MainWindowViewModel.cs + + + Failed to load local metadata definition + In ViewModels/MainWindowViewModel.cs + + + Failed to load local metadata definition. The application will continue without metadata. + In ViewModels/MainWindowViewModel.cs + + + Failed to load metadata definitions + In ViewModels/MainWindowViewModel.cs + + + Failed to load metadata definitions: {0} + In ViewModels/MainWindowViewModel.cs + + + Save Log File + In ViewModels/MainWindowViewModel.cs + + + Log Files + In ViewModels/MainWindowViewModel.cs + + + Error saving log file + In ViewModels/MainWindowViewModel.cs + + + Failed saving logfile: {0} + In ViewModels/MainWindowViewModel.cs + + + Connection error + In ViewModels/MainWindowViewModel.cs + + + Connection to serialport failed: {0} + In ViewModels/MainWindowViewModel.cs + + + Failed to get MainWindow + In ViewModels/MainWindowViewModel.cs + + + Failed to get ApplicationLifetime + In ViewModels/MainWindowViewModel.cs + + + Configuration + In Views/ConfigurationDialog.axaml + + + Language Settings + In Views/ConfigurationDialog.axaml + + + Update Settings + In Views/ConfigurationDialog.axaml + + + Check for application updates + In Views/ConfigurationDialog.axaml + + + Application update URL + In Views/ConfigurationDialog.axaml + + + Check for code updates + In Views/ConfigurationDialog.axaml + + + Code meta definition URL + In Views/ConfigurationDialog.axaml + + + Check for firmware updates + In Views/ConfigurationDialog.axaml + + + Firmware update URL + In Views/ConfigurationDialog.axaml + + + Cancel + In Views/ConfigurationDialog.axaml + + + Save + In Views/ConfigurationDialog.axaml + + + Xbox PostCode Serial Monitor + In Views/MainWindow.axaml + + + Refresh Ports + In Views/MainWindow.axaml + + + Connect + In Views/MainWindow.axaml + + + Disconnect + In Views/MainWindow.axaml + + + Save Log + In Views/MainWindow.axaml + + + App Version: + In Views/MainWindow.axaml + + + Visit XboxResearch.com + In Views/MainWindow.axaml + + + Pico Firmware: + In Views/MainWindow.axaml + + + Metadata Update: + In Views/MainWindow.axaml + + + Failed to open URL: {0} + In Views/MainWindow.axaml.cs + + diff --git a/PostCodeSerialMonitor/Models/AppConfiguration.cs b/PostCodeSerialMonitor/Models/AppConfiguration.cs index 4e8349d..2642e02 100644 --- a/PostCodeSerialMonitor/Models/AppConfiguration.cs +++ b/PostCodeSerialMonitor/Models/AppConfiguration.cs @@ -25,6 +25,9 @@ public class AppConfiguration [Url] public Uri FwUpdateUrl { get; set; } = new Uri("https://example.com/todo"); + [Required] + public string Language { get; set; } = "en-US"; + [NotMapped] public string MetaStoragePath => "meta"; diff --git a/PostCodeSerialMonitor/Models/CodeFlavor.cs b/PostCodeSerialMonitor/Models/CodeFlavor.cs index 70011a1..9c9399d 100644 --- a/PostCodeSerialMonitor/Models/CodeFlavor.cs +++ b/PostCodeSerialMonitor/Models/CodeFlavor.cs @@ -1,8 +1,3 @@ -using System; -using CsvHelper; -using CsvHelper.Configuration; -using CsvHelper.TypeConversion; - namespace PostCodeSerialMonitor.Models; public enum CodeFlavor diff --git a/PostCodeSerialMonitor/Models/CodeSeverity.cs b/PostCodeSerialMonitor/Models/CodeSeverity.cs index 1810e74..d819db1 100644 --- a/PostCodeSerialMonitor/Models/CodeSeverity.cs +++ b/PostCodeSerialMonitor/Models/CodeSeverity.cs @@ -1,5 +1,3 @@ -using System; - namespace PostCodeSerialMonitor.Models; public enum CodeSeverity { diff --git a/PostCodeSerialMonitor/Models/ConsoleType.cs b/PostCodeSerialMonitor/Models/ConsoleType.cs index 0d21494..06033bb 100644 --- a/PostCodeSerialMonitor/Models/ConsoleType.cs +++ b/PostCodeSerialMonitor/Models/ConsoleType.cs @@ -1,5 +1,3 @@ -using System; - namespace PostCodeSerialMonitor.Models; public enum ConsoleType diff --git a/PostCodeSerialMonitor/Models/JsonConverters.cs b/PostCodeSerialMonitor/Models/JsonConverters.cs index 2aad854..e71e45d 100644 --- a/PostCodeSerialMonitor/Models/JsonConverters.cs +++ b/PostCodeSerialMonitor/Models/JsonConverters.cs @@ -3,7 +3,6 @@ using System.IO; using System.Text.Json; using System.Text.Json.Serialization; - namespace PostCodeSerialMonitor.Models; public class Base64UrlByteArrayConverter : JsonConverter @@ -12,11 +11,11 @@ public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS { if (reader.TokenType != JsonTokenType.String) { - throw new JsonException("Expected a string token"); + throw new JsonException(Assets.Resources.ExpectedStringToken); } string base64String = reader.GetString() - ?? throw new InvalidDataException("Failed reading field as string"); + ?? throw new InvalidDataException(Assets.Resources.FailedReadingString); try @@ -25,7 +24,7 @@ public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS } catch (FormatException ex) { - throw new JsonException("Invalid base64-urlsafe string", ex); + throw new JsonException(Assets.Resources.InvalidBase64String, ex); } } diff --git a/PostCodeSerialMonitor/Models/PostCodeDefinition.cs b/PostCodeSerialMonitor/Models/PostCodeDefinition.cs index 05932e7..4dbcc19 100644 --- a/PostCodeSerialMonitor/Models/PostCodeDefinition.cs +++ b/PostCodeSerialMonitor/Models/PostCodeDefinition.cs @@ -1,4 +1,3 @@ -using System; using CsvHelper.Configuration.Attributes; namespace PostCodeSerialMonitor.Models; diff --git a/PostCodeSerialMonitor/PostCodeSerialMonitor.csproj b/PostCodeSerialMonitor/PostCodeSerialMonitor.csproj index d572fa5..a372915 100644 --- a/PostCodeSerialMonitor/PostCodeSerialMonitor.csproj +++ b/PostCodeSerialMonitor/PostCodeSerialMonitor.csproj @@ -22,6 +22,21 @@ + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + + True + True + Resources.resx + + + diff --git a/PostCodeSerialMonitor/ServiceCollectionExtensions.cs b/PostCodeSerialMonitor/ServiceCollectionExtensions.cs index d666a1b..20a9a26 100644 --- a/PostCodeSerialMonitor/ServiceCollectionExtensions.cs +++ b/PostCodeSerialMonitor/ServiceCollectionExtensions.cs @@ -5,12 +5,8 @@ using System.Text.Json.Serialization; using PostCodeSerialMonitor.Models; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Configuration; -using System.Threading.Tasks; -using System; using Microsoft.Extensions.Logging.Console; -using System.IO; namespace PostCodeSerialMonitor; diff --git a/PostCodeSerialMonitor/Services/ConfigurationService.cs b/PostCodeSerialMonitor/Services/ConfigurationService.cs index c94165f..e027dd1 100644 --- a/PostCodeSerialMonitor/Services/ConfigurationService.cs +++ b/PostCodeSerialMonitor/Services/ConfigurationService.cs @@ -36,11 +36,11 @@ public async Task SaveConfigurationAsync() }); await File.WriteAllTextAsync(_configFilePath, json); - _logger.LogInformation("Configuration saved successfully"); + _logger.LogInformation(Assets.Resources.ConfigurationSaved); } catch (Exception ex) { - _logger.LogError(ex, "Failed to save configuration"); + _logger.LogError(ex, Assets.Resources.FailedSaveConfiguration); throw; } } @@ -52,11 +52,11 @@ public async Task UpdateConfigurationAsync(Action updateAction var config = _configurationMonitor.CurrentValue; updateAction(config); await SaveConfigurationAsync(); - _logger.LogInformation("Configuration updated successfully"); + _logger.LogInformation(Assets.Resources.ConfigurationUpdated); } catch (Exception ex) { - _logger.LogError(ex, "Failed to update configuration"); + _logger.LogError(ex, Assets.Resources.FailedUpdateConfiguration); throw; } } diff --git a/PostCodeSerialMonitor/Services/CsvParsingService.cs b/PostCodeSerialMonitor/Services/CsvParsingService.cs index 5087c65..8a0fe93 100644 --- a/PostCodeSerialMonitor/Services/CsvParsingService.cs +++ b/PostCodeSerialMonitor/Services/CsvParsingService.cs @@ -1,4 +1,3 @@ - using System.IO; using System.Linq; using System.Globalization; diff --git a/PostCodeSerialMonitor/Services/MetaDefinitionService.cs b/PostCodeSerialMonitor/Services/MetaDefinitionService.cs index 08e9791..6ebd140 100644 --- a/PostCodeSerialMonitor/Services/MetaDefinitionService.cs +++ b/PostCodeSerialMonitor/Services/MetaDefinitionService.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -43,7 +42,7 @@ public async Task RefreshMetaDefinitionsAsync() var filePath = Path.Combine(_configurationService.Config.MetaStoragePath, entry.Path); if (!File.Exists(filePath)) { - _logger.LogError("LoadMetaDefinitions: File {filePath} does not exist", filePath); + _logger.LogError(Assets.Resources.MetaFileNotExist, filePath); continue; } @@ -61,7 +60,7 @@ public async Task RefreshMetaDefinitionsAsync() _osErrors.AddRange(CsvParsingService.ParseOSErrors(content)); break; default: - _logger.LogError("LoadMetaDefinitions: Unexpected MetaType: {metaType}", entry.MetaType); + _logger.LogError(Assets.Resources.UnexpectedMetaType, entry.MetaType); break; } } diff --git a/PostCodeSerialMonitor/Services/MetaUpdateService.cs b/PostCodeSerialMonitor/Services/MetaUpdateService.cs index 5b35c9a..0204cd9 100644 --- a/PostCodeSerialMonitor/Services/MetaUpdateService.cs +++ b/PostCodeSerialMonitor/Services/MetaUpdateService.cs @@ -71,7 +71,7 @@ public async Task UpdateMetaDefinitionAsync() return; var metaContentStr = JsonSerializer.Serialize(metaContent, _jsonSerializeOptions); - _logger.LogDebug("Meta content: {MetaContent}", metaContentStr); + _logger.LogDebug(Assets.Resources.MetaContent, metaContentStr); // Ensure directory exists Directory.CreateDirectory(_localPath); @@ -113,7 +113,7 @@ private async Task DownloadMetaFilesAsync() } catch (Exception ex) { - _logger.LogError(ex, "Failed to download MetaEntry {FileUrl}", fileUrl); + _logger.LogError(ex, Assets.Resources.FailedDownloadMetaEntry, fileUrl); } } } @@ -132,7 +132,7 @@ private async Task DownloadMetaFilesAsync() } catch (Exception ex) { - _logger.LogError(ex, "Failed deserializing MetaDefinition"); + _logger.LogError(ex, Assets.Resources.FailedDeserializingMetaDefinition); return null; } } @@ -149,7 +149,7 @@ private async Task DownloadMetaFilesAsync() } catch (Exception ex) { - _logger.LogError(ex, "Failed to download MetaDefinition from {MetaJsonUrl}", Config.MetaJsonUrl); + _logger.LogError(ex, Assets.Resources.FailedDownloadMetaDefinition, Config.MetaJsonUrl); return null; } } diff --git a/PostCodeSerialMonitor/Services/SerialLineDecoder.cs b/PostCodeSerialMonitor/Services/SerialLineDecoder.cs index d03ca0b..be27df0 100644 --- a/PostCodeSerialMonitor/Services/SerialLineDecoder.cs +++ b/PostCodeSerialMonitor/Services/SerialLineDecoder.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Text.RegularExpressions; using System.Linq; using PostCodeSerialMonitor.Models; @@ -23,7 +22,7 @@ public SerialLineDecoder(MetaDefinitionService metaDefinitionService, ILogger ParseVersionInfo() var res = await ReadUntilEnd(); if (!res.Contains("FW: ")) { - _logger.LogError("Failed to get version reply!"); + _logger.LogError(Assets.Resources.FailedGetVersion); return false; } @@ -152,7 +151,7 @@ private async Task ParseConfigState() var res = await ReadUntilEnd(); if (!res.Contains("Display mirrored:")) { - _logger.LogError("Failed to get config state!"); + _logger.LogError(Assets.Resources.FailedGetState); return false; } diff --git a/PostCodeSerialMonitor/ViewModels/ConfigurationDialogViewModel.cs b/PostCodeSerialMonitor/ViewModels/ConfigurationDialogViewModel.cs index 6a80695..4f7fbe8 100644 --- a/PostCodeSerialMonitor/ViewModels/ConfigurationDialogViewModel.cs +++ b/PostCodeSerialMonitor/ViewModels/ConfigurationDialogViewModel.cs @@ -1,3 +1,4 @@ +using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using PostCodeSerialMonitor.Models; @@ -31,6 +32,11 @@ public partial class ConfigurationDialogViewModel : ViewModelBase [ObservableProperty] private string fwUpdateUrl; + public ObservableCollection Languages { get; } = new(); + + [ObservableProperty] + private string selectedLanguage; + public ConfigurationDialogViewModel(ConfigurationService configurationService) { _configurationService = configurationService; @@ -43,6 +49,11 @@ public ConfigurationDialogViewModel(ConfigurationService configurationService) AppUpdateUrl = _originalConfiguration.AppUpdateUrl.ToString(); CodesMetaBaseUrl = _originalConfiguration.CodesMetaBaseUrl.ToString(); FwUpdateUrl = _originalConfiguration.FwUpdateUrl.ToString(); + SelectedLanguage = _originalConfiguration.Language; + + //Add available languages + Languages.Add("en-US"); + Languages.Add("pt-BR"); } [RelayCommand] @@ -56,6 +67,7 @@ await _configurationService.UpdateConfigurationAsync(config => config.AppUpdateUrl = new Uri(AppUpdateUrl); config.CodesMetaBaseUrl = new Uri(CodesMetaBaseUrl); config.FwUpdateUrl = new Uri(FwUpdateUrl); + config.Language = SelectedLanguage; }); window.Close(); diff --git a/PostCodeSerialMonitor/ViewModels/MainWindowViewModel.cs b/PostCodeSerialMonitor/ViewModels/MainWindowViewModel.cs index 161d27b..aa01310 100644 --- a/PostCodeSerialMonitor/ViewModels/MainWindowViewModel.cs +++ b/PostCodeSerialMonitor/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,3 @@ - using System; using System.Collections.ObjectModel; using System.Linq; @@ -12,10 +11,10 @@ using Avalonia.Controls.ApplicationLifetimes; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; - using PostCodeSerialMonitor.Views; using PostCodeSerialMonitor.Services; using PostCodeSerialMonitor.Models; + using MsBox.Avalonia; using MsBox.Avalonia.Enums; @@ -38,7 +37,7 @@ public partial class MainWindowViewModel : ViewModelBase public ObservableCollection LogEntries { get; } = new(); public ObservableCollection RawLogEntries { get; } = new(); - private string lastConnectedPicoFwVersion = "Unavailable"; + private string lastConnectedPicoFwVersion = Assets.Resources.Unavailable; [ObservableProperty] private ConsoleType selectedConsoleModel; @@ -62,16 +61,16 @@ public partial class MainWindowViewModel : ViewModelBase private bool printTimestamps; [ObservableProperty] - private string i2cScanOutput = "Press button to scan"; + private string i2cScanOutput = Assets.Resources.ScanButtonText; [ObservableProperty] - private string firmwareVersion = "Not connected"; + private string firmwareVersion = Assets.Resources.NotConnected; [ObservableProperty] private string buildDate = string.Empty; [ObservableProperty] - private string metadataLastUpdate = "Never"; + private string metadataLastUpdate = Assets.Resources.Never; [ObservableProperty] private string appVersion; @@ -126,8 +125,8 @@ public async void OnLoaded() { var box = MessageBoxManager .GetMessageBoxStandard( - "A new metadata definition is available.", - "This update contains the latest post codes and error definitions for your console. Would you like to update?", + Assets.Resources.NewMetadataAvailable, + Assets.Resources.NewMetadataAvailableInformation, ButtonEnum.YesNo ); @@ -141,24 +140,23 @@ public async void OnLoaded() } catch (Exception ex) { - _logger.LogError(ex, "Failed to update metadata"); + _logger.LogError(ex, Assets.Resources.FailedUpdateMetadata); await MessageBoxManager - .GetMessageBoxStandard("Error", $"Failed to update metadata: {ex.Message}", - ButtonEnum.Ok) + .GetMessageBoxStandard(Assets.Resources.Error, string.Format(Assets.Resources.FailedUpdateMetadataMessageBoxError, ex.Message), ButtonEnum.Ok) .ShowAsync(); } } } // Update the metadata last update timestamp - MetadataLastUpdate = _metaUpdateService.LastUpdateTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "Never"; + MetadataLastUpdate = _metaUpdateService.LastUpdateTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? Assets.Resources.Never; var success = await _metaUpdateService.TryLoadLocalDefinition(); if (!success) { - _logger.LogWarning("Failed to load local metadata definition"); + _logger.LogWarning(Assets.Resources.FailedLoadLocalMetadata); var box = MessageBoxManager - .GetMessageBoxStandard("Warning", "Failed to load local metadata definition. The application will continue without metadata.", + .GetMessageBoxStandard(Assets.Resources.Warning, Assets.Resources.FailedLoadLocalMetadataMessageBoxWarning, ButtonEnum.Ok); await box.ShowAsync(); @@ -170,9 +168,9 @@ await MessageBoxManager } catch (Exception ex) { - _logger.LogError(ex, "Failed to load metadata definitions"); + _logger.LogError(ex, Assets.Resources.FailedLoadLocalMetadata); await MessageBoxManager - .GetMessageBoxStandard("Error", $"Failed to load metadata definitions: {ex.Message}", + .GetMessageBoxStandard(Assets.Resources.Error, string.Format(Assets.Resources.FailedLoadLocalMetadataMessageBoxError, ex.Message), ButtonEnum.Ok) .ShowAsync(); } @@ -189,12 +187,12 @@ private async Task SaveLogAsync() var file = await _storageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { - Title = "Save Log File", + Title = Assets.Resources.SaveLogFiles, DefaultExtension = "log", SuggestedFileName = defaultName, FileTypeChoices = new[] { - new FilePickerFileType("Log Files") + new FilePickerFileType(Assets.Resources.LogFiles) { Patterns = new[] { "*.log" } } @@ -235,9 +233,9 @@ private async Task SaveLogAsync() } catch (Exception ex) { - _logger.LogError(ex, "Error saving log file"); + _logger.LogError(ex, Assets.Resources.ErrorSavingLogFile); await MessageBoxManager - .GetMessageBoxStandard("Error", $"Failed saving logfile: {ex.Message}", + .GetMessageBoxStandard(Assets.Resources.Error, string.Format(Assets.Resources.ErrorSavingLogFileMessageBoxError, ex.Message), ButtonEnum.Ok) .ShowAsync(); } @@ -267,9 +265,9 @@ private async Task ConnectAsync() } catch (Exception ex) { - _logger.LogError(ex, "Connection error"); + _logger.LogError(ex, Assets.Resources.ErrorConection); await MessageBoxManager - .GetMessageBoxStandard("Error", $"Connection to serialport failed: {ex.Message}", + .GetMessageBoxStandard(Assets.Resources.Error, string.Format(Assets.Resources.ErrorConectionMessageBoxError,ex.Message), ButtonEnum.Ok) .ShowAsync(); } @@ -297,12 +295,12 @@ private void OnDataReceived(string line) private void OnDisconnected() { IsConnected = false; - FirmwareVersion = "Not connected"; + FirmwareVersion = Assets.Resources.NotConnected; BuildDate = string.Empty; MirrorDisplay = false; PortraitMode = false; PrintTimestamps = false; - I2cScanOutput = "Press button to scan"; + I2cScanOutput = Assets.Resources.ScanButtonText; var prevSelectedPort = SelectedPort; RefreshPorts(); if (prevSelectedPort != null && SerialPorts.Contains(prevSelectedPort)) { @@ -339,8 +337,8 @@ private async Task ShowConfigurationAsync() private Window GetParentWindow() { if (Avalonia.Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - return desktop?.MainWindow ?? throw new Exception("Failed to get MainWindow"); + return desktop?.MainWindow ?? throw new Exception(Assets.Resources.FailedGetMainWindow); else - throw new Exception("Failed to get ApplicationLifetime"); + throw new Exception(Assets.Resources.FailedGetApplicationLifetime); } } \ No newline at end of file diff --git a/PostCodeSerialMonitor/Views/ConfigurationDialog.axaml b/PostCodeSerialMonitor/Views/ConfigurationDialog.axaml index 5703637..cbf25a0 100644 --- a/PostCodeSerialMonitor/Views/ConfigurationDialog.axaml +++ b/PostCodeSerialMonitor/Views/ConfigurationDialog.axaml @@ -3,43 +3,49 @@ xmlns:vm="using:PostCodeSerialMonitor.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:assets="clr-namespace:PostCodeSerialMonitor.Assets" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450" x:Class="PostCodeSerialMonitor.Views.ConfigurationDialog" x:DataType="vm:ConfigurationDialogViewModel" - Title="Configuration" + Title="{x:Static assets:Resources.Configuration}" Width="400" Height="450" WindowStartupLocation="CenterOwner"> - - - + + + + + - - -