![]() |
VOOZH | about |
dotnet add package Iciclecreek.AdaptiveExpressions.Humanizer --version 4.20.0
NuGet\Install-Package Iciclecreek.AdaptiveExpressions.Humanizer -Version 4.20.0
<PackageReference Include="Iciclecreek.AdaptiveExpressions.Humanizer" Version="4.20.0" />
<PackageVersion Include="Iciclecreek.AdaptiveExpressions.Humanizer" Version="4.20.0" />Directory.Packages.props
<PackageReference Include="Iciclecreek.AdaptiveExpressions.Humanizer" />Project file
paket add Iciclecreek.AdaptiveExpressions.Humanizer --version 4.20.0
#r "nuget: Iciclecreek.AdaptiveExpressions.Humanizer, 4.20.0"
#:package Iciclecreek.AdaptiveExpressions.Humanizer@4.20.0
#addin nuget:?package=Iciclecreek.AdaptiveExpressions.Humanizer&version=4.20.0Install as a Cake Addin
#tool nuget:?package=Iciclecreek.AdaptiveExpressions.Humanizer&version=4.20.0Install as a Cake Tool
This library provides humanizer functions to AdaptiveExpressions
To install
dotnet install Iciclecreek.AdaptiveExpressions.Humanizer
To add to your schema for usage in Bot Framework Composer from cli:
bf dialog:merge -p yourproj.proj -o your.schema
This library creates expression functions which are bound to humanizer functions.
| Function | Description | Example | Output |
|---|---|---|---|
| allCaps(text) | returns text all caps | humanizer.allCaps("This is a test") | "THIS IS A TEST" |
| lowerCase(text) | returns text all lower | humanizer.lowerCase("This is a test") | "this is a test" |
| sentence(text) | returns text as sentence cap | humanizer.sentence("this is a test") | "This is a test" |
| title(text) | returns text with each word cap | humanizer.sentence("this is a test") | "This Is A Test" |
The HumanizeXX functions turn complex structures like Dates and TimeSpans into human phrases
| Function | Description | Example | Output |
|---|---|---|---|
| humanizeDateTime(date, ?culture) | humanize a date relative to a now | humanizer.humanizeDateTime(date) | "yesterday" |
| humanizeDateTime(date, relDate, ?culture) | humanize a date relative to a date | humanizer.humanizeDateTime(date, timeInPast) | "an hour before" |
| humanizeTimeSpan(span, ?culture) | humanize timespan | humanizer.humanizeTimeSpan(span) | "a couple of minutes" |
| humanizeTimeSpan(span, GrammaticalCase,?culture) | humanize timespan | humanizer.humanizeTimeSpan(span, GrammaticalCase) | a couple of minutes |
| dateTimeToOrdinalWords(date, ?culture) | turn a date time into words | humanizer.dateTimeToOrdinalWords(date) | "May 5th, 2020" |
| dateTimeToOrdinalWords(date, ?GrammaticalCase, ?culture) | turn a date time into words | humanizer.dateTimeToOrdinalWords(date, 'Accusitive') | "May 5th, 2020" |
Functions for creating TimeSpans from numbers.
| Function | Description | Example | Output |
|---|---|---|---|
| weeks(number) | creates timespan from number of weeks | humanizer.weeks(13) | TimeSpan.FromWeeks(13) |
| days(number) | creates timespan from number of days | humanizer.days(13) | TimeSpan.FromDays(13) |
| hours(number) | creates timespan from number of hours | humanizer.hours(13) | TimeSpan.FromHours(13) |
| minutes(number) | creates timespan from number of minutes | humanizer.minutes(13) | TimeSpan.FromMinutes(13) |
| seconds(number) | creates timespan from number of seconds | humanizer.seconds(13) | TimeSpan.FromSeconds(13) |
| milliseconds(number) | creates timespan from number of milliseconds | humanizer.milliseconds(13) | TimeSpan.FromMilliseconds(13) |
Functions for converting intepreting number as binary units and converting to text.
| Function | Description | Example | Output |
|---|---|---|---|
| bits(number) | converts number as bits to text | humanizer.bits(32) | "32 bits" |
| bytes(number) | converts number as bytes to text | humanizer.bytes(32) | "32 B" |
| kilobytes(number) | converts number as kilboytes to text | humanizer.kilobytes(65) | "65 Kb" |
| megabytes(number) | converts number as megabytes to text | humanizer.megabytes(1.3) | "1.3 Mb" |
| gigabytes(number) | converts number as gigabytes to text | humanizer.gigabytes(1.3) | "1.3 Gb" |
| terabytes(number) | converts number as terbytes to text | humanizer.terabytes(1.3) | "1.3 Gb" |
Converts degrees to direction headings and back
| Function | Description | Example | Output |
|---|---|---|---|
| degress2heading(number, ?culture) | converts number as degrees to heading text | humanizer.degrees2heading(10) | "NE" |
| degress2heading(number, headingstyle, ?culture) | converts number as degrees to heading text as style | humanizer.degrees2heading(10, 'Full') | "north-northeast" |
| heading2degrees(heading()) | gets degrees from heading text | humanizer.heading2degrees('ne') | 45 |
Text transformation functions.
| Function | Description | Example | Output |
|---|---|---|---|
| pluralize(text, ?isKnownToBeSinglar) | turns singular word into plural | humanizer.pluraize('cat') | "cats" |
| singularlize(text, ?isKnownToBePlural) | turns plural word into singular | humanizer.pluraize('cats') | "cat" |
| camelize(text) | transform text into camelcase | humanizer.camelize('this is a test') | "thisIsATest" |
| dashorize(text) | transform text to replace underscore with dash | humanizer.dashorize('this_is_a_test') | "this-is-a-test" |
| hyphenate(text) | transform text to replace underscore with dash | humanizer.hyphenate('this_is_a_test') | "this-is-a-test" |
| kebaberize(text) | transform text to replace whitespace with dash | humanizer.kebaberize('this is a test') | "this-is-a-test" |
| pascalize(text) | transform text to replace whitespace with Uppercase word boundaries | humanizer.pascalize('this is a test') | "ThisIsATest" |
| titleize(text) | transform text to upercase words on word boundary | humanizer.titleize('this is a test') | "This Is A Test" |
| truncate(text, chars, truncation) | transform text to truncate at number of chars, appending trunction | humanizer.truncate('this is a test', 3, '...') | "thi..." |
| truncateWords(text, words, truncation) | transform text to truncate at number of words, appending trunction | humanizer.truncateWords('this is a test', 2, '...') | "this is a..." |
for working with numbers, units and text.
| Function | Description | Example | Output |
|---|---|---|---|
| number2metric(text) | convert number to metric text | humanizer.number2metric(1300) | '1.3k' |
| metric2number(text, ?hasSpace, ?decimals) | interpret text as metric | humanizer.metric2number('1.3k') | 1300 |
| number2words(number, ?culture) | convert number to words | humanizer.number2words(1500) | 'one thousand five hundred' |
| number2words(number, ?gender, ?culture) | convert number to words | humanizer.number2words(1500, 'Masculine') | 'one thousand five hundred' |
| number2ordinalWords(number, ?culture) | convert number to ordinal words (first, second) | humanizer.number2ordinalWords(1) | 'first' |
| number2ordinalWords(number, ?gender, ?culture) | convert number to ordinal words (first, second) | humanizer.number2ordinalWords(1, 'Masculine') | 'first' |
| number2ordinal(number) | convert number to ordinal (1st, 2nd) words | humanizer.number2ordinal(1) | '1st' |
| number2ordinal(number, ?gender) | convert number to ordinal (1st, 2nd) words | humanizer.number2ordinal(1, 'Masculine') | '1st' |
| fromRoman(text) | convert text to number | humanizer.fromRoman('IV') | 4 |
| toRoman(number) | convert number to roman numeral text | humanizer.toRoman(4) | 'IV' |
| toQuantity(name, quantity, ?style) | convert name and quantity to grammatically correct name | humanizer.toQuantity('cats',0) | 'no cats' |
| toQuantity(name, quantity, ?style) | convert name and quantity to grammatically correct name | humanizer.toQuantity('cats',1, 'Numeric') | '1 cat' |
| toQuantity(name, quantity, ?style) | convert name and quantity to grammatically correct name | humanizer.toQuantity('cats',2, 'Words') | 'Two cats' |
Functions which map to dotnet standard format strings.
| Function | Description | Example | Output |
|---|---|---|---|
| numberToString(format,?culture) | format number | dotnet.numberToString(1.3, "C") | "$1.30" |
| intToString(format,?culture) | format integer | dotnet.numberToString(1, "D2") | "1" |
| dateTimeToString(format,?culture) | format dateTime | dotnet.dateTimeToString(date, "YYYY-MM-DD") | "2020-05-25" |
| timeSpanToString(format,?culture) | format dateTime | dotnet.timeSpanToString(span, "N") | "00:43:00" |
NOTE: these functions are not part of humanizer, and are dotnet only, so they are in dotnet namespace.
By default the Thread.CurrentThread.CurrentThread.CurrentUICulture property will be used for locale sensitive conversations. Any method which has a ?culture argument can also accept the culture as a string like 'fr'
Humanizer has broad open source language support:
| Code | Language |
|---|---|
| af | Afrikaans |
| ar | Arabic |
| bg | Bulgarian |
| bn-BD | Bangla (Bangladesh) |
| cs | Czech |
| da | Danish |
| de | German |
| el | Greek |
| es | Spanish |
| fa | Persian |
| fi-FI | Finnish (Finland) |
| fr | French |
| fr-BE | French (Belgium) |
| he | Hebrew |
| hr | Croatian |
| hu | Hungarian |
| hy | Armenian |
| id | Indonesian |
| it | Italian |
| ko-KR | Korean (Korea) |
| lv | Latvian |
| ms-MY | Malay (Malaysia) |
| mt | Maltese |
| nb | Norwegian Bokmål |
| nb-NO | Norwegian Bokmål (Norway) |
| nl | Dutch |
| pl | Polish |
| pt | Portuguese |
| ro | Romanian |
| ru | Russian |
| sk | Slovak |
| sl | Slovenian |
| sr | Serbian |
| sr-Latn | Serbian (Latin) |
| sv | Swedish |
| th-TH | Thai (Thailand) |
| tr | Turkish |
| uk | Ukrainian |
| uz-Cyrl-UZ | Uzbek (Cyrillic, Uzbekistan) |
| uz-Latn-UZ | Uzbek (Latin, Uzbekistan) |
| vi | Vietnamese |
| zh-CN | Chinese (Simplified, China) |
| zh-Hans | Chinese (Simplified) |
| zh-Hant | Chinese (Traditional) |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.20.0 | 504 | 6/16/2023 |
| 4.19.0 | 373 | 4/15/2023 |
| 4.16.1 | 927 | 4/22/2022 |
| 4.16.0 | 624 | 4/22/2022 |
| 4.14.0 | 683 | 7/17/2021 |
| 4.13.0 | 638 | 4/17/2021 |
| 4.12.0 | 566 | 3/8/2021 |
| 4.11.1 | 613 | 1/7/2021 |
| 4.11.0-rc0 | 552 | 10/28/2020 |
| 4.10.3 | 669 | 10/17/2020 |
| 4.10.0 | 692 | 9/3/2020 |
| 4.9.1 | 777 | 5/17/2020 |
| 4.9.0-rc4.2 | 467 | 5/8/2020 |
| 4.9.0-rc4.1 | 460 | 5/7/2020 |
| 4.9.0-rc4 | 580 | 5/7/2020 |