VOOZH about

URL: https://www.nuget.org/packages/JTigerNova.jtiger.lang/

⇱ NuGet Gallery | JTigerNova.jtiger.lang 1.0.3




JTigerNova.jtiger.lang 1.0.3

dotnet add package JTigerNova.jtiger.lang --version 1.0.3
 
 
NuGet\Install-Package JTigerNova.jtiger.lang -Version 1.0.3
 
 
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="JTigerNova.jtiger.lang" Version="1.0.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JTigerNova.jtiger.lang" Version="1.0.3" />
 
Directory.Packages.props
<PackageReference Include="JTigerNova.jtiger.lang" />
 
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 JTigerNova.jtiger.lang --version 1.0.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JTigerNova.jtiger.lang, 1.0.3"
 
 
#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 JTigerNova.jtiger.lang@1.0.3
 
 
#: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=JTigerNova.jtiger.lang&version=1.0.3
 
Install as a Cake Addin
#tool nuget:?package=JTigerNova.jtiger.lang&version=1.0.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

jtiger.lang

.NET Standard 2.0 library for looking up localized user-facing messages from a caller-supplied translation table.

Stateless. No I/O, no globals, no DI. The caller owns the message table; this library just resolves a key against it with a sensible fallback chain.

API

public static class Lang
{
 public static string Get(
 IReadOnlyDictionary<string, IReadOnlyDictionary<string, string>> msgs,
 string key,
 string locale = null,
 Action<string> onMissingKey = null,
 Action<string> onMissingFallback = null);
}

locale is optional. When omitted (or null/empty), the resolver skips the locale-specific lookups and falls straight through to English.

Message table shape

A two-level dictionary: key → locale → message.

var msgs = new Dictionary<string, IReadOnlyDictionary<string, string>>
{
 ["greeting.hello"] = new Dictionary<string, string>
 {
 ["en"] = "Hello",
 ["es"] = "Hola",
 ["es-MX"] = "¿Qué onda?",
 ["fr"] = "Bonjour",
 },
 ["greeting.bye"] = new Dictionary<string, string>
 {
 ["en"] = "Bye",
 // no es entry — falls back to English
 },
};

Fallback chain

For each Get(msgs, key, locale) call, the resolver tries in order:

  1. Exact locale match.
  2. Language-only fallback - strips the first dash ("es-ES""es").
  3. English - byLocale["en"].
  4. The raw key - returned verbatim if nothing else matched.

Multi-segment tags like "zh-Hans-CN" only fall back one level (to "zh-Hans"), not two ("zh").

The locale string must be in BCP-47 dash form. Underscored variants like "es_ES" are not parsed and only match if the table registered that exact spelling.

Examples

Lang.Get(msgs, "greeting.hello", "es-MX"); // "¿Qué onda?"
Lang.Get(msgs, "greeting.hello", "es-AR"); // "Hola" (language fallback)
Lang.Get(msgs, "greeting.hello", "de"); // "Hello" (English fallback)
Lang.Get(msgs, "greeting.bye", "es"); // "Bye" (no es entry; falls back to en)
Lang.Get(msgs, "greeting.unknown", "en"); // "greeting.unknown" (raw key)
Lang.Get(msgs, "greeting.hello"); // "Hello" (locale omitted → English)

Missing-key callbacks

Two optional Action<string> callbacks signal the two ways a lookup can fail to find a real translation:

  • onMissingKey - fires when key is not in msgs at all. The caller probably forgot to register a message for a key the code path is using.
  • onMissingFallback - fires when key IS in msgs but its inner dictionary has no English entry, so even the safety-net path returned the raw key. The caller probably needs to add an English value as a baseline.
Lang.Get(
 msgs, "greeting.unknown", "en",
 onMissingKey: k => log.Warn($"unwired translation key: {k}"),
 onMissingFallback: k => log.Warn($"key {k} has no English fallback"));

Either callback is invoked at most once per Get call. Exceptions thrown inside a callback are swallowed so a misbehaving logger cannot break the lookup.

Exceptions

When What
msgs is null ArgumentNullException
key is null ArgumentNullException
Anything else (missing key, missing locale, callback throws) Returns the raw key and continues

Threading

Lang.Get is pure with respect to its arguments. Concurrent calls are safe as long as the msgs dictionary you pass in is not being mutated concurrently - which is the same constraint IReadOnlyDictionary<,> already implies.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 is compatible.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on JTigerNova.jtiger.lang:

Package Downloads
JTigerNova.Web.Lib.Service.JTigerNova

Library of standard web service functions and support

JTigerNova.Web.Lib.Website.JTigerNova

Standard website operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 242 5/28/2026
1.0.2 115 5/20/2026
1.0.1 104 5/4/2026
1.0.0 96 5/4/2026

v1.0.3:
- Lang.LocaleText: builds a per-key locale-text entry from (locale, text) tuples

v1.0.2:
- Lang.Get: stateless message lookup with fallback chain
 - exact locale -> language-only (e.g. "es-ES" -> "es") -> English -> raw key
 - optional locale parameter; omitting falls straight through to English
 - optional onMissingKey callback for unwired keys
 - optional onMissingFallback callback for keys with no English entry
 - callback exceptions are swallowed so a faulty logger cannot break a lookup