Locan 1.0.6

dotnet add package Locan --version 1.0.6
                    
NuGet\Install-Package Locan -Version 1.0.6
                    
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="Locan" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Locan" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Locan" />
                    
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 Locan --version 1.0.6
                    
#r "nuget: Locan, 1.0.6"
                    
#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 Locan@1.0.6
                    
#: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=Locan&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Locan&version=1.0.6
                    
Install as a Cake Tool

Locan

NuGet

Locan is a strongly typed localization library for .NET. It keeps translations in JSON, generates message classes at compile time, and renders them using the current UI culture.

Why Locan

  • Message keys become discoverable C# types instead of string literals.
  • Placeholder names, types, and formats are captured by the source generator.
  • Culture-aware formatting uses standard .NET format strings.
  • Runtime resources support parent-culture fallback such as ru-RU to ru.
  • Hosting and ASP.NET Core integrations load resources and select the request culture.

Installation

For an ASP.NET Core application with generated messages:

dotnet add package Locan.AspNetCore
dotnet add package Locan.Generator

Two-minute example

Declare the default culture and localization resources in the project file:

<PropertyGroup>
  <LocanDefaultCulture>en</LocanDefaultCulture>
</PropertyGroup>

<ItemGroup>
  <LocanResource Include="Localization/**/*.json"
                 GenerateMessages="true"
                 CopyToOutput="true" />
</ItemGroup>

Declare the namespace for generated message classes:

using Locan.Core.Attributes;

[assembly: LocalizationModule("MyApplication.Messages")]

Create Localization/localization-en.json:

{
  "culture": "en",
  "messages": {
    "article.not.found": "Article not found.",
    "article.price.updated": "Price updated to {Price|Decimal|F2}."
  }
}

The generator turns article.price.updated into a class with a typed factory:

using Locan.Core.LocalizableMessages;

public partial class ArticlePriceUpdatedMessage : LocalizableMessage
{
    public const string Key = "article.price.updated";

    public ArticlePriceUpdatedMessage() : base(Key, 1) { }

    public static ArticlePriceUpdatedMessage Create(decimal Price)
    {
        var message = new ArticlePriceUpdatedMessage();
        message.WithValue("Price", Price, "F2");
        return message;
    }

    public ArticlePriceUpdatedMessage WithPrice(decimal value)
    {
        WithValue("Price", value, "F2");
        return this;
    }
}

Use the generated class through Locan's contextual localizer:

using Locan.AspNetCore;
using Locan.Core.Interfaces.Localizers;
using MyApplication.Messages;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocanAspNetCore(options =>
{
    options.DefaultCulture = "en";
    options.SupportedCultures = ["en", "ru"];
});

var app = builder.Build();
app.UseLocanRequestLocalization();

app.MapGet("/price", (IContextualLocalizer localizer) =>
    localizer.Get(ArticlePriceUpdatedMessage.Create(12.5m)));

app.Run();

For the English request culture, the result is Price updated to 12.50.. Resources with CopyToOutput="true" are copied to the application's Locan output directory automatically.

Packages

  • Locan.Core — shared contracts, models, and template parsing primitives.
  • Locan — resource loading, culture lookup, and message rendering.
  • Locan.Hosting — dependency injection and hosted initialization.
  • Locan.AspNetCore — request-culture integration for ASP.NET Core.
  • Locan.Generator — build integration and the strongly typed source generator.

Documentation

License

Locan is licensed under the MIT License.

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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Locan:

Package Downloads
Locan.Hosting

Microsoft.Extensions.Hosting integration for Locan localization.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 254 9/13/2026
1.0.5 109 9/12/2026
1.0.4 108 9/12/2026
1.0.2 109 9/12/2026
1.0.1 94 9/12/2026
1.0.0 102 9/12/2026