Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
kl1mm committed Sep 17, 2024
2 parents f581ff4 + f15c9a7 commit 718aca7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
5 changes: 4 additions & 1 deletion example/kli.Localize.Example/Localizations/Locale.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"MyText": "Hallo Welt (German)"
"MyText": "Hallo Welt (German)",
"Sub": {
"Nested": "Kind (German)"
}
}
5 changes: 4 additions & 1 deletion example/kli.Localize.Example/Localizations/Locale_en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"MyText": "Hello World (English)"
"MyText": "Hello World (English)",
"Sub": {
"Nested": "Child (English)"
}
}
31 changes: 17 additions & 14 deletions example/kli.Localize.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
2 changes: 1 addition & 1 deletion example/kli.Localize.Example/kli.Localize.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="kli.Localize" Version="0.8.3" />
<PackageReference Include="kli.Localize" Version="1.0.4" />

<AdditionalFiles Include="Localizations\Locale.json" ClassName="MyLocale" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/kli.Localize.Generator/kli.Localize.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<ItemGroup>
<!-- Generator dependencies -->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.143">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -35,6 +35,7 @@
<!-- Include in Analyzerpackage -->
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgMicrosoft_CodeAnalysis_CSharp_Workspaces)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<!-- Package the props file -->
<None Include="kli.Localize.props" Pack="true" PackagePath="build" />
</ItemGroup>
Expand All @@ -52,6 +53,7 @@
<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PkgMicrosoft_CodeAnalysis_CSharp_Workspaces)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>

Expand Down

0 comments on commit 718aca7

Please sign in to comment.