Plumix.Slang 0.1.0-alpha.13

This is a prerelease version of Plumix.Slang.
dotnet add package Plumix.Slang --version 0.1.0-alpha.13
                    
NuGet\Install-Package Plumix.Slang -Version 0.1.0-alpha.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plumix.Slang" Version="0.1.0-alpha.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plumix.Slang" Version="0.1.0-alpha.13" />
                    
Directory.Packages.props
<PackageReference Include="Plumix.Slang" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plumix.Slang --version 0.1.0-alpha.13
                    
#r "nuget: Plumix.Slang, 0.1.0-alpha.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plumix.Slang@0.1.0-alpha.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plumix.Slang&version=0.1.0-alpha.13&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Plumix.Slang&version=0.1.0-alpha.13&prerelease
                    
Install as a Cake Tool

Plumix.Slang

NuGet

Context-based translations for Plumix — a port of Flutter's slang_flutter widget layer on top of Slang.Net.

Slang.Net generates a static translations class, so reading Strings.Instance.Root inside Build gives you the strings of whatever culture was active at that moment — and nothing repaints when the culture changes later. TranslationProvider puts the active translations into the widget tree, so a locale switch rebuilds every widget that read them.

Installation

dotnet add package Plumix.Slang

Core API

Plumix.Slang Flutter equivalent Description
ITranslations<TSelf> generated AppLocaleUtils glue Bridge to the Slang.Net generated class
TranslationProvider<T> TranslationProvider Publishes translations, rebuilds the subtree on switch
Translations<T>.Of(context) Translations.of(context) Reads translations and subscribes to switches
Translations<T>.ReadOf(context) Reads without subscribing (event handlers)
LocaleSettings<T> LocaleSettings SetLocale, SetLocaleRaw, UseDeviceLocale, CurrentCulture
context.Translations<T>() context.t Shorthand for Translations<T>.Of(context)

Usage

1. Implement the bridge on the generated class

Slang.Net emits its API as static members, so the contract uses static abstract members — no reflection, trimming/AOT safe. Only two members need glue; the rest are already generated with matching signatures:

using System.ComponentModel;
using Plumix.Slang;
using Slang;

[Translations(InputFileName = "strings")]
public partial class Strings : ITranslations<Strings>
{
    static Strings ITranslations<Strings>.CurrentTranslations => Instance.Root;
    static INotifyPropertyChanged ITranslations<Strings>.ChangeSource => Instance;
}

2. Wrap the app

new TranslationProvider<Strings>(
    child: new MyApp())

3. Read translations through the context

public override Widget Build(BuildContext context)
{
    var t = Translations<Strings>.Of(context);   // or context.Translations<Strings>()

    return new Text(t.App.Title);
}

Widgets that keep reading Strings.Instance.Root still work — they just will not repaint on a switch. Anything that should follow the locale has to go through the context.

4. Switch the locale

LocaleSettings<Strings>.SetLocale(new CultureInfo("en-US"));
LocaleSettings<Strings>.SetLocaleRaw("ru");
LocaleSettings<Strings>.UseDeviceLocale();

Unsupported cultures fall back the same way the generated Instance.Root does: exact name, then any culture with the same language, then BaseCulture. LocaleSettings<T>.Resolve exposes that mapping, IsSupported checks for an exact match.

By default only CultureInfo.CurrentUICulture moves, so number and date formatting keeps following the system — pass uiOnly: false to switch CultureInfo.CurrentCulture as well.

Call these from the UI thread: the rebuild they trigger runs synchronously on the caller.

See also

  • Plumix — the core framework
  • Slang.Net — the translations source generator
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

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
0.1.0-alpha.13 78 8/1/2026