Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities
Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities
Humanizer is a .NET library for turning strings, enums, dates, times, durations, numbers, quantities, and collections into human-friendly text.
dotnet add package HumanizerSelect your Humanizer version in the documentation site for version-correct package, framework, and API guidance.
…In v4 previews, applications can provide the exact noun forms for a culture's CLDR cardinal categories:
var files = new PluralizationForms(
singular: "plik",
other: "pliku",
few: "pliki",
many: "plików");
if (files.TryPluralize(5m, CultureInfo.GetCultureInfo("pl"), out var noun))
Console.WriteLine(noun); // plikówTryPluralize uses the required cardinal rule for every supported culture and
returns false when the selected form was not supplied. TrySingularize
resolves any exact form in the same set. See
inflection and quantities
for examples.
HumanizeWithCase returns only the duration phrase; add any required
preposition yourself. Singular forms may include a locale-authored one-word
or article, and a locale may encode a count in the unit form. Locales and custom
components without verified case support throw NotSupportedException
instead of falling back to English.
V4 previews also provide opt-in decimal SI and binary IEC byte-size APIs:
var size = ByteSize.FromBytes(1_000_000);
Console.WriteLine(size.Format(ByteSizeUnitSystem.DecimalSi)); // 1 MB
Console.WriteLine(size.Format(ByteSizeUnitSystem.BinaryIec)); // 976.56 KiBLegacy byte-size APIs keep their established unit factors. See byte sizes and rates for explicit formatting, parsing, composites, and rates.
The main library is in src/Humanizer, and its xUnit tests are in tests/Humanizer.Tests. Read the contribution guide before sending a change.
Humanizer is available under the MIT license.
Portuguese locale: incorrect `milhar` value and misspelled `milissegundo`
humanizer
Various non-standard and incorrect plurals are currently in use
Dehumanize() inserts a space before trailing digits (v3 regression)
Localized arbitrary-string Pluralize/Singularize with locale-owned grammar