From 9d38e3f6ae892b9e0adae5939c44ba17d2b5bef2 Mon Sep 17 00:00:00 2001
From: Taiizor <41683699+Taiizor@users.noreply.github.com>
Date: Mon, 22 Jan 2024 05:27:44 +0300
Subject: [PATCH] Infrastructure Preparation 60
---
.../Taiizor.Starterkit.Demo.csproj | 2 +-
.../Extension/JavascriptInterop.cs | 29 +++++++++++++++++--
.../Taiizor.Starterkit.csproj | 2 +-
.../install-from-nuget.csproj | 2 +-
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
index 1080dd2..d9ea5a7 100644
--- a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
+++ b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
@@ -14,7 +14,7 @@
-
+
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Extension/JavascriptInterop.cs b/src/Taiizor.Starterkit/Extension/JavascriptInterop.cs
index 2095b56..750bd20 100644
--- a/src/Taiizor.Starterkit/Extension/JavascriptInterop.cs
+++ b/src/Taiizor.Starterkit/Extension/JavascriptInterop.cs
@@ -1,5 +1,5 @@
+using Microsoft.Extensions.Localization;
using Microsoft.JSInterop;
-using System.Reflection;
using Taiizor.Starterkit.Interface;
namespace Taiizor.Starterkit.Extension
@@ -35,13 +35,13 @@ public JavascriptInterop(IJSRuntime js = null, string module = null, params stri
public async ValueTask InvokeAsync(string identifier, params object[] args)
{
IJSObjectReference module = await GetModuleAsync();
- return await module.InvokeAsync(identifier, args);
+ return await module.InvokeAsync(identifier, TransformLocalizationArgs(args));
}
public async ValueTask InvokeVoidAsync(string identifier, params object[] args)
{
IJSObjectReference module = await GetModuleAsync();
- await module.InvokeVoidAsync(identifier, args);
+ await module.InvokeVoidAsync(identifier, TransformLocalizationArgs(args));
}
private async ValueTask InitializeIdentifiersAsync(string[] identifiers)
@@ -60,6 +60,29 @@ private async ValueTask GetModuleAsync()
return await moduler.Value;
}
+ private object[] TransformLocalizationArgs(object[] args)
+ {
+ if (args.Any())
+ {
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i] is LocalizedString localizedString)
+ {
+ if (localizedString.ResourceNotFound)
+ {
+ args[i] = $"[{localizedString.Name}]";
+ }
+ else
+ {
+ args[i] = localizedString.Value;
+ }
+ }
+ }
+ }
+
+ return args;
+ }
+
public async ValueTask DisposeAsync()
{
try
diff --git a/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj b/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
index fe0e238..d4d16e6 100644
--- a/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
+++ b/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
@@ -13,7 +13,7 @@
Resources\Taiizor.Starterkit.ico
- 1.1.5.8
+ 1.1.5.9
$(Version)
true
Taiizor.Starterkit
diff --git a/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj b/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
index bea9525..4cc6e7c 100644
--- a/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
+++ b/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file