PH.Babel2.Simple 1.0.0

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

PH.Babel2.Simple

PH.Babel2.Simple is a lightweight JSON-backed translation wrapper for applications that need direct string lookup without the full PH.Babel2 resource model.

Features

  • Thread-safe in-memory translations with ConcurrentDictionary
  • Lazy creation of missing keys and language entries
  • Singleton-friendly registration through AddBabelSimple
  • JSON persistence on Dispose()

JSON format

{
  "Hello": {
    "en": "Hello",
    "it": "Ciao"
  },
  "Welcome {0}": {
    "en": "Welcome {0}",
    "it": "Benvenuto {0}"
  }
}

Direct usage

using PH.Babel2.Simple;

using var translator = new Translator("translations.json");

var italian = translator.Get("Hello", "it");
var welcome = translator.Get("Welcome {0}", "en", "John");

ASP.NET dependency injection

using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddBabelSimple("translations.json");

Behavior notes

Note about key-as-fallback string

The key used to retrieve a message is also the fallback string — the text in the application's primary language. If a key is missing from the JSON file, the Translator automatically inserts it and uses the key text as the default translation for the primary language. This simplifies source usage: you can use the message text itself as the localization key (for example "Welcome {0}"), so if a translation for the requested culture is missing the original message will still be shown.

Examples

JSON (after a missing key is auto-added):

{
  "Welcome {0}": {
    "en": "Welcome {0}",
    "it": "_"
  }
}

C# usage:

using var translator = new Translator("translations.json");

// Key is the message itself; missing entries are handled automatically
var msgEn = translator.Get("Welcome {0}", "en", "John");    // "Welcome John"
var msgIt = translator.Get("Welcome {0}", "it", "Giovanni"); // formats fallback -> "Welcome Giovanni" if 'it' is '_'
  • Missing keys are added automatically.
  • Missing language values are stored with the _ placeholder.
  • When a value is _, the original input text is formatted and returned.
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

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 124 6/24/2026