Humanizer.PluralizationForms
PluralizationForms Class
Provides authored singular and plural forms of one noun.
public sealed class PluralizationForms
Inheritance System.Object → PluralizationForms
Remarks
Humanizer applies the supported culture's cardinal plural rule to select an authored form. Missing selected forms are not inferred.
Constructors
PluralizationForms(string, string, string, string, string, string, string) Constructor
Creates a set of authored singular and plural forms.
public PluralizationForms(string singular, string other, string? zero=null, string? one=null, string? two=null, string? few=null, string? many=null);
Parameters
singular System.String
The noun's singular form.
other System.String
The form for the CLDR other category.
zero System.String
The form for the CLDR zero category, or null when unavailable.
one System.String
The form for the CLDR one category, or null when unavailable.
two System.String
The form for the CLDR two category, or null when unavailable.
few System.String
The form for the CLDR few category, or null when unavailable.
many System.String
The form for the CLDR many category, or null when unavailable.
Exceptions
System.ArgumentException
singular or other is empty or whitespace, or an optional supplied form is empty or whitespace.
System.ArgumentNullException
singular or other is null.
Properties
PluralizationForms.Few Property
Gets the form for the CLDR few category.
public string? Few { get; }
Property Value
PluralizationForms.Many Property
Gets the form for the CLDR many category.
public string? Many { get; }
Property Value
PluralizationForms.One Property
Gets the form for the CLDR one category.
public string? One { get; }
Property Value
PluralizationForms.Other Property
Gets the form for the CLDR other category.
public string Other { get; }
Property Value
PluralizationForms.Singular Property
Gets the noun's singular form.
public string Singular { get; }
Property Value
PluralizationForms.Two Property
Gets the form for the CLDR two category.
public string? Two { get; }
Property Value
PluralizationForms.Zero Property
Gets the form for the CLDR zero category.
public string? Zero { get; }
Property Value
Methods
PluralizationForms.Invariant(string) Method
Creates forms for a noun that remains unchanged in every cardinal category.
public static Humanizer.PluralizationForms Invariant(string word);
Parameters
word System.String
The invariant word.
Returns
PluralizationForms
A form set containing word for every category.
Exceptions
System.ArgumentException
word is empty or whitespace.
System.ArgumentNullException
word is null.
PluralizationForms.TryPluralize(decimal, CultureInfo, string) Method
Attempts to pluralize this noun for a quantity using the supported culture's cardinal plural rule.
public bool TryPluralize(decimal quantity, System.Globalization.CultureInfo culture, out string? result);
Parameters
quantity System.Decimal
The quantity. Its encoded decimal scale supplies CLDR visible-fraction operands.
culture System.Globalization.CultureInfo
The supported culture whose cardinal plural rule is applied.
result System.String
The selected authored form when available; otherwise, null.
Returns
System.Boolean
true when the selected form is available; otherwise, false.
Exceptions
System.ArgumentNullException
culture is null.
PluralizationForms.TrySingularize(string, string) Method
Attempts to resolve one of this noun's exact authored forms to its singular form.
public bool TrySingularize(string form, out string? result);
Parameters
form System.String
An exact authored form.
result System.String
The singular form when form matches; otherwise, null.
Returns
System.Boolean
true when form matches an authored form; otherwise, false.
Exceptions
System.ArgumentNullException
form is null.
Remarks
Matching is Unicode NFC-normalized, ordinal, and case-sensitive.