Modifica per traduzioni

This commit is contained in:
Annamaria Sassi
2026-08-18 12:41:16 +02:00
parent c6a3210f74
commit 9a533d877a
3 changed files with 40 additions and 16 deletions
+17 -12
View File
@@ -2,8 +2,7 @@
using Microsoft.AspNetCore.Components;
using Newtonsoft.Json;
using NLog;
using System.Diagnostics;
using System.Text.Json;
using System.Reflection;
using WebWindowComplex.Compo;
using WebWindowComplex.DTO;
using WebWindowComplex.Json;
@@ -161,23 +160,29 @@ namespace WebWindowComplex
protected override async Task OnInitializedAsync()
{
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Data", "Lemmi.json");
if (File.Exists(filePath))
var assembly = Assembly.GetExecutingAssembly();
string? resourceName = assembly.GetManifestResourceNames()
.FirstOrDefault(r => r.EndsWith("Lemmi.json", StringComparison.OrdinalIgnoreCase));
using Stream? stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
string jsonText = await File.ReadAllTextAsync(filePath);
List<string>? tradList = JsonConvert.DeserializeObject<List<string>>(jsonText);
if(tradList != null)
Log.Info("File Json non trovato");
}
else
{
using StreamReader reader = new StreamReader(stream);
string jsonContent = await reader.ReadToEndAsync();
List<string>? tradList = JsonConvert.DeserializeObject<List<string>>(jsonContent);
if (tradList != null)
{
Log.Info("Richiesta Traduzione");
prevReqTrad = true;
await EC_ReqTraduzione.InvokeAsync(tradList);
}
}
else
{
Log.Info("File Json non trovato");
}
}
/// <summary>
+8 -3
View File
@@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>3.1.8.1811</Version>
<Version>3.1.8.1812</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione Configurazioni avanzate Window per LUX</Description>
@@ -14,13 +14,13 @@
<ItemGroup>
<Content Remove="Data\Lemmi.json" />
<Content Include="Data\Lemmi.json">
<EmbeddedResource Include="Data\Lemmi.json">
<Pack>true</Pack>
<PackagePath>content\Data</PackagePath>
<PackageCopyToOutput>true</PackageCopyToOutput>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
@@ -46,3 +46,8 @@
</Project>
@@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>3.1.8.1811</Version>
<Version>3.1.8.1812</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione JWD per LUX</Description>
@@ -38,3 +38,17 @@
</Project>