Skip to main content
Version: 4.0 (next)

Choose explicit and ambient cultures

Orientation

Pass a CultureInfo directly when an overload accepts one. It makes the language choice visible, keeps concurrent requests isolated, and is easy to test. Set CurrentCulture and CurrentUICulture together at a request, message, or job boundary for APIs that use ambient culture.

Culture names are .NET culture identifiers. A specific culture such as fr-FR can fall back through its .NET parent chain to neutral fr locale data. Humanizer then uses the registry default only if no registered parent matches.

Example

using System.Globalization;
using Humanizer;

var french = CultureInfo.GetCultureInfo("fr-FR");

Console.WriteLine(42.ToWords(french));
Console.WriteLine(DateTime.UtcNow.AddDays(-1).Humanize(culture: french));
Console.WriteLine(new[] { "un", "deux", "trois" }.Humanize(french));

CultureInfo.CurrentCulture = french;
CultureInfo.CurrentUICulture = french;
Console.WriteLine(42.ToWords());

The first three calls are explicit. The final call uses the ambient culture.

For application code, establish ambient culture once at the request, message, or background-job boundary. Keep using explicit overloads inside shared services where possible; this prevents one concurrent operation from changing another operation's output.

Pitfall

CurrentCulture and CurrentUICulture serve different .NET concerns. Humanizer's ambient localizer registries, including collection formatting, follow CurrentCulture; application resources can follow CurrentUICulture. Setting only one can produce mixed-language output. Also avoid changing ambient culture in a shared request path when an explicit overload exists.

Parent fallback is resolution, not parity proof. If fr-CA reaches fr, that only identifies where the data came from. It does not establish that French Canadian wording matches every neutral-French choice.

In Humanizer 4, use Configurator.IsCultureSupported(culture) before choosing an application fallback. It checks generated Humanizer locale data through the named parent chain and does not return true merely because the default English localizers could produce output:

var requested = CultureInfo.GetCultureInfo("fr-FR");
var culture = Configurator.IsCultureSupported(requested)
? requested
: CultureInfo.GetCultureInfo("en");

If inherited or direct output is wrong, follow the language correction guide or open a prefilled locale issue.

Version notes

Explicit and ambient CultureInfo selection applies across the supported documentation corpus. Humanizer 4 ships generated locale data and Configurator.IsCultureSupported in the consolidated Humanizer NuGet package. Releases through 3.0.10 use the metapackage and locale-package graph documented in their snapshot.