Questions tagged [humanizer]

Humanizer is a C# .NET library that convert several types values into human readable content.

Humanizer can be found here:

https://github.com/MehdiK/Humanizer

25 questions
6
votes
0 answers

How do I customise the formatted string returned when using Humanize on a TimeSpan object?

I'm using Humanizer to format a TimeSpan object. It's very handy, however, I also want my string to be formatted like so: "xd yh zm as" instead of "x days, y hours, z minutes, a seconds". I'm currently just replacing those substrings after Humanize…
Alistair
  • 1,104
  • 9
  • 15
5
votes
1 answer

How to make Humanizer not display "no time" if the precision is bigger?

I am using Humanizer on a TimeSpan with precision 4: (dateEnd - dateStart).Humanize(4) And it generates something like this: 2 hours, 17 minutes, 20 seconds, 141 milliseconds But when the time remaining is just minutes (less than a hour left) it…
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
4
votes
1 answer

Add space around each / using Humanizer or Regex

I have a string like the following: var text = @"Some text/othertext/ yet more text /last of the text"; I want to normalize the spaces around each slash so it matches the following: var text = @"Some text / othertext / yet more text / last of the…
user47589
4
votes
1 answer

Humanize uppercase name with hyphenated last name

This is a standard way to title case uppercase names using the .NET Humanizer library. "FIRST M HYPHENATED-LAST".Transform(To.LowerCase, To.TitleCase); // Result (v1.37.0): "First M Hyphenated-last" // Desired Result: "First M…
Jeremy Cook
  • 20,840
  • 9
  • 71
  • 77
4
votes
1 answer

Is it possible to Humanize TimeSpan to years with Humanizer?

We want to leverage the Humanizer package (as we use it elsewhere) and don't want to add more similar libraries or hand rolled code. I have timespans some of which are thousands of days. I want to humanize them and convert them to years. Now I…
GraemeMiller
  • 11,973
  • 8
  • 57
  • 111
3
votes
2 answers

Humanizer for DateTime

I have this code: Configurator.DateTimeHumanizeStrategy = new PrecisionDateTimeHumanizeStrategy(.75); var dateTime1 = DateTime.UtcNow.AddYears(2).AddMonths(-5); var text1 = dateTime1.Humanize(); In the text1 variable I get "one year from now". But…
robocik
  • 101
  • 7
  • 20
3
votes
1 answer

Humanizer fails to singularize or pluralize an italian word in C#

I have managed to singularize/pluralize an English word using Humanizer, but when I set the CultureInfo to Italian, it just adds an extra 's' to the word. For example: "Man".Pluralize() => "Men" ----- correct, It works as…
Lorenzo Goldoni
  • 555
  • 6
  • 22
3
votes
2 answers

Why can't I use the TextInfo.ToTitleCase method in the Humanizer library?

I downloaded the code for the Humanizer library from their GitHub page and was testing some changes in the code when I noticed a yellow "status warning" icon in the Intellisense window when looking at some methods on the TextInfo class: I have…
Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
3
votes
1 answer

Humanizer French title case support

The built in .Net method TextInfo.ToTitleCase handles French sentences ok, but there are some samples which cause issues, see remarks (copied below): Generally, title casing converts the first character of a word to uppercase and the rest of the…
Graeme
  • 773
  • 1
  • 8
  • 18
2
votes
1 answer

Humanizer Pluralize/Singularize to indicate Is/Are based on the collection size

How can I singularize or pluralize a string with the words is or are based on a collection size. For example I would like to notify users about a conflict in a scheduling, And there could be 1 or more conflicts. So based on the amount of conflicts I…
Y Neuhaus
  • 84
  • 1
  • 6
2
votes
1 answer

Humanizer localization not work in IIS

I am using humanizer for getting human friendly string telling how far back or forward in time some date is. Some examples is here: DateTime.UtcNow.AddHours(-30).Humanize() => "yesterday" DateTime.UtcNow.AddHours(-2).Humanize() => "2 hours…
Seyed Morteza Mousavi
  • 6,855
  • 8
  • 43
  • 69
1
vote
2 answers

How to Convert Currency to Words using Humanizer

I need to use the Nuget package Humanizer to convert currency to English words equivalent as follows using Humanizer; AmountInWords = pmt.Amount.ToWords() pmt.Amount is of type decimal and it represents the amount in figures I get the following…
Josh
  • 1,660
  • 5
  • 33
  • 55
1
vote
1 answer

Humanizr.net ignore word/acronym

I am looping through a collection of strings and using Humanizr.net. This is so that I can correct each string to sentence case. For example. List mystrings = new List(); mystrings.Add("my string one"); …
fox909a
  • 81
  • 2
  • 11
1
vote
3 answers

Singularize method not found

For the last months I didn't had any problem but since few days my application doesn't start. I've spent many hours trying my best to finally come with this error : System.MissingMethodException : 'Méthode introuvable : 'System.String…
Ximaze C
  • 138
  • 10
0
votes
1 answer

MetricNumeralExtensions.ToMetric is obsolete, use MetricNumeralFormats?

We've upgraded Humanizer from 2.8.26 to 2.11.10 and now get the following warning: 'MetricNumeralExtensions.ToMetric(double, bool, bool, int?)' is obsolete: 'Please use overload with MetricNumeralFormats' Are there any examples on how to use…
aloisdg
  • 22,270
  • 6
  • 85
  • 105
1
2