From 2f660de14be4b8725a898b6294b2cbb9e4f972ad Mon Sep 17 00:00:00 2001 From: Tobi Kli Date: Tue, 17 Sep 2024 11:16:41 +0200 Subject: [PATCH 1/2] chore: adjust examples project; bump version --- .../Localizations/Locale.json | 5 ++- .../Localizations/Locale_en.json | 5 ++- example/kli.Localize.Example/Program.cs | 31 ++++++++++--------- .../kli.Localize.Example.csproj | 2 +- version.json | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/example/kli.Localize.Example/Localizations/Locale.json b/example/kli.Localize.Example/Localizations/Locale.json index f538858..0a7b614 100644 --- a/example/kli.Localize.Example/Localizations/Locale.json +++ b/example/kli.Localize.Example/Localizations/Locale.json @@ -1,3 +1,6 @@ { - "MyText": "Hallo Welt (German)" + "MyText": "Hallo Welt (German)", + "Sub": { + "Nested": "Kind (German)" + } } \ No newline at end of file diff --git a/example/kli.Localize.Example/Localizations/Locale_en.json b/example/kli.Localize.Example/Localizations/Locale_en.json index a41e0e9..5932cdf 100644 --- a/example/kli.Localize.Example/Localizations/Locale_en.json +++ b/example/kli.Localize.Example/Localizations/Locale_en.json @@ -1,3 +1,6 @@ { - "MyText": "Hello World (English)" + "MyText": "Hello World (English)", + "Sub": { + "Nested": "Child (English)" + } } \ No newline at end of file diff --git a/example/kli.Localize.Example/Program.cs b/example/kli.Localize.Example/Program.cs index cbe3e7d..5fd44f4 100644 --- a/example/kli.Localize.Example/Program.cs +++ b/example/kli.Localize.Example/Program.cs @@ -1,23 +1,26 @@ using System; using System.Globalization; -namespace kli.Localize.Example +namespace kli.Localize.Example; + +class Program { - class Program + static void Main(string[] args) { - static void Main(string[] args) - { - // Neutral/Invariant - Console.WriteLine(Localizations.MyLocale.MyText); // Hallo Welt (German) + // Neutral/Invariant + Console.WriteLine(Localizations.MyLocale.MyText); // Hallo Welt (German) + Console.WriteLine(Localizations.MyLocale.Sub.Nested); // Kind (German) - CultureInfo.CurrentUICulture = new CultureInfo("en"); - Console.WriteLine(Localizations.MyLocale.MyText); // Hello World (English) + CultureInfo.CurrentUICulture = new CultureInfo("en"); + Console.WriteLine(Localizations.MyLocale.MyText); // Hello World (English) + Console.WriteLine(Localizations.MyLocale.Sub.Nested); // Child (English) - CultureInfo.CurrentUICulture = new CultureInfo("en-US"); - Console.WriteLine(Localizations.MyLocale.MyText); // Hello World (English) -- Fallback to Parent.Culture + CultureInfo.CurrentUICulture = new CultureInfo("en-US"); + Console.WriteLine(Localizations.MyLocale.MyText); // Hello World (English) -- Fallback to Parent.Culture + Console.WriteLine(Localizations.MyLocale.Sub.Nested); // Child (English) -- Fallback to Parent.Culture - CultureInfo.CurrentUICulture = new CultureInfo("fr"); - Console.WriteLine(Localizations.MyLocale.MyText); // Hallo Welt (German) -- Fallback to Neutral - } + CultureInfo.CurrentUICulture = new CultureInfo("fr"); + Console.WriteLine(Localizations.MyLocale.MyText); // Hallo Welt (German) -- Fallback to Neutral + Console.WriteLine(Localizations.MyLocale.Sub.Nested); // Kind (German) -- Fallback to Neutral } -} +} \ No newline at end of file diff --git a/example/kli.Localize.Example/kli.Localize.Example.csproj b/example/kli.Localize.Example/kli.Localize.Example.csproj index 55fd7ef..2830951 100644 --- a/example/kli.Localize.Example/kli.Localize.Example.csproj +++ b/example/kli.Localize.Example/kli.Localize.Example.csproj @@ -6,7 +6,7 @@ - + diff --git a/version.json b/version.json index 0acc711..acb928e 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0", + "version": "1.1", "cloudBuild": { "buildNumber": { "enabled": true, From f15c9a750fe1c23898e851302bdec3d24defb708 Mon Sep 17 00:00:00 2001 From: Tobi Kli Date: Tue, 17 Sep 2024 15:08:16 +0200 Subject: [PATCH 2/2] fix: Add Microsoft.CodeAnalysis.CSharp.Workspaces into GeneratorPackage to be independent of host framework version --- src/kli.Localize.Generator/kli.Localize.Generator.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/kli.Localize.Generator/kli.Localize.Generator.csproj b/src/kli.Localize.Generator/kli.Localize.Generator.csproj index 731da86..58706a1 100644 --- a/src/kli.Localize.Generator/kli.Localize.Generator.csproj +++ b/src/kli.Localize.Generator/kli.Localize.Generator.csproj @@ -26,7 +26,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -35,6 +35,7 @@ + @@ -52,6 +53,7 @@ +