Humanizr/Humanizer · error · ArgumentOutOfRangeException
Unknown ordinalizer profile.
Error message
Unknown ordinalizer profile.
What it means
This message is emitted into generated source code (OrdinalizerProfileCatalog.g.cs) as the default case of the Resolve switch. At runtime, OrdinalizerProfileCatalog.Resolve(kind, culture) throws ArgumentOutOfRangeException when the kind string does not match any compiled ordinalizer profile name. The catalog only contains profiles from locales whose ordinalizer feature was registered with UsesGeneratedProfile: true.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/OrdinalizerProfileCatalogInput.cs:78
builder.AppendLine("{");
builder.AppendLine(" public static IOrdinalizer Resolve(string kind, CultureInfo culture)");
builder.AppendLine(" {");
builder.AppendLine(" switch (kind)");
builder.AppendLine(" {");
foreach (var profile in generatedProfiles)
{
builder.Append(" case ");
builder.Append(QuoteLiteral(profile.ProfileName));
builder.Append(": return ");
builder.Append(RequiresCulture(profile)
? CreateOrdinalizerExpression(profile, useCultureParameter: true)
: GetCatalogPropertyName(profile.ProfileName));
builder.AppendLine(";");
}
builder.AppendLine(" }");
builder.AppendLine(" throw new ArgumentOutOfRangeException(nameof(kind), kind, \"Unknown ordinalizer profile.\");");
builder.AppendLine(" }");
builder.AppendLine();
foreach (var profile in generatedProfiles)
{
if (RequiresCulture(profile))
{
continue;
}
AppendLazyCachedMember(
builder,
" ",
"static",
"IOrdinalizer",
GetCatalogPropertyName(profile.ProfileName),
CreateOrdinalizerExpression(profile, useCultureParameter: false));
builder.AppendLine();View on GitHub (pinned to ffc2b77c0f)
Solutions
- Verify the target locale has an ordinalizer YAML block with a matching profile name under src/Humanizer/Locales.
- Ensure the ordinalizer feature is registered with UsesGeneratedProfile: true.
- Fall back to a known-supported locale (e.g. 'en') for ordinalization if the requested locale is unsupported.
- Confirm the culture name casing and hyphenation exactly match the compiled profile name.
Example fix
// before — 'xx' has no ordinalizer profile
var ordinal = 1.ToOrdinalWords("xx");
// after — use a supported locale
var ordinal = 1.ToOrdinalWords("en"); Defensive patterns
Strategy: validation
Validate before calling
// Before calling an ordinalizer API with an arbitrary locale, verify support.
var culture = new CultureInfo("en");
// Use public APIs which fall back gracefully; guard if calling the internal catalog. Try / catch
try
{
var ordinalizer = OrdinalizerProfileCatalog.Resolve(kind, culture);
}
catch (ArgumentOutOfRangeException)
{
ordinalizer = OrdinalizerProfileCatalog.Resolve("en", culture);
} Prevention
- Use the public Ordinalize/ToOrdinalWords extension methods rather than internal catalogs.
- Verify the target culture is shipped with an ordinalizer block.
- Test ordinalization for each locale your application supports.
When it happens
Trigger: Calling an ordinalizer API (e.g. number.ToOrdinalWords() or the Ordinalize extension) with a culture whose ordinalizer profile name is not in the compiled catalog. This happens when the locale is missing, the profile name doesn't match, or the feature wasn't registered as generated.
Common situations: A consumer upgrades Humanizer and a locale name changed. A consumer passes a custom culture string that doesn't correspond to any shipped ordinalizer profile.
Related errors
- Unknown number-to-words profile.
- Unknown ordinal date profile.
- Unknown clock-notation profile.
- Unknown words-to-number profile.
- Specified argument was out of the range of valid values. (Pa
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/2e1b9135ddc913be.
Report an issue: GitHub.