From 190835499823b4d974f1c354f1bb95d313365f01 Mon Sep 17 00:00:00 2001
From: pomianowski <13592821+pomianowski@users.noreply.github.com>
Date: Sun, 19 May 2024 22:05:45 +0200
Subject: [PATCH] Fix tests
---
Directory.Packages.props | 1 +
Lepo.i18n.sln | 14 ++-----
.../GlobalUsings.cs | 1 +
.../Lepo.i18n.DependencyInjection.csproj | 2 +
.../ServiceCollectionExtensions.cs | 2 +-
src/Lepo.i18n.Json/Lepo.i18n.Json.csproj | 4 ++
src/Lepo.i18n.Wpf/ApplicationExtensions.cs | 6 +--
src/Lepo.i18n.Wpf/GlobalUsings.cs | 4 ++
src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs | 11 ++++++
src/Lepo.i18n.Wpf/StringLocalizerExtension.cs | 2 -
src/Lepo.i18n.Yaml/GlobalUsings.cs | 9 -----
src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj | 38 -------------------
src/Lepo.i18n/LocalizationProvider.cs | 4 +-
.../Yaml}/StringLocalizerBuilderExtensions.cs | 0
.../Yaml}/YamlDecoder.cs | 0
.../StringLocalizerBuilderExtensionsTests.cs | 2 +-
16 files changed, 32 insertions(+), 68 deletions(-)
create mode 100644 src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs
delete mode 100644 src/Lepo.i18n.Yaml/GlobalUsings.cs
delete mode 100644 src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj
rename src/{Lepo.i18n.Yaml => Lepo.i18n/Yaml}/StringLocalizerBuilderExtensions.cs (100%)
rename src/{Lepo.i18n.Yaml => Lepo.i18n/Yaml}/YamlDecoder.cs (100%)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index ba5d9eb..37ac9b9 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -10,6 +10,7 @@
+
diff --git a/Lepo.i18n.sln b/Lepo.i18n.sln
index 13a8908..01bc3ae 100644
--- a/Lepo.i18n.sln
+++ b/Lepo.i18n.sln
@@ -18,17 +18,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ThirdPartyNotices.txt = ThirdPartyNotices.txt
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.Yaml", "src\Lepo.i18n.Yaml\Lepo.i18n.Yaml.csproj", "{B935AF12-97DD-419E-99C3-8F76D9A0229D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.Json", "src\Lepo.i18n.Json\Lepo.i18n.Json.csproj", "{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.Json", "src\Lepo.i18n.Json\Lepo.i18n.Json.csproj", "{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{AA93DD64-B88F-46ED-9981-EABA0F3C3E95}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.UnitTests", "tests\Lepo.i18n.UnitTests\Lepo.i18n.UnitTests.csproj", "{98789E33-F370-46FF-B4B6-CEAA81E9C2C3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.UnitTests", "tests\Lepo.i18n.UnitTests\Lepo.i18n.UnitTests.csproj", "{98789E33-F370-46FF-B4B6-CEAA81E9C2C3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.DependencyInjection", "src\Lepo.i18n.DependencyInjection\Lepo.i18n.DependencyInjection.csproj", "{6297D5AB-EE2C-4DBB-BE29-B4813BB8803F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.DependencyInjection", "src\Lepo.i18n.DependencyInjection\Lepo.i18n.DependencyInjection.csproj", "{6297D5AB-EE2C-4DBB-BE29-B4813BB8803F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.DependencyInjection.UnitTests", "tests\Lepo.i18n.DependencyInjection.UnitTests\Lepo.i18n.DependencyInjection.UnitTests.csproj", "{274021AA-F5A4-4A02-B8B7-224B254031A1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.DependencyInjection.UnitTests", "tests\Lepo.i18n.DependencyInjection.UnitTests\Lepo.i18n.DependencyInjection.UnitTests.csproj", "{274021AA-F5A4-4A02-B8B7-224B254031A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -44,10 +42,6 @@ Global
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Release|Any CPU.Build.0 = Release|Any CPU
- {B935AF12-97DD-419E-99C3-8F76D9A0229D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B935AF12-97DD-419E-99C3-8F76D9A0229D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B935AF12-97DD-419E-99C3-8F76D9A0229D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B935AF12-97DD-419E-99C3-8F76D9A0229D}.Release|Any CPU.Build.0 = Release|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/src/Lepo.i18n.DependencyInjection/GlobalUsings.cs b/src/Lepo.i18n.DependencyInjection/GlobalUsings.cs
index 5c8b789..232a062 100644
--- a/src/Lepo.i18n.DependencyInjection/GlobalUsings.cs
+++ b/src/Lepo.i18n.DependencyInjection/GlobalUsings.cs
@@ -7,4 +7,5 @@
global using Microsoft.Extensions.Localization;
global using System;
global using System.Collections.Generic;
+global using System.Globalization;
global using System.Linq;
diff --git a/src/Lepo.i18n.DependencyInjection/Lepo.i18n.DependencyInjection.csproj b/src/Lepo.i18n.DependencyInjection/Lepo.i18n.DependencyInjection.csproj
index db0fc21..be79474 100644
--- a/src/Lepo.i18n.DependencyInjection/Lepo.i18n.DependencyInjection.csproj
+++ b/src/Lepo.i18n.DependencyInjection/Lepo.i18n.DependencyInjection.csproj
@@ -30,10 +30,12 @@
System.Runtime.CompilerServices.SkipLocalsInitAttribute;
+
+
diff --git a/src/Lepo.i18n.DependencyInjection/ServiceCollectionExtensions.cs b/src/Lepo.i18n.DependencyInjection/ServiceCollectionExtensions.cs
index 1d5728b..ecc0c63 100644
--- a/src/Lepo.i18n.DependencyInjection/ServiceCollectionExtensions.cs
+++ b/src/Lepo.i18n.DependencyInjection/ServiceCollectionExtensions.cs
@@ -19,7 +19,7 @@ Action configure
configure(builder);
- LocalizationProvider localizer = new(builder.GetLocalizations());
+ LocalizationProvider localizer = new(CultureInfo.CurrentCulture, builder.GetLocalizations());
LocalizationProvider.SetInstance(localizer);
_ = services.AddSingleton(
diff --git a/src/Lepo.i18n.Json/Lepo.i18n.Json.csproj b/src/Lepo.i18n.Json/Lepo.i18n.Json.csproj
index 9c1b27b..a44ebef 100644
--- a/src/Lepo.i18n.Json/Lepo.i18n.Json.csproj
+++ b/src/Lepo.i18n.Json/Lepo.i18n.Json.csproj
@@ -31,6 +31,10 @@
+
+
+
+
diff --git a/src/Lepo.i18n.Wpf/ApplicationExtensions.cs b/src/Lepo.i18n.Wpf/ApplicationExtensions.cs
index 3d8f404..42b9414 100644
--- a/src/Lepo.i18n.Wpf/ApplicationExtensions.cs
+++ b/src/Lepo.i18n.Wpf/ApplicationExtensions.cs
@@ -3,13 +3,11 @@
// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
// All Rights Reserved.
-using System.Windows;
-
namespace Lepo.i18n.Wpf;
public static class ApplicationExtensions
{
- public static Application AddStringLocalizer(
+ public static Application UseStringLocalizer(
this Application app,
Action configure
)
@@ -18,7 +16,7 @@ Action configure
configure(builder);
- LocalizationProvider localizer = new(builder.GetLocalizations());
+ LocalizationProvider localizer = new(CultureInfo.CurrentUICulture, builder.GetLocalizations());
LocalizationProvider.SetInstance(localizer);
return app;
diff --git a/src/Lepo.i18n.Wpf/GlobalUsings.cs b/src/Lepo.i18n.Wpf/GlobalUsings.cs
index b506924..4bdafe1 100644
--- a/src/Lepo.i18n.Wpf/GlobalUsings.cs
+++ b/src/Lepo.i18n.Wpf/GlobalUsings.cs
@@ -4,3 +4,7 @@
// All Rights Reserved.
global using System;
+global using System.Globalization;
+global using System.Runtime.InteropServices;
+global using System.Windows;
+global using System.Windows.Markup;
diff --git a/src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs b/src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..21c5def
--- /dev/null
+++ b/src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs
@@ -0,0 +1,11 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
+// All Rights Reserved.
+
+[assembly: ComVisible(false)]
+[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
+
+[assembly: XmlnsPrefix("http://schemas.lepo.co/i18n/2022/xaml", "i18n")]
+[assembly: XmlnsDefinition("http://schemas.lepo.co/i18n/2022/xaml", "Lepo.i18n")]
+[assembly: XmlnsDefinition("http://schemas.lepo.co/i18n/2022/xaml", "Lepo.i18n.Wpf")]
diff --git a/src/Lepo.i18n.Wpf/StringLocalizerExtension.cs b/src/Lepo.i18n.Wpf/StringLocalizerExtension.cs
index 5ae37f2..979a4bc 100644
--- a/src/Lepo.i18n.Wpf/StringLocalizerExtension.cs
+++ b/src/Lepo.i18n.Wpf/StringLocalizerExtension.cs
@@ -3,8 +3,6 @@
// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
// All Rights Reserved.
-using System.Windows.Markup;
-
namespace Lepo.i18n.Wpf;
///
diff --git a/src/Lepo.i18n.Yaml/GlobalUsings.cs b/src/Lepo.i18n.Yaml/GlobalUsings.cs
deleted file mode 100644
index 83205b3..0000000
--- a/src/Lepo.i18n.Yaml/GlobalUsings.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// This Source Code Form is subject to the terms of the MIT License.
-// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
-// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
-// All Rights Reserved.
-
-global using System;
-global using System.Collections.Generic;
-global using System.Globalization;
-global using System.Text;
diff --git a/src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj b/src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj
deleted file mode 100644
index 34535ab..0000000
--- a/src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
- Lepo.i18n.Yaml
- netstandard2.0;netstandard2.1;net462;net6.0;net8.0
- true
- true
- true
-
-
-
- true
- true
- Speed
-
-
-
-
-
- System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute;
- System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute;
- System.Diagnostics.CodeAnalysis.MemberNotNullAttribute;
- System.Diagnostics.CodeAnalysis.NotNullAttribute;
- System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute;
- System.Diagnostics.CodeAnalysis.NotNullWhenAttribute;
- System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute;
- System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute;
- System.Runtime.CompilerServices.CallerArgumentExpressionAttribute;
- System.Runtime.CompilerServices.IsExternalInit;
- System.Runtime.CompilerServices.SkipLocalsInitAttribute;
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Lepo.i18n/LocalizationProvider.cs b/src/Lepo.i18n/LocalizationProvider.cs
index 4219a53..0dc0e7d 100644
--- a/src/Lepo.i18n/LocalizationProvider.cs
+++ b/src/Lepo.i18n/LocalizationProvider.cs
@@ -5,12 +5,10 @@
namespace Lepo.i18n;
-public class LocalizationProvider(IEnumerable sets) : ILocalizationProvider
+public class LocalizationProvider(CultureInfo culture, IEnumerable sets) : ILocalizationProvider
{
private static LocalizationProvider? instance;
- private static CultureInfo culture = CultureInfo.CurrentCulture;
-
public LocalizationSet? Get(CultureInfo culture)
{
return sets.FirstOrDefault(s => s.Culture.Equals(culture));
diff --git a/src/Lepo.i18n.Yaml/StringLocalizerBuilderExtensions.cs b/src/Lepo.i18n/Yaml/StringLocalizerBuilderExtensions.cs
similarity index 100%
rename from src/Lepo.i18n.Yaml/StringLocalizerBuilderExtensions.cs
rename to src/Lepo.i18n/Yaml/StringLocalizerBuilderExtensions.cs
diff --git a/src/Lepo.i18n.Yaml/YamlDecoder.cs b/src/Lepo.i18n/Yaml/YamlDecoder.cs
similarity index 100%
rename from src/Lepo.i18n.Yaml/YamlDecoder.cs
rename to src/Lepo.i18n/Yaml/YamlDecoder.cs
diff --git a/tests/Lepo.i18n.DependencyInjection.UnitTests/StringLocalizerBuilderExtensionsTests.cs b/tests/Lepo.i18n.DependencyInjection.UnitTests/StringLocalizerBuilderExtensionsTests.cs
index dbff8aa..1f28537 100644
--- a/tests/Lepo.i18n.DependencyInjection.UnitTests/StringLocalizerBuilderExtensionsTests.cs
+++ b/tests/Lepo.i18n.DependencyInjection.UnitTests/StringLocalizerBuilderExtensionsTests.cs
@@ -43,7 +43,7 @@ public void FromResource_ShouldReturnWithoutTranslation_WhenResourceIsEmpty()
_ = services.AddStringLocalizer(b =>
{
- _ = b.FromResource(assembly, "Lepo.i18n.UnitTests.Resources.Test", new("cs-CZ"));
+ _ = b.FromResource(assembly, "Lepo.i18n.DependencyInjection.UnitTests.Resources.Test", new("cs-CZ"));
});
ServiceProvider serviceProvider = services.BuildServiceProvider();