Overview
Codebelt.Extensions.Globalization extends System.Globalization with one focused capability: enrich a CultureInfo instance with embedded Windows National Language Support data. The package rewrites the writable members on DateTimeFormat and NumberFormat so formatting behavior matches the Windows variant instead of the ICU data that modern .NET runtimes commonly expose.
The package is intentionally narrow. It does not introduce a new culture model or formatting pipeline; it lets you keep working with CultureInfo while opting into repository-shipped surrogate data for the locales it embeds.
Key APIs
CultureInfoExtensions.UseNationalLanguageSupport(this CultureInfo culture) enriches a single culture and returns the enriched instance. When the input culture is read-only, the method clones it before applying the surrogate values; when the input is writable, the method updates that instance in place.
CultureInfoExtensions.UseNationalLanguageSupport(this IEnumerable<CultureInfo> cultures) batch-enriches a sequence of cultures with the same surrogate lookup logic. The implementation caches enriched cultures by name and throws InvalidOperationException when no embedded surrogate exists for a requested locale instead of silently falling back.
Basic usage
using System;
using System.Globalization;
using Codebelt.Extensions.Globalization;
using Codebelt.Extensions.Xunit;
using Xunit;
namespace MyProject.Tests;
public class ReleaseDateFormattingTests : Test
{
public ReleaseDateFormattingTests(ITestOutputHelper output) : base(output)
{
}
[Fact]
public void UseNationalLanguageSupport_ShouldApplyWindowsDateFormatting()
{
var releaseDate = new DateTime(2026, 3, 5);
var icuCulture = new CultureInfo("da-DK", false);
var nlsCulture = CultureInfo.GetCultureInfo("da-DK").UseNationalLanguageSupport();
var icuFormatted = releaseDate.ToString("d", icuCulture);
var nlsFormatted = releaseDate.ToString("d", nlsCulture);
TestOutput.WriteLine($"ICU: {icuFormatted}");
TestOutput.WriteLine($"NLS: {nlsFormatted}");
Assert.NotEqual(icuFormatted, nlsFormatted);
Assert.Equal("05-03-2026", nlsFormatted);
}
}
Use this pattern when an application needs framework CultureInfo APIs but must reproduce Windows-specific formatting across runtimes. It matters because the package keeps the calling code centered on CultureInfo while making the formatting data explicit and testable.
Installation
dotnet add package Codebelt.Extensions.Globalization
Usage guidance
Use this package when the distinction between ICU and Windows NLS data is part of the requirement, such as matching existing Windows-produced dates, calendar rules, or number symbols across platforms. If the platform-default CultureInfo values are already acceptable, or you only need a few custom format strings, stay with the framework APIs and avoid introducing surrogate-based culture enrichment.