Skip to content

Commit

Permalink
chore: adjust examples project; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
kl1mm committed Sep 17, 2024
1 parent 7f84b5e commit 2f660de
Show file tree
Hide file tree
Showing 5 changed files with 27 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
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 2f660de

Please sign in to comment.