diff --git a/Directory.Packages.props b/Directory.Packages.props index 435a962..232098f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -19,6 +19,7 @@ + diff --git a/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor b/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor index c33ee86..aa19ab2 100644 --- a/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor +++ b/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor @@ -1,10 +1,13 @@ +@using Microsoft.Extensions.Localization +@using RomRepoMgr.Blazor.Resources @implements IDialogContentComponent -@inject ILogger Logger +@inject ILogger Logger +@inject IStringLocalizer Localizer
- + @StatusMessage
@@ -18,8 +21,8 @@
- Start - Close + @Localizer["Start"] + @Localizer["Close"]
\ No newline at end of file diff --git a/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor.cs b/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor.cs index a9761eb..9a86e89 100644 --- a/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor.cs +++ b/RomRepoMgr.Blazor/Components/Dialogs/ImportDats.razor.cs @@ -52,7 +52,7 @@ public partial class ImportDats : ComponentBase CannotClose = true; ProgressVisible = true; ProgressValue = null; - StatusMessage = "Searching for files..."; + StatusMessage = Localizer["SearchingForFiles"]; _stopwatch.Restart(); string[] dats = Directory.GetFiles(path, "*.dat", SearchOption.AllDirectories); @@ -66,7 +66,7 @@ public partial class ImportDats : ComponentBase _stopwatch.Elapsed.TotalSeconds, _datFiles.Length); - StatusMessage = string.Format("Found {0} files...", _datFiles.Length); + StatusMessage = string.Format(Localizer["FoundFiles"], _datFiles.Length); ProgressMin = 0; ProgressMax = _datFiles.Length; @@ -89,7 +89,7 @@ public partial class ImportDats : ComponentBase { ProgressVisible = false; Progress2Visible = false; - StatusMessage = "Finished"; + StatusMessage = Localizer["Finished"]; CannotClose = false; StateHasChanged(); @@ -107,7 +107,7 @@ public partial class ImportDats : ComponentBase _ = InvokeAsync(() => { - StatusMessage = string.Format("Importing {0}...", Path.GetFileName(_datFiles[_listPosition])); + StatusMessage = string.Format(Localizer["ImportingItem"], Path.GetFileName(_datFiles[_listPosition])); ProgressValue = _listPosition; StateHasChanged(); diff --git a/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor b/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor index 85fc62b..328a0b6 100644 --- a/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor +++ b/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor @@ -1,19 +1,22 @@ +@using Microsoft.Extensions.Localization +@using RomRepoMgr.Blazor.Resources @using RomRepoMgr.Database @implements IDialogContentComponent -@inject ILogger Logger -@inject Context _ctx +@inject ILogger Logger +@inject Context _ctx +@inject IStringLocalizer Localizer - + @if(NotYetStarted) { - + - + + Label=@Localizer["RecurseArchivesLabel"]/> } @if(Importing) { @@ -32,8 +35,8 @@ - Start - Close + @Localizer["Start"] + @Localizer["Close"] \ No newline at end of file diff --git a/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor.cs b/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor.cs index 7d997a5..789fa89 100644 --- a/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor.cs +++ b/RomRepoMgr.Blazor/Components/Dialogs/ImportRoms.razor.cs @@ -12,42 +12,39 @@ namespace RomRepoMgr.Blazor.Components.Dialogs; public partial class ImportRoms : ComponentBase { - readonly ConcurrentBag _newDisks = []; - readonly ConcurrentBag _newFiles = []; - readonly ConcurrentBag _newMedias = []; + readonly Stopwatch _mainStopwatch = new(); + readonly ConcurrentBag _newDisks = []; + readonly ConcurrentBag _newFiles = []; + readonly ConcurrentBag _newMedias = []; + readonly Stopwatch _stopwatch = new(); int _listPosition; - - readonly Stopwatch _mainStopwatch = new(); - FileImporter _rootImporter; - readonly Stopwatch _stopwatch = new(); - PaginationState? pagination; + FileImporter _rootImporter; + PaginationState? pagination; [CascadingParameter] - public FluentDialog Dialog { get; set; } - public bool IsBusy { get; set; } - public bool NotYetStarted { get; set; } - public bool RemoveFilesChecked { get; set; } - public bool KnownOnlyChecked { get; set; } - public bool RecurseArchivesChecked { get; set; } - public Color? StatusMessageColor { get; set; } - public string? StatusMessage { get; set; } - public int? ProgressMax { get; set; } - public int? ProgressMin { get; set; } - public int? ProgressValue { get; set; } - public string? StatusMessage2 { get; set; } - public int? Progress2Max { get; set; } - public int? Progress2Min { get; set; } - public int? Progress2Value { get; set; } - public IQueryable? Importers { get; set; } - public string? FolderPath { get; set; } - public bool Importing { get; set; } - public bool Progress2Visible { get; set; } - public bool DataGridVisible { get; set; } - public bool CannotClose { get; set; } + public FluentDialog Dialog { get; set; } + public bool IsBusy { get; set; } + public bool NotYetStarted { get; set; } + public bool RemoveFilesChecked { get; set; } + public bool KnownOnlyChecked { get; set; } + public bool RecurseArchivesChecked { get; set; } + public Color? StatusMessageColor { get; set; } + public string? StatusMessage { get; set; } + public int? ProgressMax { get; set; } + public int? ProgressMin { get; set; } + public int? ProgressValue { get; set; } + public string? StatusMessage2 { get; set; } + public int? Progress2Max { get; set; } + public int? Progress2Min { get; set; } + public int? Progress2Value { get; set; } + public string? FolderPath { get; set; } + public bool Importing { get; set; } + public bool Progress2Visible { get; set; } + public bool DataGridVisible { get; set; } + public bool CannotClose { get; set; } protected override void OnInitialized() { base.OnInitialized(); - FolderPath = Path.Combine(Environment.CurrentDirectory, Consts.IncomingRomsFolder); IsBusy = false; NotYetStarted = true; @@ -209,7 +206,7 @@ public partial class ImportRoms : ComponentBase { _ = InvokeAsync(() => { - StatusMessage = string.Format("Importing {0}...", Path.GetFileName(file)); + StatusMessage = string.Format(Localizer["ImportingItem"], Path.GetFileName(file)); ProgressValue = _listPosition; StateHasChanged(); @@ -242,7 +239,7 @@ public partial class ImportRoms : ComponentBase CannotClose = false; IsBusy = false; Importing = false; - StatusMessage = "Finished"; + StatusMessage = Localizer["Finished"]; StateHasChanged(); }); @@ -291,7 +288,8 @@ public partial class ImportRoms : ComponentBase { _ = InvokeAsync(() => { - StatusMessage = string.Format("Processing archive: {0}", Path.GetFileName(archive)); + StatusMessage = + string.Format(Localizer["ProcessingArchive"], Path.GetFileName(archive)); ProgressValue = _listPosition; diff --git a/RomRepoMgr.Blazor/Components/Pages/Home.razor b/RomRepoMgr.Blazor/Components/Pages/Home.razor index 75fc456..7e8908d 100644 --- a/RomRepoMgr.Blazor/Components/Pages/Home.razor +++ b/RomRepoMgr.Blazor/Components/Pages/Home.razor @@ -1,35 +1,39 @@ @page "/" +@using Microsoft.Extensions.Localization +@using RomRepoMgr.Blazor.Resources @using RomRepoMgr.Database @rendermode InteractiveServer -@inject IDialogService DialogService -@inject Context ctx +@inject IDialogService DialogService +@inject Context ctx +@inject IStringLocalizer Localizer + ROM Repository Manager - Import DATs - Export DAT - Remove DAT - Import ROMs - Export ROMs + @Localizer["ImportDats"] + @Localizer["ExportDat"] + @Localizer["RemoveDat"] + @Localizer["ImportRoms"] + @Localizer["ExportRoms"] - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/RomRepoMgr.Blazor/Program.cs b/RomRepoMgr.Blazor/Program.cs index ceefe18..5d10a51 100644 --- a/RomRepoMgr.Blazor/Program.cs +++ b/RomRepoMgr.Blazor/Program.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using Microsoft.EntityFrameworkCore; using Microsoft.FluentUI.AspNetCore.Components; using RomRepoMgr.Blazor; using RomRepoMgr.Blazor.Components; @@ -57,6 +56,9 @@ builder.Host.UseSerilog(); // ✅ Plug Serilog into the host builder.Services.AddRazorComponents().AddInteractiveServerComponents(); builder.Services.AddFluentUIComponents(); +// Localization +builder.Services.AddLocalization(); + Log.Debug("Creating database context..."); builder.Services.AddDbContextFactory(options => @@ -100,6 +102,18 @@ app.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents().AddInteractiveServerRenderMode(); +// Localization +string[] supportedCultures = new[] +{ + "en", "es" +}; + +RequestLocalizationOptions localizationOptions = new RequestLocalizationOptions().SetDefaultCulture("en") + .AddSupportedCultures(supportedCultures) + .AddSupportedUICultures(supportedCultures); + +app.UseRequestLocalization(localizationOptions); + Stopwatch stopwatch = new(); using(IServiceScope scope = app.Services.CreateScope()) diff --git a/RomRepoMgr.Blazor/Resources/Localization.Designer.cs b/RomRepoMgr.Blazor/Resources/Localization.Designer.cs new file mode 100644 index 0000000..9450f6f --- /dev/null +++ b/RomRepoMgr.Blazor/Resources/Localization.Designer.cs @@ -0,0 +1,228 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RomRepoMgr.Blazor.Resources { + using System; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Localization { + + private static System.Resources.ResourceManager resourceMan; + + private static System.Globalization.CultureInfo resourceCulture; + + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Localization() { + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager { + get { + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("RomRepoMgr.Blazor.Resources.Localization", typeof(Localization).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + public static string ROMs_will_be_imported_from { + get { + return ResourceManager.GetString("ROMs_will_be_imported_from", resourceCulture); + } + } + + public static string RemoveFilesLabel { + get { + return ResourceManager.GetString("RemoveFilesLabel", resourceCulture); + } + } + + public static string KnownOnlyLabel { + get { + return ResourceManager.GetString("KnownOnlyLabel", resourceCulture); + } + } + + public static string RecurseArchivesLabel { + get { + return ResourceManager.GetString("RecurseArchivesLabel", resourceCulture); + } + } + + public static string Start { + get { + return ResourceManager.GetString("Start", resourceCulture); + } + } + + public static string Close { + get { + return ResourceManager.GetString("Close", resourceCulture); + } + } + + public static string ImportingItem { + get { + return ResourceManager.GetString("ImportingItem", resourceCulture); + } + } + + public static string ProcessingArchive { + get { + return ResourceManager.GetString("ProcessingArchive", resourceCulture); + } + } + + public static string Finished { + get { + return ResourceManager.GetString("Finished", resourceCulture); + } + } + + public static string DATs_will_be_imported_from { + get { + return ResourceManager.GetString("DATs_will_be_imported_from", resourceCulture); + } + } + + public static string SearchingForFiles { + get { + return ResourceManager.GetString("SearchingForFiles", resourceCulture); + } + } + + public static string RomSetNameLabel { + get { + return ResourceManager.GetString("RomSetNameLabel", resourceCulture); + } + } + + public static string RomSetVersionLabel { + get { + return ResourceManager.GetString("RomSetVersionLabel", resourceCulture); + } + } + + public static string RomSetAuthorLabel { + get { + return ResourceManager.GetString("RomSetAuthorLabel", resourceCulture); + } + } + + public static string RomSetCategoryLabel { + get { + return ResourceManager.GetString("RomSetCategoryLabel", resourceCulture); + } + } + + public static string RomSetDateLabel { + get { + return ResourceManager.GetString("RomSetDateLabel", resourceCulture); + } + } + + public static string RomSetDescriptionLabel { + get { + return ResourceManager.GetString("RomSetDescriptionLabel", resourceCulture); + } + } + + public static string RomSetCommentLabel { + get { + return ResourceManager.GetString("RomSetCommentLabel", resourceCulture); + } + } + + public static string HomepageLabel { + get { + return ResourceManager.GetString("HomepageLabel", resourceCulture); + } + } + + public static string RomSetTotalMachinesLabel { + get { + return ResourceManager.GetString("RomSetTotalMachinesLabel", resourceCulture); + } + } + + public static string RomSetCompleteMachinesLabel { + get { + return ResourceManager.GetString("RomSetCompleteMachinesLabel", resourceCulture); + } + } + + public static string RomSetIncompleteMachinesLabel { + get { + return ResourceManager.GetString("RomSetIncompleteMachinesLabel", resourceCulture); + } + } + + public static string RomSetTotalRomsLabel { + get { + return ResourceManager.GetString("RomSetTotalRomsLabel", resourceCulture); + } + } + + public static string RomSetHaveRomsLabel { + get { + return ResourceManager.GetString("RomSetHaveRomsLabel", resourceCulture); + } + } + + public static string RomSetMissRomsLabel { + get { + return ResourceManager.GetString("RomSetMissRomsLabel", resourceCulture); + } + } + + public static string ImportDats { + get { + return ResourceManager.GetString("ImportDats", resourceCulture); + } + } + + public static string ImportRoms { + get { + return ResourceManager.GetString("ImportRoms", resourceCulture); + } + } + + public static string ExportDat { + get { + return ResourceManager.GetString("ExportDat", resourceCulture); + } + } + + public static string RemoveDat { + get { + return ResourceManager.GetString("RemoveDat", resourceCulture); + } + } + + public static string ExportRoms { + get { + return ResourceManager.GetString("ExportRoms", resourceCulture); + } + } + } +} diff --git a/RomRepoMgr.Blazor/Resources/Localization.es.resx b/RomRepoMgr.Blazor/Resources/Localization.es.resx new file mode 100644 index 0000000..bb803d3 --- /dev/null +++ b/RomRepoMgr.Blazor/Resources/Localization.es.resx @@ -0,0 +1,108 @@ + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + Las ROMs se importarán de {0}. + + + Los ficheros DAT se importarán de {0}. + + + Cerrar + + + Exportar DAT + + + Exportar ROMs + + + Terminado + + + Página web + + + Importando {0}... + + + Importar ROMs + + + Importar solo archivos conocidos. + + + Procesando archivo: {0} + + + Intentar detectar archivos comprimiedos e importar su contenido. + + + Eliminar DAT + + + Eliminar archivos después de importar satisfactoriamente. + + + Nombre + + + Faltantes + + + Incompletos + + + Presentes + + + Descripción + + + Incompletos + + + Completos + + + Comentario + + + Categoría + + + Categoría + + + Juegos + + + ROMs + + + Versión + + + Buscando archivos... + + + Comenzar + + + Importar DATs + + \ No newline at end of file diff --git a/RomRepoMgr.Blazor/Resources/Localization.resx b/RomRepoMgr.Blazor/Resources/Localization.resx new file mode 100644 index 0000000..99a87cc --- /dev/null +++ b/RomRepoMgr.Blazor/Resources/Localization.resx @@ -0,0 +1,117 @@ + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + ROM files will be imported from {0}. + + + Remove files after import successful. + + + Only import known files. + + + Try to detect archives and import their contents. + + + Start + + + Close + + + Importing {0}... + + + Processing archive: {0} + + + Finished + + + DAT files will be imported from {0}. + + + Searching for files... + + + Name + + + Version + + + Author + + + Category + + + Date + + + Description + + + Comment + + + Homepage + + + Games + + + Complete + + + Incomplete + + + ROMs + + + Have + + + Miss + + + Import DATs + + + Import ROMs + + + Export DAT + + + Remove DAT + + + Export ROMs + + \ No newline at end of file diff --git a/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj b/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj index 51db5bb..cf0cf03 100644 --- a/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj +++ b/RomRepoMgr.Blazor/RomRepoMgr.Blazor.csproj @@ -8,10 +8,12 @@ true true true + true + @@ -24,4 +26,19 @@ + + + + PublicResXFileCodeGenerator + Localization.Designer.cs + + + + + + True + True + Localization.resx + + diff --git a/RomRepoMgr.Blazor/appsettings.Development.json b/RomRepoMgr.Blazor/appsettings.Development.json index 1996cd6..43f0124 100644 --- a/RomRepoMgr.Blazor/appsettings.Development.json +++ b/RomRepoMgr.Blazor/appsettings.Development.json @@ -1,8 +1,10 @@ { "Logging": { "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft": "Debug", + "Microsoft.Extensions.Localization": "Debug" } }, "CircuitOptions": {