diff --git a/aspnetcore/push-packages.ps1 b/aspnetcore/push-packages.ps1 index 4fc832b4..45e29502 100644 --- a/aspnetcore/push-packages.ps1 +++ b/aspnetcore/push-packages.ps1 @@ -3,9 +3,9 @@ cd .\.nuget -nuget push LocalizationProvider.AspNetCore.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.AdminUI.AspNetCore.Csv.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.AdminUI.AspNetCore.Xliff.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.AdminUI.AspNetCore.8.2.3.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.AspNetCore.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.AdminUI.AspNetCore.Csv.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.AdminUI.AspNetCore.Xliff.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.AdminUI.AspNetCore.9.0.0.nupkg -source https://api.nuget.org/v3/index.json cd ..\ diff --git a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Csv/DbLocalizationProvider.AdminUI.AspNetCore.Csv.csproj b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Csv/DbLocalizationProvider.AdminUI.AspNetCore.Csv.csproj index 28a2530d..adf53e47 100644 --- a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Csv/DbLocalizationProvider.AdminUI.AspNetCore.Csv.csproj +++ b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Csv/DbLocalizationProvider.AdminUI.AspNetCore.Csv.csproj @@ -1,11 +1,11 @@  - net8.0 - 8.2.3 + net9.0 + 9.0.0 enable - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Xliff/DbLocalizationProvider.AdminUI.AspNetCore.Xliff.csproj b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Xliff/DbLocalizationProvider.AdminUI.AspNetCore.Xliff.csproj index a7ba2c96..b880660c 100644 --- a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Xliff/DbLocalizationProvider.AdminUI.AspNetCore.Xliff.csproj +++ b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore.Xliff/DbLocalizationProvider.AdminUI.AspNetCore.Xliff.csproj @@ -1,11 +1,11 @@  - net8.0 - 8.2.3 + net9.0 + 9.0.0 enable - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore/DbLocalizationProvider.AdminUI.AspNetCore.csproj b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore/DbLocalizationProvider.AdminUI.AspNetCore.csproj index c7c075a4..c0fbdfd0 100644 --- a/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore/DbLocalizationProvider.AdminUI.AspNetCore.csproj +++ b/aspnetcore/src/DbLocalizationProvider.AdminUI.AspNetCore/DbLocalizationProvider.AdminUI.AspNetCore.csproj @@ -1,11 +1,11 @@  - net8.0 + net9.0 enable - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/aspnetcore/src/DbLocalizationProvider.AspNetCore/DbLocalizationProvider.AspNetCore.csproj b/aspnetcore/src/DbLocalizationProvider.AspNetCore/DbLocalizationProvider.AspNetCore.csproj index 509c2ef8..53a6b080 100644 --- a/aspnetcore/src/DbLocalizationProvider.AspNetCore/DbLocalizationProvider.AspNetCore.csproj +++ b/aspnetcore/src/DbLocalizationProvider.AspNetCore/DbLocalizationProvider.AspNetCore.csproj @@ -1,11 +1,11 @@  - net8.0 - 8.2.3 + net9.0 + 9.0.0 enable - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/aspnetcore/tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests.csproj b/aspnetcore/tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests.csproj index 69480ea3..7a7e2241 100644 --- a/aspnetcore/tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests.csproj +++ b/aspnetcore/tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests/DbLocalizationProvider.AdminUI.AspNetCore.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 false true true @@ -9,8 +9,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/aspnetcore/tests/DbLocalizationProvider.AspNetCore.Tests/DbLocalizationProvider.AspNetCore.Tests.csproj b/aspnetcore/tests/DbLocalizationProvider.AspNetCore.Tests/DbLocalizationProvider.AspNetCore.Tests.csproj index 9ee396fa..17d8490b 100644 --- a/aspnetcore/tests/DbLocalizationProvider.AspNetCore.Tests/DbLocalizationProvider.AspNetCore.Tests.csproj +++ b/aspnetcore/tests/DbLocalizationProvider.AspNetCore.Tests/DbLocalizationProvider.AspNetCore.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable false @@ -11,9 +11,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/aspnetcore/tests/DbLocalizationProvider.Core.AspNet.ForeignAssembly/DbLocalizationProvider.Core.AspNet.ForeignAssembly.csproj b/aspnetcore/tests/DbLocalizationProvider.Core.AspNet.ForeignAssembly/DbLocalizationProvider.Core.AspNet.ForeignAssembly.csproj index 11f507ff..1a3c9a91 100644 --- a/aspnetcore/tests/DbLocalizationProvider.Core.AspNet.ForeignAssembly/DbLocalizationProvider.Core.AspNet.ForeignAssembly.csproj +++ b/aspnetcore/tests/DbLocalizationProvider.Core.AspNet.ForeignAssembly/DbLocalizationProvider.Core.AspNet.ForeignAssembly.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 diff --git a/aspnetcore/tests/DbLocalizationProvider.Core.AspNetSample/DbLocalizationProvider.Core.AspNetSample.csproj b/aspnetcore/tests/DbLocalizationProvider.Core.AspNetSample/DbLocalizationProvider.Core.AspNetSample.csproj index 2f4acf3d..67b50ec6 100644 --- a/aspnetcore/tests/DbLocalizationProvider.Core.AspNetSample/DbLocalizationProvider.Core.AspNetSample.csproj +++ b/aspnetcore/tests/DbLocalizationProvider.Core.AspNetSample/DbLocalizationProvider.Core.AspNetSample.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 Exe aspnet-WebApplication1-9B9309A9-91AD-455F-92EB-DE32CA4D4A78 @@ -12,15 +12,15 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/aspnetcore/tests/DbLocalizationProvider.Core.AzFuncSample/DbLocalizationProvider.Core.AzFuncSample.csproj b/aspnetcore/tests/DbLocalizationProvider.Core.AzFuncSample/DbLocalizationProvider.Core.AzFuncSample.csproj index aea46cfb..802e8a4a 100644 --- a/aspnetcore/tests/DbLocalizationProvider.Core.AzFuncSample/DbLocalizationProvider.Core.AzFuncSample.csproj +++ b/aspnetcore/tests/DbLocalizationProvider.Core.AzFuncSample/DbLocalizationProvider.Core.AzFuncSample.csproj @@ -1,13 +1,13 @@ - net8.0 + net9.0 v4 - - - + + + diff --git a/common/Tests/DbLocalizationProvider.Storage.PostgreSql.Tests/DbLocalizationProvider.Storage.PostgreSql.Tests.csproj b/common/Tests/DbLocalizationProvider.Storage.PostgreSql.Tests/DbLocalizationProvider.Storage.PostgreSql.Tests.csproj index c6aea2bf..d4c15efa 100644 --- a/common/Tests/DbLocalizationProvider.Storage.PostgreSql.Tests/DbLocalizationProvider.Storage.PostgreSql.Tests.csproj +++ b/common/Tests/DbLocalizationProvider.Storage.PostgreSql.Tests/DbLocalizationProvider.Storage.PostgreSql.Tests.csproj @@ -1,20 +1,20 @@  - net8.0 + net9.0 false true ..\..\..\strongname.snk - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/common/Tests/DbLocalizationProvider.Storage.SqlServer.Tests/DbLocalizationProvider.Storage.SqlServer.Tests.csproj b/common/Tests/DbLocalizationProvider.Storage.SqlServer.Tests/DbLocalizationProvider.Storage.SqlServer.Tests.csproj index 35d849e4..b2bc80bd 100644 --- a/common/Tests/DbLocalizationProvider.Storage.SqlServer.Tests/DbLocalizationProvider.Storage.SqlServer.Tests.csproj +++ b/common/Tests/DbLocalizationProvider.Storage.SqlServer.Tests/DbLocalizationProvider.Storage.SqlServer.Tests.csproj @@ -1,15 +1,15 @@ - net8.0 + net9.0 false true ..\..\..\strongname.snk - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/common/Tests/DbLocalizationProvider.Tests/DbLocalizationProvider.Tests.csproj b/common/Tests/DbLocalizationProvider.Tests/DbLocalizationProvider.Tests.csproj index afec4747..5ae5f4f9 100644 --- a/common/Tests/DbLocalizationProvider.Tests/DbLocalizationProvider.Tests.csproj +++ b/common/Tests/DbLocalizationProvider.Tests/DbLocalizationProvider.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 false true ..\..\..\strongname.snk @@ -15,8 +15,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/common/Tests/DbLocalizationProvider.Xliff.Tests/DbLocalizationProvider.Xliff.Tests.csproj b/common/Tests/DbLocalizationProvider.Xliff.Tests/DbLocalizationProvider.Xliff.Tests.csproj index 21c52a07..9de9172b 100644 --- a/common/Tests/DbLocalizationProvider.Xliff.Tests/DbLocalizationProvider.Xliff.Tests.csproj +++ b/common/Tests/DbLocalizationProvider.Xliff.Tests/DbLocalizationProvider.Xliff.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 false true ..\..\..\strongname.snk @@ -15,8 +15,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/common/push-packages.ps1 b/common/push-packages.ps1 index c668a01c..19b16cfa 100644 --- a/common/push-packages.ps1 +++ b/common/push-packages.ps1 @@ -1,13 +1,13 @@ cd .\.nuget -nuget push LocalizationProvider.Abstractions.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.AdminUI.Models.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Csv.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Storage.AzureTables.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Storage.PostgreSql.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Storage.SqlServer.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Xliff.8.2.3.nupkg -source https://api.nuget.org/v3/index.json -nuget push LocalizationProvider.Translator.Azure.8.2.3.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Abstractions.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.AdminUI.Models.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Csv.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Storage.AzureTables.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Storage.PostgreSql.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Storage.SqlServer.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Xliff.9.0.0.nupkg -source https://api.nuget.org/v3/index.json +nuget push LocalizationProvider.Translator.Azure.9.0.0.nupkg -source https://api.nuget.org/v3/index.json cd ..\ diff --git a/common/src/DbLocalizationProvider.Abstractions/DbLocalizationProvider.Abstractions.csproj b/common/src/DbLocalizationProvider.Abstractions/DbLocalizationProvider.Abstractions.csproj index ad593085..50934539 100644 --- a/common/src/DbLocalizationProvider.Abstractions/DbLocalizationProvider.Abstractions.csproj +++ b/common/src/DbLocalizationProvider.Abstractions/DbLocalizationProvider.Abstractions.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Abstractions for database driven localization provider. Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/common/src/DbLocalizationProvider.AdminUI.Models/DbLocalizationProvider.AdminUI.Models.csproj b/common/src/DbLocalizationProvider.AdminUI.Models/DbLocalizationProvider.AdminUI.Models.csproj index d1a94fa4..facd7797 100644 --- a/common/src/DbLocalizationProvider.AdminUI.Models/DbLocalizationProvider.AdminUI.Models.csproj +++ b/common/src/DbLocalizationProvider.AdminUI.Models/DbLocalizationProvider.AdminUI.Models.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Abstractions for database driven localization provider AdminUI. Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider diff --git a/common/src/DbLocalizationProvider.Csv/DbLocalizationProvider.Csv.csproj b/common/src/DbLocalizationProvider.Csv/DbLocalizationProvider.Csv.csproj index 8c7cb8b5..9fae625b 100644 --- a/common/src/DbLocalizationProvider.Csv/DbLocalizationProvider.Csv.csproj +++ b/common/src/DbLocalizationProvider.Csv/DbLocalizationProvider.Csv.csproj @@ -1,14 +1,14 @@ - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 CSV export/import implementation for DbLocalizationProvider Valdis Iljuconoks, https://tech-fellow.eu Mattias Olsson, Valdis Iljuconoks diff --git a/common/src/DbLocalizationProvider.Storage.AzureTables/DbLocalizationProvider.Storage.AzureTables.csproj b/common/src/DbLocalizationProvider.Storage.AzureTables/DbLocalizationProvider.Storage.AzureTables.csproj index 0110fb1d..7f560dda 100644 --- a/common/src/DbLocalizationProvider.Storage.AzureTables/DbLocalizationProvider.Storage.AzureTables.csproj +++ b/common/src/DbLocalizationProvider.Storage.AzureTables/DbLocalizationProvider.Storage.AzureTables.csproj @@ -1,14 +1,14 @@ - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Azure Tables storage implementation for DbLocalizationProvider package Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu @@ -32,7 +32,7 @@ - + diff --git a/common/src/DbLocalizationProvider.Storage.PostgreSQL/DbLocalizationProvider.Storage.PostgreSql.csproj b/common/src/DbLocalizationProvider.Storage.PostgreSQL/DbLocalizationProvider.Storage.PostgreSql.csproj index 4e92bc65..cbd04653 100644 --- a/common/src/DbLocalizationProvider.Storage.PostgreSQL/DbLocalizationProvider.Storage.PostgreSql.csproj +++ b/common/src/DbLocalizationProvider.Storage.PostgreSQL/DbLocalizationProvider.Storage.PostgreSql.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 PostgreSql storage implementation for DbLocalizationProvider package Valdis Iljuconoks, https://tech-fellow.eu Laurent WEHRLEN, Valdis Iljuconoks @@ -31,8 +31,8 @@ - - + + diff --git a/common/src/DbLocalizationProvider.Storage.SqlServer/DbLocalizationProvider.Storage.SqlServer.csproj b/common/src/DbLocalizationProvider.Storage.SqlServer/DbLocalizationProvider.Storage.SqlServer.csproj index 25e5b5b3..a1e7c609 100644 --- a/common/src/DbLocalizationProvider.Storage.SqlServer/DbLocalizationProvider.Storage.SqlServer.csproj +++ b/common/src/DbLocalizationProvider.Storage.SqlServer/DbLocalizationProvider.Storage.SqlServer.csproj @@ -1,15 +1,15 @@ - net8.0 + net9.0 enable enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 SqlServer storage implementation for DbLocalizationProvider package Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu @@ -32,7 +32,7 @@ - + diff --git a/common/src/DbLocalizationProvider.Translator.Azure/DbLocalizationProvider.Translator.Azure.csproj b/common/src/DbLocalizationProvider.Translator.Azure/DbLocalizationProvider.Translator.Azure.csproj index 934baa9c..cee24623 100644 --- a/common/src/DbLocalizationProvider.Translator.Azure/DbLocalizationProvider.Translator.Azure.csproj +++ b/common/src/DbLocalizationProvider.Translator.Azure/DbLocalizationProvider.Translator.Azure.csproj @@ -1,15 +1,15 @@  - net8.0 + net9.0 enable enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Azure Cognitive services implementation for auto-translator feature. Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu @@ -33,7 +33,7 @@ - + diff --git a/common/src/DbLocalizationProvider.Xliff/DbLocalizationProvider.Xliff.csproj b/common/src/DbLocalizationProvider.Xliff/DbLocalizationProvider.Xliff.csproj index 64ab8b7d..11969e9d 100644 --- a/common/src/DbLocalizationProvider.Xliff/DbLocalizationProvider.Xliff.csproj +++ b/common/src/DbLocalizationProvider.Xliff/DbLocalizationProvider.Xliff.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Xliff export/import implementation for DbLocalizationProvider Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks diff --git a/common/src/DbLocalizationProvider/DbLocalizationProvider.csproj b/common/src/DbLocalizationProvider/DbLocalizationProvider.csproj index e09e8d81..74555493 100644 --- a/common/src/DbLocalizationProvider/DbLocalizationProvider.csproj +++ b/common/src/DbLocalizationProvider/DbLocalizationProvider.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable true true - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Database driven localization provider Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider @@ -33,7 +33,7 @@ - + diff --git a/common/src/DbLocalizationProvider/LocalizationProvider.cs b/common/src/DbLocalizationProvider/LocalizationProvider.cs index 6e99c531..e627435c 100644 --- a/common/src/DbLocalizationProvider/LocalizationProvider.cs +++ b/common/src/DbLocalizationProvider/LocalizationProvider.cs @@ -9,12 +9,9 @@ using System.Text.RegularExpressions; using DbLocalizationProvider.Abstractions; using DbLocalizationProvider.Internal; -using DbLocalizationProvider.Json; using DbLocalizationProvider.Queries; using DbLocalizationProvider.Sync; using Microsoft.Extensions.Options; -using Newtonsoft.Json; -using JsonConverter = DbLocalizationProvider.Json.JsonConverter; namespace DbLocalizationProvider; @@ -28,8 +25,7 @@ public partial class LocalizationProvider : ILocalizationProvider private readonly ResourceKeyBuilder _keyBuilder; internal readonly IQueryExecutor _queryExecutor; private readonly ScanState _scanState; - private readonly JsonConverter _converter; - private readonly JsonSerializer _serializer; + private readonly ReflectionConverter _reflectionConverter; /// /// Creates new localization provider with all the required settings and services injected. @@ -55,11 +51,13 @@ public LocalizationProvider( _queryExecutor = queryExecutor; _scanState = scanState; - _converter = new JsonConverter(_queryExecutor, _scanState); - _serializer = new JsonSerializer - { - ContractResolver = new StaticPropertyContractResolver() - }; + // _converter = new JsonConverter(_queryExecutor, _scanState); + // _serializer = new JsonSerializer + // { + // ContractResolver = new StaticPropertyContractResolver() + // }; + + _reflectionConverter = new ReflectionConverter(_queryExecutor, _scanState, _keyBuilder); } /// @@ -221,27 +219,14 @@ public T Translate() } /// - /// Give a type to this method and it will return instance of the type but translated + /// Give a type to this method, and it will return instance of the type but translated /// /// Type of the target class you want to translate /// Language to use during translation /// Translated class public T Translate(CultureInfo language) { - var className = typeof(T).FullName; - - var json = _converter.GetJson(className, language.Name, _fallbackCollection); - - // get the actual class Json representation (we need to select token through FQN of the class) - // to supported nested classes - we need to fix a bit resource key name - var jsonToken = json.SelectToken(className.Replace('+', '.')); - - if (jsonToken == null) - { - return (T)Activator.CreateInstance(typeof(T), new object[] { }); - } - - return jsonToken.ToObject(_serializer); + return _reflectionConverter.Convert(language.Name, _fallbackCollection); } /// diff --git a/common/src/DbLocalizationProvider/ReflectionConverter.cs b/common/src/DbLocalizationProvider/ReflectionConverter.cs new file mode 100644 index 00000000..15865612 --- /dev/null +++ b/common/src/DbLocalizationProvider/ReflectionConverter.cs @@ -0,0 +1,94 @@ +// Copyright (c) Stefan Holm Olsen. All rights reserved. +// Licensed under Apache-2.0. See the LICENSE file in the project root for more information + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using DbLocalizationProvider.Abstractions; +using DbLocalizationProvider.Queries; +using DbLocalizationProvider.Sync; + +namespace DbLocalizationProvider; + +/// +/// Much faster translations to object converter based on reflection +/// +public class ReflectionConverter(IQueryExecutor queryExecutor, ScanState scanState, ResourceKeyBuilder keyBuilder) +{ + /// + /// Creates an object of and fills with translations + /// + /// Specify in which language you are going to use + /// Fallback languages collection + /// Specify target object type + /// If all is good, will return object of type filled with translations of matching keys + public T Convert(string languageName, FallbackLanguagesCollection fallbackCollection) + { + // TODO: Can the dictionary be cached? + // TODO: Can we go around query execution and use repository directly? + var resources = queryExecutor + .Execute(new GetAllResources.Query()) + .ToDictionary(x => x.ResourceKey, StringComparer.Ordinal); + + var newObject = Activator.CreateInstance(); + + FillProperties(newObject!, languageName, resources, fallbackCollection); + + return newObject; + } + + private void FillProperties( + object instance, + string languageName, + Dictionary resources, + FallbackLanguagesCollection fallbackCollection) + { + var type = instance!.GetType(); + var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static); + foreach (var propertyInfo in properties) + { + if (propertyInfo.MemberType == MemberTypes.NestedType) + { + var nestedObject = Activator.CreateInstance(propertyInfo.PropertyType); + if (nestedObject == null) + { + continue; + } + + FillProperties(nestedObject, languageName, resources, fallbackCollection); + + propertyInfo.SetValue(instance, nestedObject); + } + + if (propertyInfo.PropertyType != typeof(string)) + { + continue; + } + + string? translation; + var key = keyBuilder.BuildResourceKey(type, propertyInfo.Name); + if (scanState.UseResourceAttributeCache.TryGetValue(key, out var targetResourceKey) + && resources.TryGetValue(targetResourceKey, out var foundResource)) + { + translation = foundResource.Translations.GetValueWithFallback( + languageName, + fallbackCollection.GetFallbackLanguages(languageName)); + + propertyInfo.SetValue(instance, translation); + continue; + } + + if (!resources.TryGetValue(key, out var resource)) + { + continue; + } + + translation = resource.Translations.GetValueWithFallback( + languageName, + fallbackCollection.GetFallbackLanguages(languageName)); + + propertyInfo.SetValue(instance, translation); + } + } +} diff --git a/optimizely/samples/AlloySampleSite/AlloySampleSite.csproj b/optimizely/samples/AlloySampleSite/AlloySampleSite.csproj index cf21852e..9d9626d6 100644 --- a/optimizely/samples/AlloySampleSite/AlloySampleSite.csproj +++ b/optimizely/samples/AlloySampleSite/AlloySampleSite.csproj @@ -1,20 +1,20 @@  - net8.0 + net9.0 - + - + - - - - - + + + + + diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/CMS/CMS.zip b/optimizely/samples/AlloySampleSite/modules/_protected/CMS/CMS.zip index 8e12fccd..9f3065a3 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/CMS/CMS.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/CMS/CMS.zip differ diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.TinyMce/EPiServer.Cms.TinyMce.zip b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.TinyMce/EPiServer.Cms.TinyMce.zip index 66adc8c1..9494c1d3 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.TinyMce/EPiServer.Cms.TinyMce.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.TinyMce/EPiServer.Cms.TinyMce.zip differ diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Admin/EPiServer.Cms.UI.Admin.zip b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Admin/EPiServer.Cms.UI.Admin.zip index e6a9f4be..d1b23187 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Admin/EPiServer.Cms.UI.Admin.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Admin/EPiServer.Cms.UI.Admin.zip differ diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Settings/EPiServer.Cms.UI.Settings.zip b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Settings/EPiServer.Cms.UI.Settings.zip index e9a240f8..9c52760e 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Settings/EPiServer.Cms.UI.Settings.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.Settings/EPiServer.Cms.UI.Settings.zip differ diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.VisitorGroups/EPiServer.Cms.UI.VisitorGroups.zip b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.VisitorGroups/EPiServer.Cms.UI.VisitorGroups.zip index f576ec27..038195f6 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.VisitorGroups/EPiServer.Cms.UI.VisitorGroups.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/EPiServer.Cms.UI.VisitorGroups/EPiServer.Cms.UI.VisitorGroups.zip differ diff --git a/optimizely/samples/AlloySampleSite/modules/_protected/Shell/Shell.zip b/optimizely/samples/AlloySampleSite/modules/_protected/Shell/Shell.zip index 623212b1..dabf0b61 100644 Binary files a/optimizely/samples/AlloySampleSite/modules/_protected/Shell/Shell.zip and b/optimizely/samples/AlloySampleSite/modules/_protected/Shell/Shell.zip differ diff --git a/optimizely/src/DbLocalizationProvider.AdminUI.EPiServer/DbLocalizationProvider.AdminUI.EPiServer.csproj b/optimizely/src/DbLocalizationProvider.AdminUI.EPiServer/DbLocalizationProvider.AdminUI.EPiServer.csproj index 04e1fcb4..52883cc7 100644 --- a/optimizely/src/DbLocalizationProvider.AdminUI.EPiServer/DbLocalizationProvider.AdminUI.EPiServer.csproj +++ b/optimizely/src/DbLocalizationProvider.AdminUI.EPiServer/DbLocalizationProvider.AdminUI.EPiServer.csproj @@ -1,11 +1,11 @@  - net8.0 + net9.0 enable - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider @@ -39,8 +39,8 @@ - - + + diff --git a/optimizely/src/DbLocalizationProvider.EPiServer/DbLocalizationProvider.EPiServer.csproj b/optimizely/src/DbLocalizationProvider.EPiServer/DbLocalizationProvider.EPiServer.csproj index 74833471..30ed95b5 100644 --- a/optimizely/src/DbLocalizationProvider.EPiServer/DbLocalizationProvider.EPiServer.csproj +++ b/optimizely/src/DbLocalizationProvider.EPiServer/DbLocalizationProvider.EPiServer.csproj @@ -1,11 +1,11 @@  - net8.0 + net9.0 enable - 8.2.3 - 8.2.3 - 8.2.3.0 - 8.2.3.0 + 9.0.0 + 9.0.0 + 9.0.0.0 + 9.0.0.0 Valdis Iljuconoks, https://tech-fellow.eu Valdis Iljuconoks, https://tech-fellow.eu DbLocalizationProvider @@ -34,8 +34,8 @@ - - + + diff --git a/optimizely/tests/DbLocalizationProvider.EPiServer.Tests/DbLocalizationProvider.EPiServer.Tests.csproj b/optimizely/tests/DbLocalizationProvider.EPiServer.Tests/DbLocalizationProvider.EPiServer.Tests.csproj index 0e1f153c..143976ea 100644 --- a/optimizely/tests/DbLocalizationProvider.EPiServer.Tests/DbLocalizationProvider.EPiServer.Tests.csproj +++ b/optimizely/tests/DbLocalizationProvider.EPiServer.Tests/DbLocalizationProvider.EPiServer.Tests.csproj @@ -1,15 +1,15 @@  - net8.0 + net9.0 false true ..\..\..\strongname.snk - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive