TekDeq.Localization.Core
0.1.0.11
See the version list below for details.
dotnet add package TekDeq.Localization.Core --version 0.1.0.11
NuGet\Install-Package TekDeq.Localization.Core -Version 0.1.0.11
<PackageReference Include="TekDeq.Localization.Core" Version="0.1.0.11" />
paket add TekDeq.Localization.Core --version 0.1.0.11
#r "nuget: TekDeq.Localization.Core, 0.1.0.11"
// Install TekDeq.Localization.Core as a Cake Addin #addin nuget:?package=TekDeq.Localization.Core&version=0.1.0.11 // Install TekDeq.Localization.Core as a Cake Tool #tool nuget:?package=TekDeq.Localization.Core&version=0.1.0.11
TekDeq.Localization
Yet another localization library with its own abstractions gives the possibility to create localization infrastructure with examples. It contains basic Json Localization Provider implementation (other types will be added in the future).
Library
Installation
Before using the library, install following Nuget packages:
The core library contains required abstractions. <br />
Install-Package TekDeq.Localization.Core
Microsoft dependency injection extensions. <br />
Install-Package TekDeq.Localization.DependencyInjection
<br /> Localization provider and extensions for Avalonia (now it supports Json dictionaries only).
Install-Package TekDeq.Localization.Avalonia
Using the library
To create additional Localization Providers, please look at ILocalizationProvider and LocalizationProviderBase abstractions. As an example of usage please look at JsonLocalizationProvider and AvaloniaJsonLocalizationProvider implementation. If you are using dependency injection in your project, an example of the usage could be found in App.axaml.cs of the demo project.
public override void OnFrameworkInitializationCompleted()
{
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.UseMicrosoftDependencyResolver();
// Initialize Splat
var resolver = Locator.CurrentMutable;
resolver.InitializeSplat();
resolver.InitializeReactiveUI();
// Register Views and ViewModels
services.AddTransient<MainWindow>();
services.AddTransient<MainWindowViewModel>();
// Register Localization
services.AddLocalization<AvaloniaJsonLocalizationProvider>(() =>
{
var options = new AvaloniaLocalizationOptions(
// cultures support localization
new List<CultureInfo>
{
new("en-US"),
new("uk-UA")
},
// defaultCulture, it uses for setting if currentCulture is not in cultures list
// and as fallback culture mor missing localization entries.
new CultureInfo("en-US"),
// currentCulture sets when infrastructure loads,
// could be received from app settings or so.
Thread.CurrentThread.CurrentCulture,
// path to assets with json files of localization.
$"{typeof(App).Namespace}/Assets/i18n");
return options;
});
}).Build();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = host.Services.GetRequiredService<MainWindowViewModel>()
};
}
base.OnFrameworkInitializationCompleted();
}
For start using the markup localization in Avalonia by Localize markup extension, it needs the namespace to be added to the markup.
<Window xmlns="https://github.com/avaloniaui"
...
xmlns:i18n="clr-namespace:TekDeq.Localization.Avalonia.Extensions;assembly=TekDeq.Localization.Avalonia"
...
>
After this it could be used for localization of UI
<StackPanel
...
<TextBlock Text="{i18n:Localize Greeting}" />
...
</StackPanel>
AvaloniaUI demo project
The DEMO project included to the repository, just open and run it in Visual Studio.
License
This project is licensed under the terms of the MIT license.
Contribute
Contributions are welcome. Just open an Issue or submit a new PR.
Contact
You can reach me via my email.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 7.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on TekDeq.Localization.Core:
Package | Downloads |
---|---|
TekDeq.Localization.DependencyInjection
Localization Dependecy Injection Extensions library |
|
TekDeq.Localization.Avalonia
Avalonia Localization library |
GitHub repositories
This package is not used by any popular GitHub repositories.