LiteObservableLanguages 1.0.0
dotnet add package LiteObservableLanguages --version 1.0.0
NuGet\Install-Package LiteObservableLanguages -Version 1.0.0
<PackageReference Include="LiteObservableLanguages" Version="1.0.0" />
<PackageVersion Include="LiteObservableLanguages" Version="1.0.0" />
<PackageReference Include="LiteObservableLanguages" />
paket add LiteObservableLanguages --version 1.0.0
#r "nuget: LiteObservableLanguages, 1.0.0"
#:package LiteObservableLanguages@1.0.0
#addin nuget:?package=LiteObservableLanguages&version=1.0.0
#tool nuget:?package=LiteObservableLanguages&version=1.0.0
LiteObservableLanguages
Lightweight I18N and locale support for WPF: culture-aware markup extensions (I18NExtension, I18NBindingExtension), a Locale manager with resource fallback, and source-generated resource keys.
Features
- Locale: Central manager for current UI culture,
ResourceManager, and fallback culture; raisesCultureChangedwhen culture changes; supports fluent configuration (UseResourceManager,UseFallback,UseCulture). - I18NExtension (
{I18N ...}): Markup extension that resolves resource keys to localized strings in XAML; supports static keys ({x:Static m:LangKeys.Key}) and dynamic keys ({Binding SelectedKey}); supports composite strings viaLanguageBindingand nested bindings. - I18NBindingExtension (
{I18NBinding ...}): Returns a binding that updates automatically when the language changes; ideal forSetter.Value,Triggersetters, and other binding-only scenarios. - LocaleExtension: Extension method
"Key".Tr()and"Key".Tr(args)for code-behind or view models. - Source-generated resource keys: Use
[ResourceKeysOf(typeof(Resources))]on a static partial class to generate type-safe key constants (e.g.LangKeys.SomeKey) from your.resxkeys. - ResourceProvider: Abstract provider for custom resource sources; register with
ResourceProvider.Providersfor integration withI18NExtension.
Installation
dotnet add package LiteObservableLanguages
Demos (WpfApp)
The WpfApp project demonstrates the following.
1. Language switcher and Locale
ViewModel exposes Culture and AvailableCultures; setting Culture updates I18NExtension.Culture so all I18N bindings refresh.
public CultureInfo Culture
{
get;
set
{
if (field.EnglishName.Equals(value.EnglishName)) return;
field = value;
I18NExtension.Culture = value;
OnPropertyChanged();
}
} = new("zh");
2. I18N with static key
<TextBlock Text="{I18N {x:Static m:LangKeys.Select_your_text_to_translate}}" />
3. I18N with dynamic key (binding)
Key can come from a binding (e.g. selected item or user input):
<TextBox Text="{I18N {Binding SelectedKey}}" />
<TextBlock Text="{I18N {Binding InputText}}" />
4. Composite string with LanguageBinding
Use I18N with a template that mixes literal placeholders and LanguageBinding/Binding for dynamic parts:
<TextBlock.Text>
<I18N Key="{x:Static m:LangKeys.Current_language_is}">
<LanguageBinding Key="{x:Static m:LangKeys.Language}" />
<Binding Path="Culture.EnglishName" />
</I18N>
</TextBlock.Text>
5. I18NBinding in styles and triggers
Use I18NBinding where only a binding is allowed (e.g. Setter.Value):
<Setter Property="Content" Value="{I18NBinding {x:Static m:LangKeys.Off}}" />
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="{I18NBinding {x:Static m:LangKeys.On}}" />
</Trigger>
6. Source-generated keys
Define a static partial class and point it at your default resource class; the source generator emits key constants:
[ResourceKeysOf(typeof(Resources))]
public static partial class LangKeys;
Then use LangKeys.SomeKey in XAML or code.
Run WpfApp and switch languages from the list; all text bound with I18N / I18NBinding updates without restart.
Attribution
This project is a fork of Antelcat/I18N — reactive language support for WPF/Avalonia applications when using .resx files.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0-windows7.0 is compatible. net6.0-windows was computed. net7.0-windows was computed. net8.0-windows was computed. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.0
- No dependencies.
-
net5.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 143 | 3/17/2026 |
| 1.0.0-beta1 | 125 | 3/17/2026 |