diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8a10d8db2..033b370fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,4 +53,4 @@ Check out [Dutch](https://github.com/Humanizr/Humanizer/blob/master/src/Humanize [Russian](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs) localisations for examples of how you can write a Converter for your language. You should then register your converter in the [ConverterFactory](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer/NumberToWordsExtension.cs#L13) for it to kick in on your locale. -Don't forget to write tests for your localisations. Check out the existing [DateHumanizeTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs), [TimeSpanHumanizeTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs) and [NumberToWordsTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests/Localisation/ru-RU/NumberToWordsTests.cs). +Don't forget to write tests for your localisations. Check out the existing [DateHumanizeTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests.Shared/Localisation/ru-RU/DateHumanizeTests.cs), [TimeSpanHumanizeTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests.Shared/Localisation/ru-RU/TimeSpanHumanizeTests.cs) and [NumberToWordsTests](https://github.com/Humanizr/Humanizer/blob/master/src/Humanizer.Tests.Shared/Localisation/ru-RU/NumberToWordsTests.cs). diff --git a/GitVersionConfig.yaml b/GitVersionConfig.yaml index 81726999d..6404cb33a 100644 --- a/GitVersionConfig.yaml +++ b/GitVersionConfig.yaml @@ -1,5 +1,4 @@ assembly-versioning-scheme: MajorMinorPatch -mode: ContinuousDelivery tag-prefix: '[vV]' continuous-delivery-fallback-tag: ci next-version: 2.0.0 @@ -11,44 +10,37 @@ build-metadata-padding: 4 commit-message-incrementing: Enabled branches: master: - mode: ContinuousDelivery tag: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - releases?[/-]: - mode: ContinuousDelivery + release: tag: beta increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - features?[/-]: - mode: ContinuousDelivery + feature: tag: useBranchName increment: Inherit prevent-increment-of-merged-branch-version: false track-merge-target: false - (pull|pull\-requests|pr)[/-]: - mode: ContinuousDelivery + pull-request: tag: PullRequest increment: Inherit prevent-increment-of-merged-branch-version: false tag-number-pattern: '[/-](?\d+)[-/]' track-merge-target: false - hotfix(es)?[/-]: - mode: ContinuousDelivery + hotfix: tag: beta increment: Patch prevent-increment-of-merged-branch-version: false track-merge-target: false - support[/-]: - mode: ContinuousDelivery + support: tag: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - dev(elop)?(ment)?$: - mode: ContinuousDelivery + develop: tag: beta increment: Minor prevent-increment-of-merged-branch-version: false diff --git a/NuSpecs/Humanizer.Core.af.nuspec b/NuSpecs/Humanizer.Core.af.nuspec index 14fe24e6e..502f66d53 100644 --- a/NuSpecs/Humanizer.Core.af.nuspec +++ b/NuSpecs/Humanizer.Core.af.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.ar.nuspec b/NuSpecs/Humanizer.Core.ar.nuspec index f4f6adde7..629de39bb 100644 --- a/NuSpecs/Humanizer.Core.ar.nuspec +++ b/NuSpecs/Humanizer.Core.ar.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.bg.nuspec b/NuSpecs/Humanizer.Core.bg.nuspec index 38fc38d23..08e860741 100644 --- a/NuSpecs/Humanizer.Core.bg.nuspec +++ b/NuSpecs/Humanizer.Core.bg.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.bn-BD.nuspec b/NuSpecs/Humanizer.Core.bn-BD.nuspec index d09a10889..469b8313f 100644 --- a/NuSpecs/Humanizer.Core.bn-BD.nuspec +++ b/NuSpecs/Humanizer.Core.bn-BD.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.cs.nuspec b/NuSpecs/Humanizer.Core.cs.nuspec index 8cb9a165d..6c710ced1 100644 --- a/NuSpecs/Humanizer.Core.cs.nuspec +++ b/NuSpecs/Humanizer.Core.cs.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.da.nuspec b/NuSpecs/Humanizer.Core.da.nuspec index 2333df003..138077db7 100644 --- a/NuSpecs/Humanizer.Core.da.nuspec +++ b/NuSpecs/Humanizer.Core.da.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.de.nuspec b/NuSpecs/Humanizer.Core.de.nuspec index 5cdd349eb..3bd1a1b0a 100644 --- a/NuSpecs/Humanizer.Core.de.nuspec +++ b/NuSpecs/Humanizer.Core.de.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.el.nuspec b/NuSpecs/Humanizer.Core.el.nuspec index 1cab5f35c..fce38cd89 100644 --- a/NuSpecs/Humanizer.Core.el.nuspec +++ b/NuSpecs/Humanizer.Core.el.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.es.nuspec b/NuSpecs/Humanizer.Core.es.nuspec index 400828aab..725453cbb 100644 --- a/NuSpecs/Humanizer.Core.es.nuspec +++ b/NuSpecs/Humanizer.Core.es.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.fa.nuspec b/NuSpecs/Humanizer.Core.fa.nuspec index ae281c7aa..a5742c1f2 100644 --- a/NuSpecs/Humanizer.Core.fa.nuspec +++ b/NuSpecs/Humanizer.Core.fa.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.fi-FI.nuspec b/NuSpecs/Humanizer.Core.fi-FI.nuspec index dc2d764b5..6d87f321b 100644 --- a/NuSpecs/Humanizer.Core.fi-FI.nuspec +++ b/NuSpecs/Humanizer.Core.fi-FI.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.fr-BE.nuspec b/NuSpecs/Humanizer.Core.fr-BE.nuspec index e5bc2a258..694d0772a 100644 --- a/NuSpecs/Humanizer.Core.fr-BE.nuspec +++ b/NuSpecs/Humanizer.Core.fr-BE.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.fr.nuspec b/NuSpecs/Humanizer.Core.fr.nuspec index 9eb789ba8..cfa75aa9f 100644 --- a/NuSpecs/Humanizer.Core.fr.nuspec +++ b/NuSpecs/Humanizer.Core.fr.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.he.nuspec b/NuSpecs/Humanizer.Core.he.nuspec index 2be3c18fc..92e99d01d 100644 --- a/NuSpecs/Humanizer.Core.he.nuspec +++ b/NuSpecs/Humanizer.Core.he.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.hr.nuspec b/NuSpecs/Humanizer.Core.hr.nuspec index f91bb6ae3..c59d0d144 100644 --- a/NuSpecs/Humanizer.Core.hr.nuspec +++ b/NuSpecs/Humanizer.Core.hr.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.hu.nuspec b/NuSpecs/Humanizer.Core.hu.nuspec index aa2e9976f..a3a6b2eba 100644 --- a/NuSpecs/Humanizer.Core.hu.nuspec +++ b/NuSpecs/Humanizer.Core.hu.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.id.nuspec b/NuSpecs/Humanizer.Core.id.nuspec index 99953951d..b79872b41 100644 --- a/NuSpecs/Humanizer.Core.id.nuspec +++ b/NuSpecs/Humanizer.Core.id.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.it.nuspec b/NuSpecs/Humanizer.Core.it.nuspec index 621556428..5e513fdf6 100644 --- a/NuSpecs/Humanizer.Core.it.nuspec +++ b/NuSpecs/Humanizer.Core.it.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.ja.nuspec b/NuSpecs/Humanizer.Core.ja.nuspec index 016f32c6b..c0244f78d 100644 --- a/NuSpecs/Humanizer.Core.ja.nuspec +++ b/NuSpecs/Humanizer.Core.ja.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.lv.nuspec b/NuSpecs/Humanizer.Core.lv.nuspec new file mode 100644 index 000000000..8ff5c2842 --- /dev/null +++ b/NuSpecs/Humanizer.Core.lv.nuspec @@ -0,0 +1,23 @@ + + + + Humanizer.Core.lv + $version$ + Humanizer Locale (lv) + Mehdi Khalili, Oren Novotny + Mehdi Khalili, onovotny + https://github.com/Humanizr/Humanizer + https://raw.github.com/Humanizr/Humanizer/master/logo.png + false + Humanizer Locale (lv) + Copyright 2012-2015 Mehdi Khalili + https://raw.githubusercontent.com/Humanizr/Humanizer/master/LICENSE + lv + + + + + + + + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.nb-NO.nuspec b/NuSpecs/Humanizer.Core.nb-NO.nuspec index 800389086..8b938716b 100644 --- a/NuSpecs/Humanizer.Core.nb-NO.nuspec +++ b/NuSpecs/Humanizer.Core.nb-NO.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.nb.nuspec b/NuSpecs/Humanizer.Core.nb.nuspec index ea889328a..585a81a78 100644 --- a/NuSpecs/Humanizer.Core.nb.nuspec +++ b/NuSpecs/Humanizer.Core.nb.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.nl.nuspec b/NuSpecs/Humanizer.Core.nl.nuspec index 88636266b..8d0c61d9a 100644 --- a/NuSpecs/Humanizer.Core.nl.nuspec +++ b/NuSpecs/Humanizer.Core.nl.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.nuspec b/NuSpecs/Humanizer.Core.nuspec index 59a6c3f29..5056db553 100644 --- a/NuSpecs/Humanizer.Core.nuspec +++ b/NuSpecs/Humanizer.Core.nuspec @@ -16,11 +16,11 @@ - + - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.pl.nuspec b/NuSpecs/Humanizer.Core.pl.nuspec index 6d0191ddb..5e9d84566 100644 --- a/NuSpecs/Humanizer.Core.pl.nuspec +++ b/NuSpecs/Humanizer.Core.pl.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.pt.nuspec b/NuSpecs/Humanizer.Core.pt.nuspec index 9f310b001..26728c957 100644 --- a/NuSpecs/Humanizer.Core.pt.nuspec +++ b/NuSpecs/Humanizer.Core.pt.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.ro.nuspec b/NuSpecs/Humanizer.Core.ro.nuspec index 58c8968cd..6026c8929 100644 --- a/NuSpecs/Humanizer.Core.ro.nuspec +++ b/NuSpecs/Humanizer.Core.ro.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.ru.nuspec b/NuSpecs/Humanizer.Core.ru.nuspec index 79a994313..336ac8e53 100644 --- a/NuSpecs/Humanizer.Core.ru.nuspec +++ b/NuSpecs/Humanizer.Core.ru.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.sk.nuspec b/NuSpecs/Humanizer.Core.sk.nuspec index e349767d1..f6f11c01e 100644 --- a/NuSpecs/Humanizer.Core.sk.nuspec +++ b/NuSpecs/Humanizer.Core.sk.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.sl.nuspec b/NuSpecs/Humanizer.Core.sl.nuspec index cae9440c9..e56b77e14 100644 --- a/NuSpecs/Humanizer.Core.sl.nuspec +++ b/NuSpecs/Humanizer.Core.sl.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.sr-Latn.nuspec b/NuSpecs/Humanizer.Core.sr-Latn.nuspec index ae06c0d1b..7e26b6647 100644 --- a/NuSpecs/Humanizer.Core.sr-Latn.nuspec +++ b/NuSpecs/Humanizer.Core.sr-Latn.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.sr.nuspec b/NuSpecs/Humanizer.Core.sr.nuspec index 246c462fb..dd5e36b5a 100644 --- a/NuSpecs/Humanizer.Core.sr.nuspec +++ b/NuSpecs/Humanizer.Core.sr.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.sv.nuspec b/NuSpecs/Humanizer.Core.sv.nuspec index 6fecd29de..595cf3555 100644 --- a/NuSpecs/Humanizer.Core.sv.nuspec +++ b/NuSpecs/Humanizer.Core.sv.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.tr.nuspec b/NuSpecs/Humanizer.Core.tr.nuspec index 1df866192..32dc47cdb 100644 --- a/NuSpecs/Humanizer.Core.tr.nuspec +++ b/NuSpecs/Humanizer.Core.tr.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.uk.nuspec b/NuSpecs/Humanizer.Core.uk.nuspec index 7149d4a04..b3e6cdb23 100644 --- a/NuSpecs/Humanizer.Core.uk.nuspec +++ b/NuSpecs/Humanizer.Core.uk.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.uz-Cyrl-UZ.nuspec b/NuSpecs/Humanizer.Core.uz-Cyrl-UZ.nuspec index 438f1afc8..e852d551f 100644 --- a/NuSpecs/Humanizer.Core.uz-Cyrl-UZ.nuspec +++ b/NuSpecs/Humanizer.Core.uz-Cyrl-UZ.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.uz-Latn-UZ.nuspec b/NuSpecs/Humanizer.Core.uz-Latn-UZ.nuspec index 77b68c7a9..002f1aa59 100644 --- a/NuSpecs/Humanizer.Core.uz-Latn-UZ.nuspec +++ b/NuSpecs/Humanizer.Core.uz-Latn-UZ.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.vi.nuspec b/NuSpecs/Humanizer.Core.vi.nuspec index 337572464..4e3cd4eea 100644 --- a/NuSpecs/Humanizer.Core.vi.nuspec +++ b/NuSpecs/Humanizer.Core.vi.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.zh-CN.nuspec b/NuSpecs/Humanizer.Core.zh-CN.nuspec index 52cfbe540..7c7ecac3a 100644 --- a/NuSpecs/Humanizer.Core.zh-CN.nuspec +++ b/NuSpecs/Humanizer.Core.zh-CN.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.zh-Hans.nuspec b/NuSpecs/Humanizer.Core.zh-Hans.nuspec index f13e0dd1d..382a3af7d 100644 --- a/NuSpecs/Humanizer.Core.zh-Hans.nuspec +++ b/NuSpecs/Humanizer.Core.zh-Hans.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.Core.zh-Hant.nuspec b/NuSpecs/Humanizer.Core.zh-Hant.nuspec index 4cc8106f0..a0888b5c4 100644 --- a/NuSpecs/Humanizer.Core.zh-Hant.nuspec +++ b/NuSpecs/Humanizer.Core.zh-Hant.nuspec @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/NuSpecs/Humanizer.nuspec b/NuSpecs/Humanizer.nuspec index 284c8dd10..04a9be1b1 100644 --- a/NuSpecs/Humanizer.nuspec +++ b/NuSpecs/Humanizer.nuspec @@ -10,7 +10,7 @@ https://raw.github.com/Humanizr/Humanizer/master/logo.png false Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities - Copyright 2012-2016 Mehdi Khalili + Copyright 2012-2017 Mehdi Khalili https://raw.githubusercontent.com/Humanizr/Humanizer/master/LICENSE @@ -32,6 +32,7 @@ + diff --git a/NuSpecs/Humanizer.xproj.nuspec b/NuSpecs/Humanizer.xproj.nuspec deleted file mode 100644 index 2010d48d3..000000000 --- a/NuSpecs/Humanizer.xproj.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - Humanizer.xproj - $version$ - Humanizer XProj Workaround - Mehdi Khalili, Oren Novotny - Mehdi Khalili, onovotny - https://github.com/Humanizr/Humanizer - https://raw.github.com/Humanizr/Humanizer/master/logo.png - false - Humanizer for XProj with a workaround for https://github.com/dotnet/cli/issues/3396 - Copyright 2012-2016 - https://raw.githubusercontent.com/Humanizr/Humanizer/master/LICENSE - en - - - - - - - - - - \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index dc29533ea..04b5a3d3f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +image: Visual Studio 2017 configuration: Release branches: only: @@ -5,17 +6,21 @@ branches: - dev - /hotfix\/.*/ +environment: + SignClientSecret: + secure: S26+NphAhj/vo5ZdHd/N/4toty3ztdNGmuNdvAB57W1oIVQEHVKqAVuhTD8B9ATy + init: - - cmd: set - + - git config --global core.autocrlf input + install: - - cmd: appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/v3.5.0-beta2/NuGet.exe + - cmd: appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/v4.1.0/NuGet.exe - cmd: nuget install GitVersion.CommandLine -SolutionDir %APPVEYOR_BUILD_FOLDER% -Verbosity quiet -ExcludeVersion -pre - - cmd: nuget install gitlink -SolutionDir %APPVEYOR_BUILD_FOLDER% -Verbosity quiet -ExcludeVersion -pre + - cmd: nuget install SignClient -Version 0.7.0 -SolutionDir %APPVEYOR_BUILD_FOLDER% -Verbosity quiet -ExcludeVersion before_build: - - cmd: nuget restore src\Humanizer.sln - - cmd: '.\packages\GitVersion.CommandLine\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo' + - cmd: msbuild /t:restore src\Humanizer.sln + - cmd: '.\packages\GitVersion.CommandLine\tools\GitVersion.exe /l console /output buildserver' build: verbosity: normal @@ -23,13 +28,10 @@ build: project: src\Humanizer.sln after_build: - - cmd: '.\packages\gitlink\lib\net45\GitLink.exe . -f src\Humanizer.sln -u https://github.com/Humanizr/Humanizer -s %APPVEYOR_REPO_COMMIT% -errorsaswarnings' - ps: | - $nugetVer = $env:GitVersion_NuGetVersion - if(![string]::IsNullOrWhiteSpace($env:GitVersion_BuildMetaDataPadded)) { - $nugetVer = $nugetVer + "-build$env:GitVersion_BuildMetaDataPadded" - } + $nugetVer = $env:GitVersion_FullSemVer ls .\NuSpecs\*.nuspec | %{ nuget pack $_.FullName -version "$nugetVer" -BasePath "src" -NoPackageAnalysis } + - ps: '.\scripts\Sign-Package.ps1' - ps: 'ls *.nupkg | %{ appveyor PushArtifact $_.Name}' test: diff --git a/build.proj b/build.proj index f892861eb..351380731 100644 --- a/build.proj +++ b/build.proj @@ -2,7 +2,7 @@ - $(MSBuildThisFileDirectory)packages\xunit.runner.msbuild\build\portable-net45+win8+wp8+wpa81 + $(MSBuildThisFileDirectory)packages\xunit.runner.msbuild\build\net452 $(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll $(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll @@ -48,9 +48,9 @@ - + - + @@ -76,7 +76,7 @@ Log.LogMessage("Downloading latest version of NuGet.exe..."); WebClient webClient = new WebClient(); - webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", OutputFilename); + webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe", OutputFilename); return true; } diff --git a/build.ps1 b/build.ps1 index c5fe553ca..d7f4a6272 100644 --- a/build.ps1 +++ b/build.ps1 @@ -4,33 +4,12 @@ param( [int]$maxCpuCount = 0 ) +$msbuild = "msbuild.exe" # Kill all MSBUILD.EXE processes because they could very likely have a lock against our # MSBuild runner from when we last ran unit tests. get-process -name "msbuild" -ea SilentlyContinue | %{ stop-process $_.ID -force } -$msbuilds = @(get-command msbuild -ea SilentlyContinue) -if ($msbuilds.Count -gt 0) { - $msbuild = $msbuilds[0].Definition -} -else { - if (test-path "env:\ProgramFiles(x86)") { - $path = join-path ${env:ProgramFiles(x86)} "MSBuild\14.0\bin\MSBuild.exe" - if (test-path $path) { - $msbuild = $path - } - } - if ($msbuild -eq $null) { - $path = join-path $env:ProgramFiles "MSBuild\14.0\bin\MSBuild.exe" - if (test-path $path) { - $msbuild = $path - } - } - if ($msbuild -eq $null) { - throw "MSBuild could not be found in the path. Please ensure MSBuild v14 (from Visual Studio 2015) is in the path." - } -} - if ($maxCpuCount -lt 1) { $maxCpuCountText = $Env:MSBuildProcessorCount } else { diff --git a/readme.md b/readme.md index 412e6ec0b..7a139f730 100644 --- a/readme.md +++ b/readme.md @@ -32,10 +32,12 @@ Humanizer meets all your .NET needs for manipulating and displaying strings, enu - [Camelize](#camelize) - [Underscore](#underscore) - [Dasherize & Hyphenate](#dasherize--hyphenate) + - [Kebaberize](#kebaberize) - [Fluent date](#fluent-date) - [Number to Numbers](#number-to-numbers) - [Number to words](#number-to-words) - [Number to ordinal words](#number-to-ordinal-words) + - [DateTime to ordinal words](#date-time-to-ordinal-words) - [Roman numerals](#roman-numerals) - [Metric numerals](#metric-numerals) - [ByteSize](#bytesize) @@ -310,7 +312,7 @@ DateTime.UtcNow.AddHours(-2).Humanize() => "2 hours ago" DateTime.UtcNow.AddHours(30).Humanize() => "tomorrow" DateTime.UtcNow.AddHours(2).Humanize() => "2 hours from now" -DateTimeOffset.AddHours(1).Humanize() => "an hour from now" +DateTimeOffset.UtcNow.AddHours(1).Humanize() => "an hour from now" ``` Humanizer supports both local and UTC dates as well as dates with offset (`DateTimeOffset`). You could also provide the date you want the input date to be compared against. If null, it will use the current date as comparison base. @@ -344,8 +346,8 @@ There are two strategies for `DateTime.Humanize`: the default one as seen above To use the precision based strategy you need to configure it: ```C# -Configurator.DateTimeHumanizeStrategy = new PrecisionDateTimeHumanizeStrategy(precision = .75); -Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(precision = .75); // configure when humanizing DateTimeOffset +Configurator.DateTimeHumanizeStrategy = new PrecisionDateTimeHumanizeStrategy(precision: .75); +Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(precision: .75); // configure when humanizing DateTimeOffset ``` The default precision is set to .75 but you can pass your desired precision too. With precision set to 0.75: @@ -425,6 +427,11 @@ In addition, a maximum unit of time may be specified to avoid rolling up to the TimeSpan.FromDays(7).Humanize(maxUnit: TimeUnit.Day) => "7 days" // instead of 1 week TimeSpan.FromMilliseconds(2000).Humanize(maxUnit: TimeUnit.Millisecond) => "2000 milliseconds" // instead of 2 seconds ``` +The default maxUnit is `TimeUnit.Week` because it gives exact results. You can increase this value to `TimeUnit.Month` or `TimeUnit.Year` which will give you an approximation based on 365.2425 days a year and 30.436875 days a month. Therefore the months are alternating between 30 and 31 days in length and every fourth year is 366 days long. +```C# +TimeSpan.FromDays(486).Humanize(maxUnit: TimeUnit.Year, precision: 7) => "1 year, 3 months, 29 days" // One day further is 1 year, 4 month +TimeSpan.FromDays(517).Humanize(maxUnit: TimeUnit.Year, precision: 7) => "1 year, 4 months, 30 days" // This month has 30 days and one day further is 1 year, 5 months +``` When there are multiple time units, they are combined using the `", "` string: @@ -645,6 +652,13 @@ Obviously this only applies to some cultures. For others passing gender in or no "some_title".Hyphenate() => "some-title" ``` +#### Kebaberize +`Kebaberize` separates the input words with hyphens and all words are converted to lowercase + +```C# +"SomeText".Kebaberize() => "some-text" +``` + ### Fluent Date Humanizer provides a fluent API to deal with `DateTime` and `TimeSpan` as follows: @@ -792,7 +806,7 @@ The possible values are `GrammaticalGender.Masculine`, `GrammaticalGender.Femini ``` ```C# -// for Brazilian Portuguese locale +// for Arabic locale 1.ToOrdinalWords(GrammaticalGender.Masculine) => "الأول" 1.ToOrdinalWords(GrammaticalGender.Feminine) => "الأولى" 1.ToOrdinalWords(GrammaticalGender.Neuter) => "الأول" @@ -810,6 +824,29 @@ Also, culture to use can be specified explicitly. If it is not, current thread's 1.ToOrdinalWords(GrammaticalGender.Masculine, new CulureInfo("pt-BR")) => "primeiro" ``` + +###DateTime to ordinal words +This is kind of an extension of Ordinalize +```C# +// for English UK locale +new DateTime(2015, 1, 1).ToOrdinalWords() => "1st January 2015" +new DateTime(2015, 2, 12).ToOrdinalWords() => "12th February 2015" +new DateTime(2015, 3, 22).ToOrdinalWords() => "22nd March 2015" +// for English US locale +new DateTime(2015, 1, 1).ToOrdinalWords() => "January 1st, 2015" +new DateTime(2015, 2, 12).ToOrdinalWords() => "February 12th, 2015" +new DateTime(2015, 3, 22).ToOrdinalWords() => "March 22nd, 2015" +``` + +`ToOrdinalWords` also supports grammatical case. +You can pass a second argument to `ToOrdinalWords` to specify the case of the output. +The possible values are `GrammaticalCase.Nominative`, `GrammaticalCase.Genitive`, `GrammaticalCase.Dative`, `GrammaticalCase.Accusative`, `GrammaticalCase.Instrumental` and `GrammaticalGender.Prepositional`: + +```C# +``` + +Obviously this only applies to some cultures. For others passing case in doesn't make any difference in the result. + ### Roman numerals Humanizer can change numbers to Roman numerals using the `ToRoman` extension. The numbers 1 to 10 can be expressed in Roman numerals as follows: diff --git a/release_notes.md b/release_notes.md index 2e0f4d6c6..c6407981a 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,3 +1,54 @@ +# v2.2 + + - [#634](https://github.com/Humanizr/Humanizer/pull/634) - Added support for Greek language in resources contributed by Christos Matskas ([cmatskas](https://github.com/cmatskas)) + - [#633](https://github.com/Humanizr/Humanizer/pull/633) - #632 Continued: Fuzzy month years logic for time span humanize extensions contributed by Oren Novotny ([onovotny](https://github.com/onovotny)) +enhancement + - [#632](https://github.com/Humanizr/Humanizer/pull/632) - Fuzzy month years logic for time span humanize extensions contributed by Martin Strecker ([MaStr11](https://github.com/MaStr11)) + - [#631](https://github.com/Humanizr/Humanizer/pull/631) - Latvian localization contributed by Dmitry Bogatykh ([bogatykh](https://github.com/bogatykh)) + - [#630](https://github.com/Humanizr/Humanizer/pull/630) - billions and millions greater than 2 contributed by Rafael Bianchi ([rafaellfontana](https://github.com/rafaellfontana)) + - [#628](https://github.com/Humanizr/Humanizer/pull/628) - IsDefined is prefered contributed by Shimmy ([weitzhandler](https://github.com/weitzhandler)) + - [#623](https://github.com/Humanizr/Humanizer/issues/623) - Wrongful commit to master. What to do? + - [#620](https://github.com/Humanizr/Humanizer/issues/620) - Double Barrel Name conversion + - [#619](https://github.com/Humanizr/Humanizer/pull/619) - Update readme.md contributed by Tyler Brinkley ([TylerBrinkley](https://github.com/TylerBrinkley)) + - [#617](https://github.com/Humanizr/Humanizer/pull/617) - issue 611: added the method Kebaberize contributed by ([klaus78](https://github.com/klaus78)) + - [#616](https://github.com/Humanizr/Humanizer/issues/616) - English verb (Past Participle) tense conversion "x" => "xed" feasibility? + - [#613](https://github.com/Humanizr/Humanizer/issues/613) - Humanizer.Core not working correctly, show localized strings instead of english + - [#612](https://github.com/Humanizr/Humanizer/pull/612) - Added Swedish collection formatter contributed by Māris Brenčuks ([brencuks](https://github.com/brencuks)) + - [#610](https://github.com/Humanizr/Humanizer/pull/610) - adding parameter decimals toMetric(). Fixes #609 contributed by ([klaus78](https://github.com/klaus78)) + - [#609](https://github.com/Humanizr/Humanizer/issues/609) - add .ToMetric() rounding +enhancement + - [#608](https://github.com/Humanizr/Humanizer/pull/608) - 605: Fix enum no display attrib contributed by Thomas Bo Nielsen ([basildk](https://github.com/basildk)) + - [#605](https://github.com/Humanizr/Humanizer/issues/605) - enum with DisplayAttribute but no Description attribute fails +fix + - [#603](https://github.com/Humanizr/Humanizer/pull/603) - Syntax correction in readme.md contributed by Brian MacKay ([kinetiq](https://github.com/kinetiq)) + - [#602](https://github.com/Humanizr/Humanizer/pull/602) - Register Portuguese translations as `pt` contributed by ([hangy](https://github.com/hangy)) + - [#601](https://github.com/Humanizr/Humanizer/issues/601) - Humanize pt-PT problem + - [#600](https://github.com/Humanizr/Humanizer/pull/600) - Revert "Add Esperanto support to NumberToWords. Fixes #558" contributed by Oren Novotny ([onovotny](https://github.com/onovotny)) + - [#598](https://github.com/Humanizr/Humanizer/pull/598) - Workaround for Croatian TimeSpan localization bug contributed by ([hangy](https://github.com/hangy)) + - [#597](https://github.com/Humanizr/Humanizer/issues/597) - Croatian localization of TimeSpan fails with >1 day + - [#596](https://github.com/Humanizr/Humanizer/issues/596) - Can not add Humanizer 2.1.0 in Class library (.Net Core) + - [#595](https://github.com/Humanizr/Humanizer/pull/595) - Add new overload for Ordinalize that accepts a CultureInfo contributed by Thijs Brobbel ([tiesmaster](https://github.com/tiesmaster)) + - [#590](https://github.com/Humanizr/Humanizer/pull/590) - English contributed by ([stevotennis](https://github.com/stevotennis)) + - [#589](https://github.com/Humanizr/Humanizer/pull/589) - Fix CONTRIBUTING.md of broken links. contributed by Sho Sato ([cssho](https://github.com/cssho)) + - [#588](https://github.com/Humanizr/Humanizer/pull/588) - Add resource value validation for DefaultFormatter contributed by Krisztián Bodrogi ([Chrissx](https://github.com/Chrissx)) + - [#586](https://github.com/Humanizr/Humanizer/pull/586) - added translation for DateHumanize_Now contributed by Daniel Katz ([danielkatz](https://github.com/danielkatz)) + - [#583](https://github.com/Humanizr/Humanizer/issues/583) - TimeSpan.Humanize does not behave as expected +enhancement + - [#582](https://github.com/Humanizr/Humanizer/pull/582) - Pass through the content of the "Letter, other" Unicode category. contributed by ([hangy](https://github.com/hangy)) + - [#581](https://github.com/Humanizr/Humanizer/pull/581) - Fix misspelling contributed by Cameron Sjo ([cameron-sjo](https://github.com/cameron-sjo)) + - [#578](https://github.com/Humanizr/Humanizer/issues/578) - .Humanize() on "Arabic" letters returns empty string (or any other casing) + - [#577](https://github.com/Humanizr/Humanizer/issues/577) - .NET Core 1.0 Support? + - [#576](https://github.com/Humanizr/Humanizer/pull/576) - Fixed incorrect locale in readme contributed by ([fishchisel](https://github.com/fishchisel)) + - [#575](https://github.com/Humanizr/Humanizer/issues/575) - not installable for projects that targets .NET client profile + - [#574](https://github.com/Humanizr/Humanizer/issues/574) - Difference Dasherize and Hyphenate + - [#573](https://github.com/Humanizr/Humanizer/issues/573) - Humanizer.Core 2.1.0 breaks compatibility with PCL Profile 259 + - [#569](https://github.com/Humanizr/Humanizer/pull/569) - Add Esperanto support to NumberToWords. Fixes #558 contributed by Alois ([aloisdg](https://github.com/aloisdg)) + - [#558](https://github.com/Humanizr/Humanizer/issues/558) - Add Esperanto support for NumberToWords + - [#504](https://github.com/Humanizr/Humanizer/pull/504) - Add support for long to ToQuantity contributed by Robert Pethick ([RobPethick](https://github.com/RobPethick)) +enhancement + - [#503](https://github.com/Humanizr/Humanizer/issues/503) - ToQuantity does not support long quantities +enhancement + - [#500](https://github.com/Humanizr/Humanizer/pull/500) - Add ToOrdinalWords extension with gender overload contributed by Robert Pethick ([RobPethick](https://github.com/RobPethick)) + - [#328](https://github.com/Humanizr/Humanizer/issues/328) - Ordinal number suffixes + +[Commits](https://github.com/Humanizr/Humanizer/compare/v2.1...v2.2) + +# vNext + ### v2.1 - 2016-07-04 [Fixed issues](https://github.com/Humanizr/Humanizer/issues?q=is%3Aclosed+milestone%3Av2.1) @@ -5,7 +56,7 @@ ### v2.0.1 - 2016-02-07 - [#520](https://github.com/Humanizr/Humanizer/issues/520) Humanizer.Core package does not install on Xamarin - + [Commits](https://github.com/Humanizr/Humanizer/compare/v2.0...v2.0.1) ### v2.0.0 - 2016-01-30 @@ -30,7 +81,7 @@ - [#462](https://github.com/Humanizr/Humanizer/pull/462): Implemented Spanish cardinal feminines - [#459](https://github.com/Humanizr/Humanizer/pull/459): Add support of metric numeral expressions - Enable source debugging via [GitLink](https://github.com/GitTools/GitLink) - + [Commits](https://github.com/Humanizr/Humanizer/compare/v1.37.0...v2.0.0-beta01) ### v1.37.0 - 2015-07-03 @@ -355,3 +406,5 @@ fix it based on your requirements. ### v1.0.0 - 2013-11-10 No release history before this point: check out http://www.mehdi-khalili.com/humanizer-v1 for the feature-set at V1 + +Commits: ... diff --git a/samples/Humanizer.MvcSample/HumanizerMetadataProvider.cs b/samples/Humanizer.MvcSample/HumanizerMetadataProvider.cs index 9d9a4c556..47860b6ce 100644 --- a/samples/Humanizer.MvcSample/HumanizerMetadataProvider.cs +++ b/samples/Humanizer.MvcSample/HumanizerMetadataProvider.cs @@ -30,13 +30,13 @@ private static bool IsTransformRequired(ModelMetadata modelMetadata, IList().Any()) + if (propertyAttributes.IsDefined(typeof(DisplayNameAttribute), true)) return false; - if (propertyAttributes.OfType().Any()) + if (propertyAttributes.IsDefined(typeof(DisplayAttribute), true)) return false; return true; } } -} \ No newline at end of file +} diff --git a/scripts/Sign-Package.ps1 b/scripts/Sign-Package.ps1 new file mode 100644 index 000000000..acd44f323 --- /dev/null +++ b/scripts/Sign-Package.ps1 @@ -0,0 +1,25 @@ +$currentDirectory = split-path $MyInvocation.MyCommand.Definition + +# See if we have the ClientSecret available +if([string]::IsNullOrEmpty($env:SignClientSecret)){ + Write-Host "Client Secret not found, not signing packages" + return; +} + +# Setup Variables we need to pass into the sign client tool + +$appSettings = "$currentDirectory\SignClient.json" + +$appPath = "$currentDirectory\..\packages\SignClient\tools\SignClient.dll" + +$nupgks = ls $currentDirectory\..\*.nupkg | Select -ExpandProperty FullName + +foreach ($nupkg in $nupgks){ + Write-Host "Submitting $nupkg for signing" + + dotnet $appPath 'sign' -c $appSettings -i $nupkg -s $env:SignClientSecret -n 'Humanizer' -d 'Humanizer' -u 'https://github.com/Humanizr/Humanizer' + + Write-Host "Finished signing $nupkg" +} + +Write-Host "Sign-package complete" \ No newline at end of file diff --git a/scripts/SignClient.json b/scripts/SignClient.json new file mode 100644 index 000000000..e991c2b1f --- /dev/null +++ b/scripts/SignClient.json @@ -0,0 +1,13 @@ +{ + "SignClient": { + "AzureAd": { + "AADInstance": "https://login.microsoftonline.com/", + "ClientId": "eedcc7e7-c92c-42ff-9217-3ec939207bd8", + "TenantId": "71048637-3782-41a3-b6b2-6f4ac8a25ae0" + }, + "Service": { + "Url": "https://codesign.novotny.org/", + "ResourceId": "https://novotny.org/SignService" + } + } +} \ No newline at end of file diff --git a/src/Humanizer.Tests.DotNet/Humanizer.Tests.DotNet.xproj b/src/Humanizer.Tests.DotNet/Humanizer.Tests.DotNet.xproj deleted file mode 100644 index ee33f8010..000000000 --- a/src/Humanizer.Tests.DotNet/Humanizer.Tests.DotNet.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 50d97972-236c-46a0-b912-1310ce636569 - Humanizer.Tests - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Humanizer.Tests.DotNet/Properties/AssemblyInfo.cs b/src/Humanizer.Tests.DotNet/Properties/AssemblyInfo.cs deleted file mode 100644 index 07a9ac3a1..000000000 --- a/src/Humanizer.Tests.DotNet/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Humanizer.Tests.Dnx")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Humanizer.Tests.Dnx")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("50d97972-236c-46a0-b912-1310ce636569")] diff --git a/src/Humanizer.Tests.DotNet/project.json b/src/Humanizer.Tests.DotNet/project.json deleted file mode 100644 index 18f0fa1b4..000000000 --- a/src/Humanizer.Tests.DotNet/project.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "Humanizer.Tests.DotNet Class Library", - "authors": ["oren"], - "packOptions": { - "tags": [""], - "projectUrl": "", - "licenseUrl": "" - }, - - "buildOptions": { - "compile": ["**/*.cs", "../Humanizer.Tests.Shared/**/*.cs"] - }, - - "dependencies": { - "xunit": "2.2.0-beta2-build3300", - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "Humanizer.xproj": "2.1.0-beta01-build0092" - }, - - "testRunner": "xunit", - - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - } - }, - "buildOptions": { - "define": ["NETFX_CORE"] - } - }, - "net46": { - "dependencies": { - - }, - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "" - } - } - } -} diff --git a/src/Humanizer.Tests.Shared/EnumHumanizeTests.cs b/src/Humanizer.Tests.Shared/EnumHumanizeTests.cs index 785ff4378..1fa438cff 100644 --- a/src/Humanizer.Tests.Shared/EnumHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/EnumHumanizeTests.cs @@ -63,11 +63,17 @@ public void HonorsDisplayAttribute() { Assert.Equal(EnumTestsResources.MemberWithDisplayAttribute, EnumUnderTest.MemberWithDisplayAttribute.Humanize()); } + [Fact] + public void HandlesDisplayAttributeWithNoDescription() + { + Assert.Equal(EnumTestsResources.MemberWithDisplayAttributeWithoutDescription, EnumUnderTest.MemberWithDisplayAttributeWithoutDescription.Humanize()); + } [Fact] public void HonorsLocalizedDisplayAttribute() { Assert.Equal(EnumTestsResources.MemberWithLocalizedDisplayAttribute, EnumUnderTest.MemberWithLocalizedDisplayAttribute.Humanize()); } + } } diff --git a/src/Humanizer.Tests.Shared/EnumUnderTest.cs b/src/Humanizer.Tests.Shared/EnumUnderTest.cs index 009f3dc56..041ddc0ac 100644 --- a/src/Humanizer.Tests.Shared/EnumUnderTest.cs +++ b/src/Humanizer.Tests.Shared/EnumUnderTest.cs @@ -23,7 +23,9 @@ public enum EnumUnderTest [Display(Description = EnumTestsResources.MemberWithDisplayAttribute)] MemberWithDisplayAttribute, [Display(Description = "MemberWithLocalizedDisplayAttribute", ResourceType = typeof(EnumTestsResources))] - MemberWithLocalizedDisplayAttribute + MemberWithLocalizedDisplayAttribute, + [Display(Name = EnumTestsResources.MemberWithDisplayAttributeWithoutDescription)] + MemberWithDisplayAttributeWithoutDescription } public class EnumTestsResources @@ -37,6 +39,7 @@ public class EnumTestsResources public const string MemberWithoutDescriptionAttributeTitle = "Member Without Description Attribute"; public const string MemberWithoutDescriptionAttributeLowerCase = "member without description attribute"; public const string MemberWithDisplayAttribute = "Description from Display attribute"; + public const string MemberWithDisplayAttributeWithoutDescription = "Displayattribute without description"; public static string MemberWithLocalizedDisplayAttribute { get { return "Localized description from Display attribute"; } } } diff --git a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems index 29a58cbd2..a90b4d1c1 100644 --- a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems +++ b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems @@ -51,8 +51,10 @@ + + @@ -74,6 +76,7 @@ + @@ -103,6 +106,8 @@ + + @@ -124,6 +129,7 @@ + diff --git a/src/Humanizer.Tests.Shared/InflectorTests.cs b/src/Humanizer.Tests.Shared/InflectorTests.cs index 44975da7f..9e863ae1f 100644 --- a/src/Humanizer.Tests.Shared/InflectorTests.cs +++ b/src/Humanizer.Tests.Shared/InflectorTests.cs @@ -129,10 +129,24 @@ public void Camelize(string input, string expectedOutput) [InlineData("some title", "some_title")] [InlineData("some title that will be underscored", "some_title_that_will_be_underscored")] [InlineData("SomeTitleThatWillBeUnderscored", "some_title_that_will_be_underscored")] + [InlineData("SomeForeignWordsLikeÄgyptenÑu", "some_foreign_words_like_ägypten_ñu")] + [InlineData("Some wordsTo be Underscored", "some_words_to_be_underscored")] public void Underscore(string input, string expectedOuput) { Assert.Equal(expectedOuput, input.Underscore()); } + + // transform words into lowercase and separate with a - + [Theory] + [InlineData("SomeWords", "some-words")] + [InlineData("SOME words TOGETHER", "some-words-together")] + [InlineData("A spanish word EL niño", "a-spanish-word-el-niño")] + [InlineData("SomeForeignWords ÆgÑuÄgypten", "some-foreign-words-æg-ñu-ägypten")] + [InlineData("A VeryShortSENTENCE", "a-very-short-sentence")] + public void Kebaberize(string input, string expectedOutput) + { + Assert.Equal(expectedOutput, input.Kebaberize()); + } } class PluralTestSource : IEnumerable diff --git a/src/Humanizer.Tests.Shared/Localisation/DefaultFormatterTests.cs b/src/Humanizer.Tests.Shared/Localisation/DefaultFormatterTests.cs index 23a0ca6c6..daa38f51c 100644 --- a/src/Humanizer.Tests.Shared/Localisation/DefaultFormatterTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/DefaultFormatterTests.cs @@ -8,17 +8,6 @@ namespace Humanizer.Tests.Localisation { public class DefaultFormatterTests { - [Theory] - [InlineData(TimeUnit.Month, 1)] - [InlineData(TimeUnit.Month, 2)] - [InlineData(TimeUnit.Month, 10)] - [InlineData(TimeUnit.Year, 1)] - [InlineData(TimeUnit.Year, 2)] - [InlineData(TimeUnit.Year, 10)] - public void TimeSpanHumanizeThrowsExceptionForTimeUnitsLargerThanWeek(TimeUnit timeUnit, int unit) - { - Assert.Throws(() => new DefaultFormatter(CultureInfo.InvariantCulture.Name).TimeSpanHumanize(timeUnit, unit)); - } [Fact] [UseCulture("es")] diff --git a/src/Humanizer.Tests.Shared/Localisation/af/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/af/TimeSpanHumanizeTests.cs index 92e147736..fbda08ef7 100644 --- a/src/Humanizer.Tests.Shared/Localisation/af/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/af/TimeSpanHumanizeTests.cs @@ -7,6 +7,28 @@ namespace Humanizer.Tests.Localisation.af public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 jaar")] + [InlineData(731, "2 jaar")] + [InlineData(1096, "3 jaar")] + [InlineData(4018, "11 jaar")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 maand")] + [InlineData(61, "2 maande")] + [InlineData(92, "3 maande")] + [InlineData(335, "11 maande")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Fact] public void TwoWeeks() { diff --git a/src/Humanizer.Tests.Shared/Localisation/ar/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/ar/TimeSpanHumanizeTests.cs index 52b23bb2e..cffa58d52 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ar/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ar/TimeSpanHumanizeTests.cs @@ -6,6 +6,28 @@ namespace Humanizer.Tests.Localisation.ar [UseCulture("ar")] public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "السنة 1")] + [InlineData(731, "سنتين")] + [InlineData(1096, "3 سنة")] + [InlineData(4018, "11 سنة")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "شهر 1")] + [InlineData(61, "شهرين")] + [InlineData(92, "3 أشهر")] + [InlineData(335, "11 أشهر")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "أسبوع واحد")] [InlineData(14, "أسبوعين")] diff --git a/src/Humanizer.Tests.Shared/Localisation/bg/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/bg/TimeSpanHumanizeTests.cs index 130b4952c..feb0d80ea 100644 --- a/src/Humanizer.Tests.Shared/Localisation/bg/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/bg/TimeSpanHumanizeTests.cs @@ -6,6 +6,28 @@ namespace Humanizer.Tests.Localisation.bg [UseCulture("bg-BG")] public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "една година")] + [InlineData(731, "2 години")] + [InlineData(1096, "3 години")] + [InlineData(4018, "11 години")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "един месец")] + [InlineData(61, "2 месеца")] + [InlineData(92, "3 месеца")] + [InlineData(335, "11 месеца")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "една седмица")] [InlineData(14, "2 седмици")] diff --git a/src/Humanizer.Tests.Shared/Localisation/bn-BD/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/bn-BD/TimeSpanHumanizeTests.cs index dbf42307b..ef459ffd8 100644 --- a/src/Humanizer.Tests.Shared/Localisation/bn-BD/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/bn-BD/TimeSpanHumanizeTests.cs @@ -6,6 +6,29 @@ namespace Humanizer.Tests.Localisation.bnBD [UseCulture("bn-BD")] public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "এক বছর")] + [InlineData(731, "2 বছর")] + [InlineData(1096, "3 বছর")] + [InlineData(4018, "11 বছর")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "এক মাসের")] + [InlineData(61, "2 মাস")] + [InlineData(92, "3 মাস")] + [InlineData(335, "11 মাস")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "এক সপ্তাহ")] [InlineData(14, "2 সপ্তাহ")] diff --git a/src/Humanizer.Tests.Shared/Localisation/cs/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/cs/TimeSpanHumanizeTests.cs index d773116c7..53e54a87e 100644 --- a/src/Humanizer.Tests.Shared/Localisation/cs/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/cs/TimeSpanHumanizeTests.cs @@ -7,6 +7,28 @@ namespace Humanizer.Tests.Localisation.cs public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 roky")] + [InlineData(1096, "3 roky")] + [InlineData(4018, "11 let")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 měsíc")] + [InlineData(61, "2 měsíce")] + [InlineData(92, "3 měsíce")] + [InlineData(335, "11 měsíců")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(1, "1 milisekunda")] [InlineData(2, "2 milisekundy")] @@ -80,7 +102,7 @@ public void Days(int number, string expected) [InlineData(6, "6 týdnů")] public void Weeks(int number, string expected) { - Assert.Equal(expected, TimeSpan.FromDays(number*7).Humanize()); + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); } } } diff --git a/src/Humanizer.Tests.Shared/Localisation/da/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/da/TimeSpanHumanizeTests.cs index 3fc6512af..2ea633eda 100644 --- a/src/Humanizer.Tests.Shared/Localisation/da/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/da/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.da { [UseCulture("da-DK")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "et år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "en uge")] [InlineData(14, "2 uger")] diff --git a/src/Humanizer.Tests.Shared/Localisation/de/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/de/DateToOrdinalWordsTests.cs new file mode 100644 index 000000000..48ed80e1c --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/de/DateToOrdinalWordsTests.cs @@ -0,0 +1,15 @@ +using System; +using Xunit; + +namespace Humanizer.Tests.Localisation.de +{ + [UseCulture("de")] + public class DateToOrdinalWordsTests + { + [Fact] + public void OrdinalizeString() + { + Assert.Equal("1. Januar 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + } + } +} diff --git a/src/Humanizer.Tests.Shared/Localisation/de/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/de/TimeSpanHumanizeTests.cs index ba5d2ed70..588fc2998 100644 --- a/src/Humanizer.Tests.Shared/Localisation/de/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/de/TimeSpanHumanizeTests.cs @@ -3,8 +3,31 @@ namespace Humanizer.Tests.Localisation.de { [UseCulture("de-DE")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "Ein Jahr")] + [InlineData(731, "2 Jahre")] + [InlineData(1096, "3 Jahre")] + [InlineData(4018, "11 Jahre")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "Ein Monat")] + [InlineData(61, "2 Monate")] + [InlineData(92, "3 Monate")] + [InlineData(335, "11 Monate")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "Eine Woche")] [InlineData(14, "2 Wochen")] diff --git a/src/Humanizer.Tests.Shared/Localisation/en/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/en/DateToOrdinalWordsTests.cs new file mode 100644 index 000000000..e1f8eb92a --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/en/DateToOrdinalWordsTests.cs @@ -0,0 +1,22 @@ +using System; +using Xunit; + +namespace Humanizer.Tests.Localisation.en +{ + public class DateToOrdinalWordsTests + { + [UseCulture("en-GB")] + [Fact] + public void OrdinalizeStringGb() + { + Assert.Equal("1st January 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + } + + [UseCulture("en-US")] + [Fact] + public void OrdinalizeStringUs() + { + Assert.Equal("January 1st, 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + } + } +} diff --git a/src/Humanizer.Tests.Shared/Localisation/es/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/es/TimeSpanHumanizeTests.cs index 758496b80..e327a6df6 100644 --- a/src/Humanizer.Tests.Shared/Localisation/es/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/es/TimeSpanHumanizeTests.cs @@ -6,6 +6,27 @@ namespace Humanizer.Tests.Localisation.es [UseCulture("es-ES")] public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "un año")] + [InlineData(731, "2 años")] + [InlineData(1096, "3 años")] + [InlineData(4018, "11 años")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "un mes")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } [Fact] public void TwoWeeks() diff --git a/src/Humanizer.Tests.Shared/Localisation/fa/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/fa/TimeSpanHumanizeTests.cs index cd8e74414..c8362926b 100644 --- a/src/Humanizer.Tests.Shared/Localisation/fa/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/fa/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.fa { [UseCulture("fa")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "یک سال")] + [InlineData(731, "2 سال")] + [InlineData(1096, "3 سال")] + [InlineData(4018, "11 سال")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "یک ماه")] + [InlineData(61, "2 ماه")] + [InlineData(92, "3 ماه")] + [InlineData(335, "11 ماه")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "یک هفته")] [InlineData(77, "11 هفته")] diff --git a/src/Humanizer.Tests.Shared/Localisation/fr-BE/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/fr-BE/TimeSpanHumanizeTests.cs index e34574458..b4925a08f 100644 --- a/src/Humanizer.Tests.Shared/Localisation/fr-BE/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/fr-BE/TimeSpanHumanizeTests.cs @@ -4,12 +4,35 @@ namespace Humanizer.Tests.Localisation.frBE { [UseCulture("fr-BE")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 année")] + [InlineData(731, "2 ans")] + [InlineData(1096, "3 ans")] + [InlineData(4018, "11 ans")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mois")] + [InlineData(61, "2 mois")] + [InlineData(92, "3 mois")] + [InlineData(335, "11 mois")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 semaines")] [InlineData(7, "1 semaine")] - public void Weeks(int days, string expected) + public void Weeks(int days, string expected) { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); @@ -18,7 +41,7 @@ public void Weeks(int days, string expected) [Theory] [InlineData(6, "6 jours")] [InlineData(1, "1 jour")] - public void Days(int days, string expected) + public void Days(int days, string expected) { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); @@ -27,7 +50,7 @@ public void Days(int days, string expected) [Theory] [InlineData(2, "2 heures")] [InlineData(1, "1 heure")] - public void Hours(int hours, string expected) + public void Hours(int hours, string expected) { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); @@ -36,7 +59,7 @@ public void Hours(int hours, string expected) [Theory] [InlineData(2, "2 minutes")] [InlineData(1, "1 minute")] - public void Minutes(int minutes, string expected) + public void Minutes(int minutes, string expected) { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); @@ -45,7 +68,7 @@ public void Minutes(int minutes, string expected) [Theory] [InlineData(2, "2 secondes")] [InlineData(1, "1 seconde")] - public void Seconds(int seconds, string expected) + public void Seconds(int seconds, string expected) { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); @@ -54,14 +77,14 @@ public void Seconds(int seconds, string expected) [Theory] [InlineData(2, "2 millisecondes")] [InlineData(1, "1 milliseconde")] - public void Milliseconds(int ms, string expected) + public void Milliseconds(int ms, string expected) { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } [Fact] - public void NoTime() + public void NoTime() { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(); diff --git a/src/Humanizer.Tests.Shared/Localisation/fr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/fr/TimeSpanHumanizeTests.cs index 12c2514f4..dfda48ad0 100644 --- a/src/Humanizer.Tests.Shared/Localisation/fr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/fr/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.fr { [UseCulture("fr")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [InlineData(366, "1 année")] + [InlineData(731, "2 ans")] + [InlineData(1096, "3 ans")] + [InlineData(4018, "11 ans")] + [Theory] + [Trait("Translation", "Google")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mois")] + [InlineData(61, "2 mois")] + [InlineData(92, "3 mois")] + [InlineData(335, "11 mois")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 semaines")] [InlineData(7, "1 semaine")] diff --git a/src/Humanizer.Tests.Shared/Localisation/he/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/he/TimeSpanHumanizeTests.cs index 21dfcf1a9..f1750fef2 100644 --- a/src/Humanizer.Tests.Shared/Localisation/he/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/he/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.he { [UseCulture("he")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "שנה")] + [InlineData(731, "שנתיים")] + [InlineData(1096, "3 שנים")] + [InlineData(4018, "11 שנים")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "חודש")] + [InlineData(61, "חודשיים")] + [InlineData(92, "3 חודשים")] + [InlineData(335, "11 חודשים")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "שבוע")] [InlineData(14, "שבועיים")] diff --git a/src/Humanizer.Tests.Shared/Localisation/hr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/hr/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..8d58c7ec2 --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/hr/TimeSpanHumanizeTests.cs @@ -0,0 +1,45 @@ +using System; +using Xunit; + +namespace Humanizer.Tests.Localisation.hr +{ + [UseCulture("hr-HR")] + public class TimeSpanHumanizeTests + { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 godina")] + [InlineData(731, "2 godine")] + [InlineData(1096, "3 godine")] + [InlineData(4018, "11 godina")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mjesec")] + [InlineData(61, "2 mjeseca")] + [InlineData(92, "3 mjeseca")] + [InlineData(335, "11 mjeseci")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [InlineData(1, "1 dan")] + [InlineData(2, "2 dana")] + [InlineData(3, "3 dana")] + [InlineData(4, "4 dana")] + [InlineData(5, "5 dana")] + [InlineData(7, "1 tjedan")] + [InlineData(14, "2 tjedna")] + public void Days(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + } +} diff --git a/src/Humanizer.Tests.Shared/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/hu/TimeSpanHumanizeTests.cs index 5f05e1f1a..86b2210df 100644 --- a/src/Humanizer.Tests.Shared/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/hu/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.hu { [UseCulture("hu-HU")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "egy év")] + [InlineData(731, "2 év")] + [InlineData(1096, "3 év")] + [InlineData(4018, "11 év")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "egy hónap")] + [InlineData(61, "2 hónap")] + [InlineData(92, "3 hónap")] + [InlineData(335, "11 hónap")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 hét")] [InlineData(7, "1 hét")] diff --git a/src/Humanizer.Tests.Shared/Localisation/id/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/id/TimeSpanHumanizeTests.cs index 25e10f282..63ebc55e6 100644 --- a/src/Humanizer.Tests.Shared/Localisation/id/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/id/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.id { [UseCulture("id-ID")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 tahun")] + [InlineData(731, "2 tahun")] + [InlineData(1096, "3 tahun")] + [InlineData(4018, "11 tahun")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 bulan")] + [InlineData(61, "2 bulan")] + [InlineData(92, "3 bulan")] + [InlineData(335, "11 bulan")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 minggu")] [InlineData(7, "1 minggu")] diff --git a/src/Humanizer.Tests.Shared/Localisation/it/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/it/TimeSpanHumanizeTests.cs index 0a88ebe2b..bfcfa3c19 100644 --- a/src/Humanizer.Tests.Shared/Localisation/it/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/it/TimeSpanHumanizeTests.cs @@ -4,9 +4,32 @@ namespace Humanizer.Tests.Localisation.it { [UseCulture("it")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 anno")] + [InlineData(731, "2 anni")] + [InlineData(1096, "3 anni")] + [InlineData(4018, "11 anni")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mese")] + [InlineData(61, "2 mesi")] + [InlineData(92, "3 mesi")] + [InlineData(335, "11 mesi")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 settimana")] [InlineData(14, "2 settimane")] diff --git a/src/Humanizer.Tests.Shared/Localisation/ja/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/ja/TimeSpanHumanizeTests.cs index a47829837..db5b3f9f0 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ja/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ja/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.ja { [UseCulture("ja")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 年間の")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ヶ月")] + [InlineData(61, "2 ヶ月")] + [InlineData(92, "3 ヶ月")] + [InlineData(335, "11 ヶ月")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 週間")] [InlineData(14, "2 週間")] diff --git a/src/Humanizer.Tests.Shared/Localisation/nb-NO/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/nb-NO/TimeSpanHumanizeTests.cs index 2681e6157..2c3b57252 100644 --- a/src/Humanizer.Tests.Shared/Localisation/nb-NO/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/nb-NO/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.nbNO { [UseCulture("nb-NO")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "ett år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "en uke")] [InlineData(14, "2 uker")] diff --git a/src/Humanizer.Tests.Shared/Localisation/nb/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/nb/TimeSpanHumanizeTests.cs index 8b267b15b..2f8aab112 100644 --- a/src/Humanizer.Tests.Shared/Localisation/nb/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/nb/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.nb { [UseCulture("nb")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "ett år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "en uke")] [InlineData(14, "2 uker")] diff --git a/src/Humanizer.Tests.Shared/Localisation/nl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/nl/TimeSpanHumanizeTests.cs index 746fbcdf7..8cb748e94 100644 --- a/src/Humanizer.Tests.Shared/Localisation/nl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/nl/TimeSpanHumanizeTests.cs @@ -4,9 +4,32 @@ namespace Humanizer.Tests.Localisation.nl { [UseCulture("nl-NL")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 jaar")] + [InlineData(731, "2 jaar")] + [InlineData(1096, "3 jaar")] + [InlineData(4018, "11 jaar")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 maand")] + [InlineData(61, "2 maanden")] + [InlineData(92, "3 maanden")] + [InlineData(335, "11 maanden")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Fact] public void TwoWeeks() { diff --git a/src/Humanizer.Tests.Shared/Localisation/pl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/pl/TimeSpanHumanizeTests.cs index d87d562c9..1f57e80fc 100644 --- a/src/Humanizer.Tests.Shared/Localisation/pl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/pl/TimeSpanHumanizeTests.cs @@ -4,7 +4,7 @@ namespace Humanizer.Tests.Localisation.pl { [UseCulture("pl")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { [Theory] [InlineData(1, "1 milisekunda")] @@ -82,6 +82,29 @@ public void Weeks(int number, string expected) Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 miesiąc")] + [InlineData(61, "2 miesiące")] + [InlineData(92, "3 miesiące")] + [InlineData(335, "11 miesięcy")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 lata")] + [InlineData(1096, "3 lata")] + [InlineData(4018, "11 lat")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Fact] public void NoTime() { diff --git a/src/Humanizer.Tests.Shared/Localisation/pt-BR/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/pt-BR/TimeSpanHumanizeTests.cs index 13faeb869..156dcada3 100644 --- a/src/Humanizer.Tests.Shared/Localisation/pt-BR/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/pt-BR/TimeSpanHumanizeTests.cs @@ -6,6 +6,29 @@ namespace Humanizer.Tests.Localisation.ptBR [UseCulture("pt-BR")] public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 ano")] + [InlineData(731, "2 anos")] + [InlineData(1096, "3 anos")] + [InlineData(4018, "11 anos")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mês")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Fact] public void TwoWeeks() { diff --git a/src/Humanizer.Tests.Shared/Localisation/pt/OrdinalizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/pt/OrdinalizeTests.cs new file mode 100644 index 000000000..cf45cd8ea --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/pt/OrdinalizeTests.cs @@ -0,0 +1,87 @@ +using Xunit; + +namespace Humanizer.Tests.Localisation.pt +{ + [UseCulture("pt")] + public class OrdinalizeTests + { + + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1º")] + [InlineData("2", "2º")] + [InlineData("3", "3º")] + [InlineData("4", "4º")] + [InlineData("5", "5º")] + [InlineData("6", "6º")] + [InlineData("23", "23º")] + [InlineData("100", "100º")] + [InlineData("101", "101º")] + [InlineData("102", "102º")] + [InlineData("103", "103º")] + [InlineData("1001", "1001º")] + public void OrdinalizeString(string number, string ordinalized) + { + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + } + + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1ª")] + [InlineData("2", "2ª")] + [InlineData("3", "3ª")] + [InlineData("4", "4ª")] + [InlineData("5", "5ª")] + [InlineData("6", "6ª")] + [InlineData("23", "23ª")] + [InlineData("100", "100ª")] + [InlineData("101", "101ª")] + [InlineData("102", "102ª")] + [InlineData("103", "103ª")] + [InlineData("1001", "1001ª")] + public void OrdinalizeStringFeminine(string number, string ordinalized) + { + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + } + + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1º")] + [InlineData(2, "2º")] + [InlineData(3, "3º")] + [InlineData(4, "4º")] + [InlineData(5, "5º")] + [InlineData(6, "6º")] + [InlineData(10, "10º")] + [InlineData(23, "23º")] + [InlineData(100, "100º")] + [InlineData(101, "101º")] + [InlineData(102, "102º")] + [InlineData(103, "103º")] + [InlineData(1001, "1001º")] + public void OrdinalizeNumber(int number, string ordinalized) + { + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + } + + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1ª")] + [InlineData(2, "2ª")] + [InlineData(3, "3ª")] + [InlineData(4, "4ª")] + [InlineData(5, "5ª")] + [InlineData(6, "6ª")] + [InlineData(10, "10ª")] + [InlineData(23, "23ª")] + [InlineData(100, "100ª")] + [InlineData(101, "101ª")] + [InlineData(102, "102ª")] + [InlineData(103, "103ª")] + [InlineData(1001, "1001ª")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) + { + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + } + } +} diff --git a/src/Humanizer.Tests.Shared/Localisation/pt/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/pt/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..54540c10f --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/pt/TimeSpanHumanizeTests.cs @@ -0,0 +1,117 @@ +using System; +using Xunit; + +namespace Humanizer.Tests.Localisation.pt +{ + [UseCulture("pt")] + public class TimeSpanHumanizeTests + { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 ano")] + [InlineData(731, "2 anos")] + [InlineData(1096, "3 anos")] + [InlineData(4018, "11 anos")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mês")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Fact] + public void TwoWeeks() + { + Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); + } + + [Fact] + public void OneWeek() + { + Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); + } + + [Fact] + public void SixDays() + { + Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); + } + + [Fact] + public void TwoDays() + { + Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); + } + + [Fact] + public void OneDay() + { + Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); + } + + [Fact] + public void TwoHours() + { + Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); + } + + [Fact] + public void OneHour() + { + Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); + } + + [Fact] + public void TwoMinutes() + { + Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); + } + + [Fact] + public void OneMinute() + { + Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); + } + + [Fact] + public void TwoSeconds() + { + Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); + } + + [Fact] + public void OneSecond() + { + Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); + } + + [Fact] + public void TwoMilliseconds() + { + Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); + } + + [Fact] + public void OneMillisecond() + { + Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); + } + + [Fact] + public void NoTime() + { + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("sem horário", TimeSpan.Zero.Humanize()); + } + } +} diff --git a/src/Humanizer.Tests.Shared/Localisation/ro-Ro/TimeSpanHumanizerTests.cs b/src/Humanizer.Tests.Shared/Localisation/ro-Ro/TimeSpanHumanizerTests.cs index 194f557d8..7eba8663c 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ro-Ro/TimeSpanHumanizerTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ro-Ro/TimeSpanHumanizerTests.cs @@ -11,7 +11,7 @@ namespace Humanizer.Tests.Localisation.roRO /// There is no test for months since there are only 12 of them in a year. /// [UseCulture("ro-RO")] - public class TimeSpanHumanizerTests + public class TimeSpanHumanizerTests { [Theory] @@ -57,7 +57,7 @@ public void Hours(int hours, string expected) var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - + [Theory] [InlineData(1, "1 zi")] [InlineData(6, "6 zile")] @@ -79,5 +79,28 @@ public void Weeks(int weeks, string expected) var actual = TimeSpan.FromDays(7 * weeks).Humanize(); Assert.Equal(expected, actual); } + + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 luna")] + [InlineData(61, "2 luni")] + [InlineData(92, "3 luni")] + [InlineData(335, "11 luni")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 ani")] + [InlineData(731, "2 ani")] + [InlineData(1096, "3 ani")] + [InlineData(4018, "11 ani")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } } } diff --git a/src/Humanizer.Tests.Shared/Localisation/ru-RU/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/ru-RU/TimeSpanHumanizeTests.cs index 21ed8650b..aa8b2c0ae 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ru-RU/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ru-RU/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.ruRU { [UseCulture("ru-RU")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "один год")] + [InlineData(731, "2 года")] + [InlineData(1096, "3 года")] + [InlineData(4018, "11 лет")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "один месяц")] + [InlineData(61, "2 месяца")] + [InlineData(92, "3 месяца")] + [InlineData(335, "11 месяцев")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "одна неделя")] [InlineData(14, "2 недели")] diff --git a/src/Humanizer.Tests.Shared/Localisation/sk/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/sk/TimeSpanHumanizeTests.cs index 833c9cafb..e6f2acfea 100644 --- a/src/Humanizer.Tests.Shared/Localisation/sk/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/sk/TimeSpanHumanizeTests.cs @@ -7,6 +7,28 @@ namespace Humanizer.Tests.Localisation.sk public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 roky")] + [InlineData(1096, "3 roky")] + [InlineData(4018, "11 rokov")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesiac")] + [InlineData(61, "2 mesiace")] + [InlineData(92, "3 mesiace")] + [InlineData(335, "11 mesiacov")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(1, "1 milisekunda")] [InlineData(2, "2 milisekundy")] @@ -16,7 +38,7 @@ public class TimeSpanHumanizeTests [InlineData(6, "6 milisekúnd")] [InlineData(10, "10 milisekúnd")] public void Milliseconds(int number, string expected) - { + { Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); } @@ -29,7 +51,7 @@ public void Milliseconds(int number, string expected) [InlineData(6, "6 sekúnd")] [InlineData(10, "10 sekúnd")] public void Seconds(int number, string expected) - { + { Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); } @@ -55,7 +77,7 @@ public void Minutes(int number, string expected) [InlineData(6, "6 hodín")] [InlineData(10, "10 hodín")] public void Hours(int number, string expected) - { + { Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); } @@ -67,7 +89,7 @@ public void Hours(int number, string expected) [InlineData(5, "5 dní")] [InlineData(6, "6 dní")] public void Days(int number, string expected) - { + { Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); } diff --git a/src/Humanizer.Tests.Shared/Localisation/sl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/sl/TimeSpanHumanizeTests.cs index 78dad0c0a..3909946dc 100644 --- a/src/Humanizer.Tests.Shared/Localisation/sl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/sl/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.sl { [UseCulture("sl-SI")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 leto")] + [InlineData(731, "2 leti")] + [InlineData(1096, "3 leta")] + [InlineData(4018, "11 let")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesec")] + [InlineData(61, "2 meseca")] + [InlineData(92, "3 mesece")] + [InlineData(335, "11 mesecev")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 teden")] [InlineData(14, "2 tedna")] diff --git a/src/Humanizer.Tests.Shared/Localisation/sr-Latn/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/sr-Latn/TimeSpanHumanizeTests.cs index 94af4be25..d3797dc4d 100644 --- a/src/Humanizer.Tests.Shared/Localisation/sr-Latn/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/sr-Latn/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.srLatn { [UseCulture("sr-Latn")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 godina")] + [InlineData(731, "2 godine")] + [InlineData(1096, "3 godine")] + [InlineData(4018, "11 godina")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesec")] + [InlineData(61, "2 meseca")] + [InlineData(92, "3 meseca")] + [InlineData(335, "11 meseci")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(35, "5 nedelja")] [InlineData(14, "2 nedelje")] diff --git a/src/Humanizer.Tests.Shared/Localisation/sr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/sr/TimeSpanHumanizeTests.cs index f47dec099..283498594 100644 --- a/src/Humanizer.Tests.Shared/Localisation/sr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/sr/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.sr { [UseCulture("sr")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 година")] + [InlineData(731, "2 године")] + [InlineData(1096, "3 године")] + [InlineData(4018, "11 година")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 месец")] + [InlineData(61, "2 месеца")] + [InlineData(92, "3 месеца")] + [InlineData(335, "11 месеци")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(35, "5 недеља")] [InlineData(14, "2 недеље")] diff --git a/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs b/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs new file mode 100644 index 000000000..f36619a8b --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using Xunit; + +namespace Humanizer.Tests.Localisation.sv +{ + [UseCulture("sv-SE")] + public class CollectionFormatterTests + { + [Fact] + public void MoreThanTwoItems() + { + var collection = new List(new[] {1, 2, 3}); + var humanized = "1, 2 och 3"; + Assert.Equal(humanized, collection.Humanize()); + } + + [Fact] + public void OneItem() + { + var collection = new List(new[] {1}); + var humanized = "1"; + Assert.Equal(humanized, collection.Humanize()); + } + + [Fact] + public void TwoItems() + { + var collection = new List(new[] {1, 2}); + var humanized = "1 och 2"; + Assert.Equal(humanized, collection.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer.Tests.Shared/Localisation/sv/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/sv/TimeSpanHumanizeTests.cs index 123e0fdf7..da70eab51 100644 --- a/src/Humanizer.Tests.Shared/Localisation/sv/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/sv/TimeSpanHumanizeTests.cs @@ -54,5 +54,28 @@ public void Weeks(int number, string expected) { Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); } + + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en månad")] + [InlineData(61, "2 månader")] + [InlineData(92, "3 månader")] + [InlineData(335, "11 månader")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "ett år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } } } diff --git a/src/Humanizer.Tests.Shared/Localisation/tr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/tr/TimeSpanHumanizeTests.cs index 732442ea8..cbce3d31b 100644 --- a/src/Humanizer.Tests.Shared/Localisation/tr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/tr/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.tr { [UseCulture("tr")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 yıl")] + [InlineData(731, "2 yıl")] + [InlineData(1096, "3 yıl")] + [InlineData(4018, "11 yıl")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ay")] + [InlineData(61, "2 ay")] + [InlineData(92, "3 ay")] + [InlineData(335, "11 ay")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 hafta")] [InlineData(7, "1 hafta")] diff --git a/src/Humanizer.Tests.Shared/Localisation/uk-UA/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/uk-UA/TimeSpanHumanizeTests.cs index 40d6ebc91..02432c9fe 100644 --- a/src/Humanizer.Tests.Shared/Localisation/uk-UA/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/uk-UA/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.ukUA { [UseCulture("uk-UA")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "один рік")] + [InlineData(731, "2 роки")] + [InlineData(1096, "3 роки")] + [InlineData(4018, "11 років")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "один місяць")] + [InlineData(61, "2 місяці")] + [InlineData(92, "3 місяці")] + [InlineData(335, "11 місяців")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "один тиждень")] [InlineData(14, "2 тижні")] diff --git a/src/Humanizer.Tests.Shared/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs index 2283b1aab..b9cf5873b 100644 --- a/src/Humanizer.Tests.Shared/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs @@ -4,8 +4,32 @@ namespace Humanizer.Tests.Localisation.uzCyrl { [UseCulture("uz-Cyrl-UZ")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 йил")] + [InlineData(731, "2 йил")] + [InlineData(1096, "3 йил")] + [InlineData(4018, "11 йил")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ой")] + [InlineData(61, "2 ой")] + [InlineData(92, "3 ой")] + [InlineData(335, "11 ой")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 ҳафта")] [InlineData(7, "1 ҳафта")] diff --git a/src/Humanizer.Tests.Shared/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs index 735bff718..f4e6638a2 100644 --- a/src/Humanizer.Tests.Shared/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.uzLatn { [UseCulture("uz-Latn-UZ")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { - + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 yil")] + [InlineData(731, "2 yil")] + [InlineData(1096, "3 yil")] + [InlineData(4018, "11 yil")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 oy")] + [InlineData(61, "2 oy")] + [InlineData(92, "3 oy")] + [InlineData(335, "11 oy")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 hafta")] [InlineData(7, "1 hafta")] diff --git a/src/Humanizer.Tests.Shared/Localisation/vi/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/vi/TimeSpanHumanizeTests.cs index 2825f9969..02c331222 100644 --- a/src/Humanizer.Tests.Shared/Localisation/vi/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/vi/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.vi { [UseCulture("vi")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 năm")] + [InlineData(731, "2 năm")] + [InlineData(1096, "3 năm")] + [InlineData(4018, "11 năm")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 tháng")] + [InlineData(61, "2 tháng")] + [InlineData(92, "3 tháng")] + [InlineData(335, "11 tháng")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(14, "2 tuần")] [InlineData(7, "1 tuần")] diff --git a/src/Humanizer.Tests.Shared/Localisation/zh-CN/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/zh-CN/TimeSpanHumanizeTests.cs index c1317d653..ed9b60dd0 100644 --- a/src/Humanizer.Tests.Shared/Localisation/zh-CN/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/zh-CN/TimeSpanHumanizeTests.cs @@ -4,8 +4,31 @@ namespace Humanizer.Tests.Localisation.zhCN { [UseCulture("zh-CN")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 个月")] + [InlineData(61, "2 个月")] + [InlineData(92, "3 个月")] + [InlineData(335, "11 个月")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 周")] [InlineData(14, "2 周")] diff --git a/src/Humanizer.Tests.Shared/Localisation/zh-Hans/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/zh-Hans/TimeSpanHumanizeTests.cs index 83c1582b6..f85c67dcb 100644 --- a/src/Humanizer.Tests.Shared/Localisation/zh-Hans/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/zh-Hans/TimeSpanHumanizeTests.cs @@ -4,9 +4,31 @@ namespace Humanizer.Tests.Localisation.zhHans { [UseCulture("zh-Hans")] - public class TimeSpanHumanizeTests + public class TimeSpanHumanizeTests { + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 个月")] + [InlineData(61, "2 个月")] + [InlineData(92, "3 个月")] + [InlineData(335, "11 个月")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 周")] [InlineData(14, "2 周")] diff --git a/src/Humanizer.Tests.Shared/Localisation/zh-Hant/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/Localisation/zh-Hant/TimeSpanHumanizeTests.cs index 241e833a2..2bee5a24f 100644 --- a/src/Humanizer.Tests.Shared/Localisation/zh-Hant/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/zh-Hant/TimeSpanHumanizeTests.cs @@ -6,6 +6,30 @@ namespace Humanizer.Tests.Localisation.zhHant [UseCulture("zh-Hant")] public class TimeSpanHumanizeTests { + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 個月")] + [InlineData(61, "2 個月")] + [InlineData(92, "3 個月")] + [InlineData(335, "11 個月")] + public void Months(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year)); + } + [Theory] [InlineData(7, "1 周")] [InlineData(14, "2 周")] diff --git a/src/Humanizer.Tests.Shared/MetricNumeralTests.cs b/src/Humanizer.Tests.Shared/MetricNumeralTests.cs index bd4021077..c0410eebd 100644 --- a/src/Humanizer.Tests.Shared/MetricNumeralTests.cs +++ b/src/Humanizer.Tests.Shared/MetricNumeralTests.cs @@ -88,18 +88,25 @@ public void TestAllSymbolsAsInt(int exponent) } [Theory] - [InlineData("0", 0d, false, true)] - [InlineData("123", 123d, false, true)] - [InlineData("-123", (-123d), false, true)] - [InlineData("1.23k", 1230d, false, true)] - [InlineData("1 k", 1000d, true, true)] - [InlineData("1 kilo", 1000d, true, false)] - [InlineData("1milli", 1E-3, false, false)] - public void ToMetric(string expected, double input, bool hasSpace, bool useSymbol) + [InlineData("0", 0d, false, true, null)] + [InlineData("123", 123d, false, true, null)] + [InlineData("-123", (-123d), false, true, null)] + [InlineData("1.23k", 1230d, false, true, null)] + [InlineData("1 k", 1000d, true, true, null)] + [InlineData("1 kilo", 1000d, true, false, null)] + [InlineData("1milli", 1E-3, false, false, null)] + [InlineData("1milli", 1E-3, false, false, null)] + [InlineData("1.23milli", 1.234E-3, false, false, 2)] + [InlineData("12.34k", 12345, false, true, 2)] + [InlineData("12k", 12345, false, true, 0)] + [InlineData("-3.9m", -3.91e-3, false, true, 1)] + public void ToMetric(string expected, double input, bool hasSpace, bool useSymbol, int? decimals) { - Assert.Equal(expected, input.ToMetric(hasSpace, useSymbol)); + Assert.Equal(expected, input.ToMetric(hasSpace, useSymbol, decimals)); } + + [Theory] [InlineData(1E+27)] [InlineData(1E-27)] diff --git a/src/Humanizer.Tests.Shared/NumberToWordsTests.cs b/src/Humanizer.Tests.Shared/NumberToWordsTests.cs index 999d1a036..634019c5d 100644 --- a/src/Humanizer.Tests.Shared/NumberToWordsTests.cs +++ b/src/Humanizer.Tests.Shared/NumberToWordsTests.cs @@ -35,7 +35,32 @@ public class NumberToWordsTests [InlineData(123456789, "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine")] [InlineData(1234567890, "one billion two hundred and thirty-four million five hundred and sixty-seven thousand eight hundred and ninety")] [Theory] - public void ToWords(int number, string expected) + public void ToWordsInt(int number, string expected) + { + Assert.Equal(expected, number.ToWords()); + } + + [InlineData(1L, "one")] + [InlineData(11L, "eleven")] + [InlineData(111L, "one hundred and eleven")] + [InlineData(1111L, "one thousand one hundred and eleven")] + [InlineData(11111L, "eleven thousand one hundred and eleven")] + [InlineData(111111L, "one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111L, "one million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111L, "eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111L, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111L, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111L, "eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111L, "one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111L, "one trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111111L, "eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111111L, "one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111111L, "one quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111111111L, "eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111111111L, "one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111111111L, "one quintillion one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [Theory] + public void ToWordsLong(long number, string expected) { Assert.Equal(expected, number.ToWords()); } diff --git a/src/Humanizer.Tests.Shared/StringHumanizeTests.cs b/src/Humanizer.Tests.Shared/StringHumanizeTests.cs index ba05d6b6c..ae8656d08 100644 --- a/src/Humanizer.Tests.Shared/StringHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/StringHumanizeTests.cs @@ -32,6 +32,13 @@ public void CanHumanizeStringInPascalCaseInTurkish(string input, string expected Assert.Equal(expectedResult, input.Humanize()); } + [Theory, UseCulture("ar")] + [InlineData("جمهورية ألمانيا الاتحادية", "جمهورية ألمانيا الاتحادية")] + public void CanHumanizeOtherUnicodeLetter(string input, string expectedResult) + { + Assert.Equal(expectedResult, input.Humanize()); + } + [Theory] [InlineData("Underscored_input_string_is_turned_into_sentence", "Underscored input string is turned into sentence")] [InlineData("Underscored_input_String_is_turned_INTO_sentence", "Underscored input String is turned INTO sentence")] diff --git a/src/Humanizer.Tests.Shared/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests.Shared/TimeSpanHumanizeTests.cs index 9eadfb056..ecaa11fb7 100644 --- a/src/Humanizer.Tests.Shared/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/TimeSpanHumanizeTests.cs @@ -2,17 +2,70 @@ using System.Globalization; using Humanizer.Localisation; using Xunit; +using System.Linq; namespace Humanizer.Tests { [UseCulture("en-US")] public class TimeSpanHumanizeTests { + [Fact] + public void AllTimeSpansMustBeUniqueForASequenceOfDays() + { + var culture = new CultureInfo("en-US"); + var qry = from i in Enumerable.Range(0, 100000) + let ts = TimeSpan.FromDays(i) + let text = ts.Humanize(precision: 3, culture: culture, maxUnit: TimeUnit.Year) + select text; + var grouping = from t in qry + group t by t into g + select new { Key = g.Key, Count = g.Count() }; + var allUnique = grouping.All(g => g.Count == 1); + Assert.True(allUnique); + } + + [Theory] + [InlineData(365, "11 months, 30 days")] + [InlineData(365 + 1, "1 year")] + [InlineData(365 + 365, "1 year, 11 months, 29 days")] + [InlineData(365 + 365 + 1, "2 years")] + [InlineData(365 + 365 + 365, "2 years, 11 months, 29 days")] + [InlineData(365 + 365 + 365 + 1, "3 years")] + [InlineData(365 + 365 + 365 + 365, "3 years, 11 months, 29 days")] + [InlineData(365 + 365 + 365 + 365 + 1, "4 years")] + [InlineData(365 + 365 + 365 + 365 + 366, "4 years, 11 months, 30 days")] + [InlineData(365 + 365 + 365 + 365 + 366 + 1, "5 years")] + public void Year(int days, string expected) + { + string actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(30, "4 weeks, 2 days")] + [InlineData(30 + 1, "1 month")] + [InlineData(30 + 30, "1 month, 29 days")] + [InlineData(30 + 30 + 1, "2 months")] + [InlineData(30 + 30 + 31, "2 months, 30 days")] + [InlineData(30 + 30 + 31 + 1, "3 months")] + [InlineData(30 + 30 + 31 + 30, "3 months, 29 days")] + [InlineData(30 + 30 + 31 + 30 + 1, "4 months")] + [InlineData(30 + 30 + 31 + 30 + 31, "4 months, 30 days")] + [InlineData(30 + 30 + 31 + 30 + 31 + 1, "5 months")] + [InlineData(365, "11 months, 30 days")] + [InlineData(366, "1 year")] + public void Month(int days, string expected) + { + string actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } + [Theory] [InlineData(14, "2 weeks")] [InlineData(7, "1 week")] [InlineData(-14, "2 weeks")] [InlineData(-7, "1 week")] + [InlineData(730, "104 weeks")] public void Weeks(int days, string expected) { var actual = TimeSpan.FromDays(days).Humanize(); @@ -86,12 +139,14 @@ public void Milliseconds(int ms, string expected) } [Theory] + [InlineData((long)366 * 24 * 60 * 60 * 1000, "12 months", TimeUnit.Month)] + [InlineData((long)6 * 7 * 24 * 60 * 60 * 1000, "6 weeks", TimeUnit.Week)] [InlineData(7 * 24 * 60 * 60 * 1000, "7 days", TimeUnit.Day)] [InlineData(24 * 60 * 60 * 1000, "24 hours", TimeUnit.Hour)] [InlineData(60 * 60 * 1000, "60 minutes", TimeUnit.Minute)] [InlineData(60 * 1000, "60 seconds", TimeUnit.Second)] [InlineData(1000, "1000 milliseconds", TimeUnit.Millisecond)] - public void TimeSpanWithMaxTimeUnit(int ms, string expected, TimeUnit maxUnit) + public void TimeSpanWithMaxTimeUnit(long ms, string expected, TimeUnit maxUnit) { var actual = TimeSpan.FromMilliseconds(ms).Humanize(maxUnit: maxUnit); Assert.Equal(expected, actual); @@ -134,9 +189,25 @@ public void TimeSpanWithMaxTimeUnit(int ms, string expected, TimeUnit maxUnit) [InlineData(694922500, "1 week, 1 day, 1 hour", TimeUnit.Hour)] [InlineData(694922500, "1 week, 1 day", TimeUnit.Day)] [InlineData(694922500, "1 week", TimeUnit.Week)] - public void TimeSpanWithMinTimeUnit(int ms, string expected, TimeUnit minUnit) + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute", TimeUnit.Minute)] + [InlineData(2768462500, "1 month, 1 day, 1 hour", TimeUnit.Hour)] + [InlineData(2768462500, "1 month, 1 day", TimeUnit.Day)] + [InlineData(2768462500, "1 month", TimeUnit.Week)] + [InlineData(2768462500, "1 month", TimeUnit.Month)] + [InlineData(2768462500, "no time", TimeUnit.Year)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute", TimeUnit.Minute)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour", TimeUnit.Hour)] + [InlineData(34390862500, "1 year, 1 month, 2 days", TimeUnit.Day)] + [InlineData(34390862500, "1 year, 1 month", TimeUnit.Week)] + [InlineData(34390862500, "1 year, 1 month", TimeUnit.Month)] + [InlineData(34390862500, "1 year", TimeUnit.Year)] + public void TimeSpanWithMinTimeUnit(long ms, string expected, TimeUnit minUnit) { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 6); + var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 7, maxUnit: TimeUnit.Year); Assert.Equal(expected, actual); } @@ -170,9 +241,22 @@ public void TimeSpanWithMinTimeUnit(int ms, string expected, TimeUnit minUnit) [InlineData(1299630020, 3, "2 weeks, 1 day, 1 hour")] [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour, 30 seconds")] [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds, 20 milliseconds")] - public void TimeSpanWithPrecision(int milliseconds, int precision, string expected) + [InlineData(2768462500, 6, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] + [InlineData(2768462500, 5, "1 month, 1 day, 1 hour, 1 minute, 2 seconds")] + [InlineData(2768462500, 4, "1 month, 1 day, 1 hour, 1 minute")] + [InlineData(2768462500, 3, "1 month, 1 day, 1 hour")] + [InlineData(2768462500, 2, "1 month, 1 day")] + [InlineData(2768462500, 1, "1 month")] + [InlineData(34390862500, 7, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] + [InlineData(34390862500, 6, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds")] + [InlineData(34390862500, 5, "1 year, 1 month, 2 days, 1 hour, 1 minute")] + [InlineData(34390862500, 4, "1 year, 1 month, 2 days, 1 hour")] + [InlineData(34390862500, 3, "1 year, 1 month, 2 days")] + [InlineData(34390862500, 2, "1 year, 1 month")] + [InlineData(34390862500, 1, "1 year")] + public void TimeSpanWithPrecision(long milliseconds, int precision, string expected) { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision); + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, maxUnit: TimeUnit.Year); Assert.Equal(expected, actual); } diff --git a/src/Humanizer.Tests.Shared/ToQuantityTests.cs b/src/Humanizer.Tests.Shared/ToQuantityTests.cs index a2c41e2b6..a85c2909d 100644 --- a/src/Humanizer.Tests.Shared/ToQuantityTests.cs +++ b/src/Humanizer.Tests.Shared/ToQuantityTests.cs @@ -23,6 +23,7 @@ public class ToQuantityTests public void ToQuantity(string word, int quantity, string expected) { Assert.Equal(expected, word.ToQuantity(quantity)); + Assert.Equal(expected, word.ToQuantity((long)quantity)); } [Theory] @@ -40,6 +41,7 @@ public void ToQuantity(string word, int quantity, string expected) public void ToQuantityWithNoQuantity(string word, int quantity, string expected) { Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.None)); + Assert.Equal(expected, word.ToQuantity((long)quantity, ShowQuantityAs.None)); } [Theory] @@ -58,6 +60,7 @@ public void ToQuantityNumeric(string word, int quantity, string expected) { // ReSharper disable once RedundantArgumentDefaultValue Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Numeric)); + Assert.Equal(expected, word.ToQuantity((long)quantity, ShowQuantityAs.Numeric)); } [Theory] @@ -76,6 +79,7 @@ public void ToQuantityNumeric(string word, int quantity, string expected) public void ToQuantityWords(string word, int quantity, string expected) { Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Words)); + Assert.Equal(expected, word.ToQuantity((long)quantity, ShowQuantityAs.Words)); } [Theory] @@ -93,6 +97,7 @@ public void ToQuantityWords(string word, int quantity, string expected) public void ToQuantityWordsWithCurrentCultureFormatting(string word, int quantity, string format, string expected) { Assert.Equal(expected, word.ToQuantity(quantity, format)); + Assert.Equal(expected, word.ToQuantity((long)quantity, format)); } [Theory] @@ -110,6 +115,7 @@ public void ToQuantityWordsWithCustomCultureFormatting(string word, int quantity var culture = new CultureInfo(cultureCode); Assert.Equal(expected, word.ToQuantity(quantity, format, culture), GetStringComparer(culture)); + Assert.Equal(expected, word.ToQuantity((long)quantity, format, culture), GetStringComparer(culture)); } internal static StringComparer GetStringComparer(CultureInfo culture) diff --git a/src/Humanizer.Tests.Uwp.Runner/project.json b/src/Humanizer.Tests.Uwp.Runner/project.json index eea13f7b8..8b187074e 100644 --- a/src/Humanizer.Tests.Uwp.Runner/project.json +++ b/src/Humanizer.Tests.Uwp.Runner/project.json @@ -1,8 +1,8 @@ { "dependencies": { - "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.0", - "xunit": "2.1.0", - "xunit.runner.devices": "1.3.2" + "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.3", + "xunit": "2.3.0-beta1-build3642", + "xunit.runner.devices": "2.2.0-rc1" }, "frameworks": { "uap10.0": {} @@ -15,4 +15,4 @@ "win10-x64": {}, "win10-x64-aot": {} } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests.Uwp/project.json b/src/Humanizer.Tests.Uwp/project.json index fb7e14ea8..5b4958e72 100644 --- a/src/Humanizer.Tests.Uwp/project.json +++ b/src/Humanizer.Tests.Uwp/project.json @@ -1,8 +1,8 @@ { "dependencies": { - "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.0", - "xunit": "2.1.0", - "xunit.runner.visualstudio": "2.1.0" + "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.3", + "xunit": "2.3.0-beta1-build3642", + "xunit.runner.visualstudio": "2.3.0-beta1-build1309" }, "frameworks": { "uap10.0": {} @@ -15,4 +15,4 @@ "win10-x64": {}, "win10-x64-aot": {} } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt index e2427e5c4..6cd8bc19b 100644 --- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt +++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt @@ -1,5 +1,5 @@ [assembly: System.Resources.NeutralResourcesLanguageAttribute("en")] -[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETPortable,Version=v5.0", FrameworkDisplayName=".NET Portable Subset")] +[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v1.0", FrameworkDisplayName="")] namespace Humanizer.Bytes { @@ -134,6 +134,11 @@ namespace Humanizer public static string Humanize(this System.DateTimeOffset input, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } public static string Humanize(this System.Nullable input, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } } + public class static DateToOrdinalWordsExtensions + { + public static string ToOrdinalWords(this System.DateTime input) { } + public static string ToOrdinalWords(this System.DateTime input, Humanizer.GrammaticalCase grammaticalCase) { } + } public class static EnumDehumanizeExtensions { public static TTargetEnum DehumanizeTo(this string input) @@ -364,6 +369,7 @@ namespace Humanizer public static string Camelize(this string input) { } public static string Dasherize(this string underscoredWord) { } public static string Hyphenate(this string underscoredWord) { } + public static string Kebaberize(this string input) { } public static string Pascalize(this string input) { } public static string Pluralize(this string word, bool inputIsKnownToBeSingular = True) { } public static string Singularize(this string word, bool inputIsKnownToBePlural = True) { } @@ -388,8 +394,8 @@ namespace Humanizer public class static MetricNumeralExtensions { public static double FromMetric(this string input) { } - public static string ToMetric(this int input, bool hasSpace = False, bool useSymbol = True) { } - public static string ToMetric(this double input, bool hasSpace = False, bool useSymbol = True) { } + public static string ToMetric(this int input, bool hasSpace = False, bool useSymbol = True, System.Nullable decimals = null) { } + public static string ToMetric(this double input, bool hasSpace = False, bool useSymbol = True, System.Nullable decimals = null) { } } public class NoMatchFoundException : System.Exception { @@ -488,6 +494,8 @@ namespace Humanizer public static string ToOrdinalWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo culture = null) { } public static string ToWords(this int number, System.Globalization.CultureInfo culture = null) { } public static string ToWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo culture = null) { } + public static string ToWords(this long number, System.Globalization.CultureInfo culture = null) { } + public static string ToWords(this long number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo culture = null) { } } public class On { @@ -986,6 +994,8 @@ namespace Humanizer { public static string ToQuantity(this string input, int quantity, Humanizer.ShowQuantityAs showQuantityAs = 1) { } public static string ToQuantity(this string input, int quantity, string format, System.IFormatProvider formatProvider = null) { } + public static string ToQuantity(this string input, long quantity, Humanizer.ShowQuantityAs showQuantityAs = 1) { } + public static string ToQuantity(this string input, long quantity, string format, System.IFormatProvider formatProvider = null) { } } public class static TruncateExtensions { @@ -1014,6 +1024,7 @@ namespace Humanizer.Configuration public static Humanizer.Configuration.LocaliserRegistry CollectionFormatters { get; } public static Humanizer.DateTimeHumanizeStrategy.IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } public static Humanizer.DateTimeHumanizeStrategy.IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy { get; set; } + public static Humanizer.Configuration.LocaliserRegistry DateToOrdinalWordsConverters { get; } public static System.Func EnumDescriptionPropertyLocator { get; set; } public static Humanizer.Configuration.LocaliserRegistry Formatters { get; } public static Humanizer.Configuration.LocaliserRegistry NumberToWordsConverters { get; } @@ -1090,6 +1101,15 @@ namespace Humanizer.Localisation.CollectionFormatters string Humanize(System.Collections.Generic.IEnumerable collection, System.Func objectFormatter, string separator); } } +namespace Humanizer.Localisation.DateToOrdinalWords +{ + + public interface IDateToOrdinalWordConverter + { + string Convert(System.DateTime date); + string Convert(System.DateTime date, Humanizer.GrammaticalCase grammaticalCase); + } +} namespace Humanizer.Localisation.Formatters { @@ -1120,8 +1140,8 @@ namespace Humanizer.Localisation.NumberToWords public interface INumberToWordsConverter { - string Convert(int number); - string Convert(int number, Humanizer.GrammaticalGender gender); + string Convert(long number); + string Convert(long number, Humanizer.GrammaticalGender gender); string ConvertToOrdinal(int number); string ConvertToOrdinal(int number, Humanizer.GrammaticalGender gender); } diff --git a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.cs b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.cs index 618614002..cd5bf39ca 100644 --- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.cs +++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.cs @@ -1,4 +1,5 @@ -using System.IO; +#if NET46 +using System.IO; using ApiApprover; using ApprovalTests; using ApprovalTests.Reporters; @@ -7,6 +8,7 @@ namespace Humanizer.Tests.ApiApprover { + public class PublicApiApprovalTest { [Fact] @@ -31,4 +33,5 @@ public void approve_public_api() Approvals.Verify(publicApi); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiApprover.cs b/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiApprover.cs index cc17e6ca9..e6fc8e78f 100644 --- a/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiApprover.cs +++ b/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiApprover.cs @@ -1,4 +1,5 @@ -using System.IO; +#if NET46 +using System.IO; using ApprovalTests; using ApprovalTests.Namers; using Mono.Cecil; @@ -40,4 +41,5 @@ public override string Name } } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiGenerator.cs b/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiGenerator.cs index 424d5db44..c9c95e0d6 100644 --- a/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiGenerator.cs +++ b/src/Humanizer.Tests/App_Packages/ApiApprover.3.0.1/PublicApiGenerator.cs @@ -1,4 +1,5 @@ -using System; +#if NET46 +using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -792,3 +793,4 @@ private static CodeTypeReference[] CreateGenericArguments(TypeReference type) } // ReSharper restore BitwiseOperatorOnEnumWihtoutFlags // ReSharper restore CheckNamespace +#endif \ No newline at end of file diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index d458af31e..b10ec2e3f 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -1,84 +1,32 @@ - - + - Debug - AnyCPU - 8.0.30703 - 2.0 - {F886A8DA-3EFC-4A89-91DD-06FAF13DA172} - Library - Properties - Humanizer.Tests - Humanizer.Tests - v4.6 - 512 - ..\ - true + net46;netcoreapp1.1 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false + + + $(DefineConstants);NETFX_CORE - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - ..\Humanizer.ruleset - true - false - - - - - - - - - - - - - - + + + + + + + + + + PreserveNewest - - {511a7984-f455-4a6e-adb9-9caac47ea079} - Humanizer - - - - - - - - - - + + - - + diff --git a/src/Humanizer.Tests/Properties/AssemblyInfo.cs b/src/Humanizer.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 6bcb7b913..000000000 --- a/src/Humanizer.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Humanizer.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Humanizer.Tests")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("41e937d9-52d0-410d-9923-954cbb461dd1")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Humanizer.Tests/project.json b/src/Humanizer.Tests/project.json deleted file mode 100644 index 92931a999..000000000 --- a/src/Humanizer.Tests/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "dependencies": { - "ApiApprover": "3.0.1", - "ApprovalTests": "3.0.10", - "ApprovalUtilities": "3.0.10", - "Mono.Cecil": "0.9.6.1", - "xunit": "2.1.0", - "xunit.runner.visualstudio": "2.1.0" - }, - "frameworks": { - "net46": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/src/Humanizer.sln b/src/Humanizer.sln index a97dc68a1..0111bf446 100644 --- a/src/Humanizer.sln +++ b/src/Humanizer.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Humanizer.Tests", "Humanizer.Tests\Humanizer.Tests.csproj", "{F886A8DA-3EFC-4A89-91DD-06FAF13DA172}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Humanizer.Tests", "Humanizer.Tests\Humanizer.Tests.csproj", "{F886A8DA-3EFC-4A89-91DD-06FAF13DA172}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Humanizer", "Humanizer\Humanizer.csproj", "{511A7984-F455-4A6E-ADB9-9CAAC47EA079}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Humanizer", "Humanizer\Humanizer.csproj", "{511A7984-F455-4A6E-ADB9-9CAAC47EA079}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4779A7C9-9ED8-4146-A158-FBE0B1BE09D9}" ProjectSection(SolutionItems) = preProject @@ -37,7 +37,51 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{04B74BEC EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Humanizer.Tests.Uwp.Runner", "Humanizer.Tests.Uwp.Runner\Humanizer.Tests.Uwp.Runner.csproj", "{F0DC7771-CE59-4F3C-B160-56F661F5D220}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Humanizer.Tests.DotNet", "Humanizer.Tests.DotNet\Humanizer.Tests.DotNet.xproj", "{50D97972-236C-46A0-B912-1310CE636569}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuSpecs", "NuSpecs", "{AA449265-E001-486D-A0F4-04ACF0C83DC1}" + ProjectSection(SolutionItems) = preProject + ..\NuSpecs\Humanizer.Core.af.nuspec = ..\NuSpecs\Humanizer.Core.af.nuspec + ..\NuSpecs\Humanizer.Core.ar.nuspec = ..\NuSpecs\Humanizer.Core.ar.nuspec + ..\NuSpecs\Humanizer.Core.bg.nuspec = ..\NuSpecs\Humanizer.Core.bg.nuspec + ..\NuSpecs\Humanizer.Core.bn-BD.nuspec = ..\NuSpecs\Humanizer.Core.bn-BD.nuspec + ..\NuSpecs\Humanizer.Core.cs.nuspec = ..\NuSpecs\Humanizer.Core.cs.nuspec + ..\NuSpecs\Humanizer.Core.da.nuspec = ..\NuSpecs\Humanizer.Core.da.nuspec + ..\NuSpecs\Humanizer.Core.de.nuspec = ..\NuSpecs\Humanizer.Core.de.nuspec + ..\NuSpecs\Humanizer.Core.el.nuspec = ..\NuSpecs\Humanizer.Core.el.nuspec + ..\NuSpecs\Humanizer.Core.es.nuspec = ..\NuSpecs\Humanizer.Core.es.nuspec + ..\NuSpecs\Humanizer.Core.fa.nuspec = ..\NuSpecs\Humanizer.Core.fa.nuspec + ..\NuSpecs\Humanizer.Core.fi-FI.nuspec = ..\NuSpecs\Humanizer.Core.fi-FI.nuspec + ..\NuSpecs\Humanizer.Core.fr-BE.nuspec = ..\NuSpecs\Humanizer.Core.fr-BE.nuspec + ..\NuSpecs\Humanizer.Core.fr.nuspec = ..\NuSpecs\Humanizer.Core.fr.nuspec + ..\NuSpecs\Humanizer.Core.he.nuspec = ..\NuSpecs\Humanizer.Core.he.nuspec + ..\NuSpecs\Humanizer.Core.hr.nuspec = ..\NuSpecs\Humanizer.Core.hr.nuspec + ..\NuSpecs\Humanizer.Core.hu.nuspec = ..\NuSpecs\Humanizer.Core.hu.nuspec + ..\NuSpecs\Humanizer.Core.id.nuspec = ..\NuSpecs\Humanizer.Core.id.nuspec + ..\NuSpecs\Humanizer.Core.it.nuspec = ..\NuSpecs\Humanizer.Core.it.nuspec + ..\NuSpecs\Humanizer.Core.ja.nuspec = ..\NuSpecs\Humanizer.Core.ja.nuspec + ..\NuSpecs\Humanizer.Core.lv.nuspec = ..\NuSpecs\Humanizer.Core.lv.nuspec + ..\NuSpecs\Humanizer.Core.nb-NO.nuspec = ..\NuSpecs\Humanizer.Core.nb-NO.nuspec + ..\NuSpecs\Humanizer.Core.nb.nuspec = ..\NuSpecs\Humanizer.Core.nb.nuspec + ..\NuSpecs\Humanizer.Core.nl.nuspec = ..\NuSpecs\Humanizer.Core.nl.nuspec + ..\NuSpecs\Humanizer.Core.nuspec = ..\NuSpecs\Humanizer.Core.nuspec + ..\NuSpecs\Humanizer.Core.pl.nuspec = ..\NuSpecs\Humanizer.Core.pl.nuspec + ..\NuSpecs\Humanizer.Core.pt.nuspec = ..\NuSpecs\Humanizer.Core.pt.nuspec + ..\NuSpecs\Humanizer.Core.ro.nuspec = ..\NuSpecs\Humanizer.Core.ro.nuspec + ..\NuSpecs\Humanizer.Core.ru.nuspec = ..\NuSpecs\Humanizer.Core.ru.nuspec + ..\NuSpecs\Humanizer.Core.sk.nuspec = ..\NuSpecs\Humanizer.Core.sk.nuspec + ..\NuSpecs\Humanizer.Core.sl.nuspec = ..\NuSpecs\Humanizer.Core.sl.nuspec + ..\NuSpecs\Humanizer.Core.sr-Latn.nuspec = ..\NuSpecs\Humanizer.Core.sr-Latn.nuspec + ..\NuSpecs\Humanizer.Core.sr.nuspec = ..\NuSpecs\Humanizer.Core.sr.nuspec + ..\NuSpecs\Humanizer.Core.sv.nuspec = ..\NuSpecs\Humanizer.Core.sv.nuspec + ..\NuSpecs\Humanizer.Core.tr.nuspec = ..\NuSpecs\Humanizer.Core.tr.nuspec + ..\NuSpecs\Humanizer.Core.uk.nuspec = ..\NuSpecs\Humanizer.Core.uk.nuspec + ..\NuSpecs\Humanizer.Core.uz-Cyrl-UZ.nuspec = ..\NuSpecs\Humanizer.Core.uz-Cyrl-UZ.nuspec + ..\NuSpecs\Humanizer.Core.uz-Latn-UZ.nuspec = ..\NuSpecs\Humanizer.Core.uz-Latn-UZ.nuspec + ..\NuSpecs\Humanizer.Core.vi.nuspec = ..\NuSpecs\Humanizer.Core.vi.nuspec + ..\NuSpecs\Humanizer.Core.zh-CN.nuspec = ..\NuSpecs\Humanizer.Core.zh-CN.nuspec + ..\NuSpecs\Humanizer.Core.zh-Hans.nuspec = ..\NuSpecs\Humanizer.Core.zh-Hans.nuspec + ..\NuSpecs\Humanizer.Core.zh-Hant.nuspec = ..\NuSpecs\Humanizer.Core.zh-Hant.nuspec + ..\NuSpecs\Humanizer.nuspec = ..\NuSpecs\Humanizer.nuspec + EndProjectSection EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -133,22 +177,6 @@ Global {F0DC7771-CE59-4F3C-B160-56F661F5D220}.Release|x86.ActiveCfg = Release|x86 {F0DC7771-CE59-4F3C-B160-56F661F5D220}.Release|x86.Build.0 = Release|x86 {F0DC7771-CE59-4F3C-B160-56F661F5D220}.Release|x86.Deploy.0 = Release|x86 - {50D97972-236C-46A0-B912-1310CE636569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|Any CPU.Build.0 = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|ARM.ActiveCfg = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|ARM.Build.0 = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|x64.ActiveCfg = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|x64.Build.0 = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|x86.ActiveCfg = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Debug|x86.Build.0 = Debug|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|Any CPU.ActiveCfg = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|Any CPU.Build.0 = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|ARM.ActiveCfg = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|ARM.Build.0 = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|x64.ActiveCfg = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|x64.Build.0 = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|x86.ActiveCfg = Release|Any CPU - {50D97972-236C-46A0-B912-1310CE636569}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -159,6 +187,6 @@ Global {FDEC244B-F07E-4A5E-BB80-FBC6AC77A9AA} = {04B74BEC-A645-4D1A-BE21-F4EB4413A903} {261367CA-00C7-4832-BD26-200CFF8F575F} = {04B74BEC-A645-4D1A-BE21-F4EB4413A903} {F0DC7771-CE59-4F3C-B160-56F661F5D220} = {04B74BEC-A645-4D1A-BE21-F4EB4413A903} - {50D97972-236C-46A0-B912-1310CE636569} = {04B74BEC-A645-4D1A-BE21-F4EB4413A903} + {AA449265-E001-486D-A0F4-04ACF0C83DC1} = {4779A7C9-9ED8-4146-A158-FBE0B1BE09D9} EndGlobalSection EndGlobal diff --git a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs index cc038f54e..4bca43f07 100644 --- a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs +++ b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs @@ -16,6 +16,7 @@ public CollectionFormatterRegistry() Register("ro", new DefaultCollectionFormatter("și")); Register("nn", new DefaultCollectionFormatter("og")); Register("nb", new DefaultCollectionFormatter("og")); + Register("sv", new DefaultCollectionFormatter("och")); } } } \ No newline at end of file diff --git a/src/Humanizer/Configuration/Configurator.cs b/src/Humanizer/Configuration/Configurator.cs index facdd033b..933010f8d 100644 --- a/src/Humanizer/Configuration/Configurator.cs +++ b/src/Humanizer/Configuration/Configurator.cs @@ -7,6 +7,7 @@ using Humanizer.Localisation.NumberToWords; using Humanizer.Localisation.Ordinalizers; using Humanizer.Localisation.CollectionFormatters; +using Humanizer.Localisation.DateToOrdinalWords; namespace Humanizer.Configuration { @@ -52,6 +53,15 @@ public static LocaliserRegistry Ordinalizers get { return _ordinalizers; } } + private static readonly LocaliserRegistry _dateToOrdinalWordConverters = new DateToOrdinalWordsConverterRegistry(); + /// + /// A registry of ordinalizers used to localise Ordinalize method + /// + public static LocaliserRegistry DateToOrdinalWordsConverters + { + get { return _dateToOrdinalWordConverters; } + } + internal static ICollectionFormatter CollectionFormatter { get @@ -89,6 +99,17 @@ internal static IOrdinalizer Ordinalizer } } + /// + /// The ordinalizer to be used + /// + internal static IDateToOrdinalWordConverter DateToOrdinalWordsConverter + { + get + { + return DateToOrdinalWordsConverters.ResolveForUiCulture(); + } + } + private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy(); /// /// The strategy to be used for DateTime.Humanize diff --git a/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs b/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs new file mode 100644 index 000000000..b2c867104 --- /dev/null +++ b/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs @@ -0,0 +1,13 @@ +using Humanizer.Localisation.DateToOrdinalWords; +namespace Humanizer.Configuration +{ + internal class DateToOrdinalWordsConverterRegistry : LocaliserRegistry + { + public DateToOrdinalWordsConverterRegistry() : base(new DefaultDateToOrdinalWordConverter()) + { + Register("en-UK", new DefaultDateToOrdinalWordConverter()); + Register("de", new DefaultDateToOrdinalWordConverter()); + Register("en-US", new UsDateToOrdinalWordsConverter()); + } + } +} diff --git a/src/Humanizer/Configuration/FormatterRegistry.cs b/src/Humanizer/Configuration/FormatterRegistry.cs index 7fe073b42..32c7323be 100644 --- a/src/Humanizer/Configuration/FormatterRegistry.cs +++ b/src/Humanizer/Configuration/FormatterRegistry.cs @@ -19,7 +19,7 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US")) RegisterCzechSlovakPolishFormatter("pl"); RegisterCzechSlovakPolishFormatter("sk"); RegisterDefaultFormatter("bg"); - RegisterDefaultFormatter("pt-BR"); + RegisterDefaultFormatter("pt"); RegisterDefaultFormatter("sv"); RegisterDefaultFormatter("tr"); RegisterDefaultFormatter("vi"); diff --git a/src/Humanizer/DateToOrdinalWordsExtensions.cs b/src/Humanizer/DateToOrdinalWordsExtensions.cs new file mode 100644 index 000000000..ac60ba244 --- /dev/null +++ b/src/Humanizer/DateToOrdinalWordsExtensions.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using Humanizer.Configuration; + +namespace Humanizer +{ + /// + /// Humanizes DateTime into human readable sentence + /// + public static class DateToOrdinalWordsExtensions + { + /// + /// Turns the provided date into ordinal words + /// + /// The date to be made into ordinal words + /// The date in ordinal words + public static string ToOrdinalWords(this DateTime input) + { + return Configurator.DateToOrdinalWordsConverter.Convert(input); + } + /// + /// Turns the provided date into ordinal words + /// + /// The date to be made into ordinal words + /// The grammatical case to use for output words + /// The date in ordinal words + public static string ToOrdinalWords(this DateTime input, GrammaticalCase grammaticalCase) + { + return Configurator.DateToOrdinalWordsConverter.Convert(input, grammaticalCase); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/EnumHumanizeExtensions.cs b/src/Humanizer/EnumHumanizeExtensions.cs index d7ce1e8bc..4aa89e8d2 100644 --- a/src/Humanizer/EnumHumanizeExtensions.cs +++ b/src/Humanizer/EnumHumanizeExtensions.cs @@ -13,6 +13,7 @@ public static class EnumHumanizeExtensions { private const string DisplayAttributeTypeName = "System.ComponentModel.DataAnnotations.DisplayAttribute"; private const string DisplayAttributeGetDescriptionMethodName = "GetDescription"; + private const string DisplayAttributeGetNameMethodName = "GetName"; private static readonly Func StringTypedProperty = p => p.PropertyType == typeof(string); @@ -69,10 +70,21 @@ private static string GetCustomDescription(MemberInfo memberInfo) var attrType = attr.GetType(); if (attrType.FullName == DisplayAttributeTypeName) { - var method = attrType.GetRuntimeMethod(DisplayAttributeGetDescriptionMethodName, new Type[0]); - if (method != null) - return method.Invoke(attr, new object[0]).ToString(); + var methodGetDescription = attrType.GetRuntimeMethod(DisplayAttributeGetDescriptionMethodName, new Type[0]); + if (methodGetDescription != null) + { + var executedMethod = methodGetDescription.Invoke(attr, new object[0]); + if (executedMethod != null) return executedMethod.ToString(); + } + var methodGetName = attrType.GetRuntimeMethod(DisplayAttributeGetNameMethodName, new Type[0]); + if (methodGetName != null) + { + var executedMethod = methodGetName.Invoke(attr, new object[0]); + if (executedMethod != null) return executedMethod.ToString(); + } + return null; } + var descriptionProperty = attrType.GetRuntimeProperties() .Where(StringTypedProperty) diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 73ed03817..fa55ddf40 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -1,265 +1,22 @@ - - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {511A7984-F455-4A6E-ADB9-9CAAC47EA079} - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - Humanizer - Humanizer - v5.0 - - - 512 - 14.0 - Humanizer.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - bin\Debug\Humanizer.xml - false - 1591 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Humanizer.xml - true - true - ..\Humanizer.ruleset - + + netstandard1.0 + Mehdi Khalili, Oren Novotny + https://raw.githubusercontent.com/Humanizr/Humanizer/master/LICENSE + https://github.com/Humanizr/Humanizer + 2.12 + A micro-framework that turns your normal strings, type names, enum fields, date fields ETC into a human friendly format + Copyright © 2012-2017 Mehdi Khalili + Humanizer ($(TargetFramework)) + true + true true + Humanizer.snk + embedded + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - In.SomeTimeFrom.tt - - - True - True - On.Days.tt - - - - - - - - - - - - - - - - - - - - - True - True - In.Months.tt - - - - - - - - - - - - - - - - - - - - - - - - - - TextTemplatingFileGenerator - In.SomeTimeFrom.cs - - - TextTemplatingFileGenerator - On.Days.cs - - - TextTemplatingFileGenerator - In.Months.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - \ No newline at end of file diff --git a/src/Humanizer/InflectorExtensions.cs b/src/Humanizer/InflectorExtensions.cs index 37c5c3a34..0eb8b244f 100644 --- a/src/Humanizer/InflectorExtensions.cs +++ b/src/Humanizer/InflectorExtensions.cs @@ -94,7 +94,7 @@ public static string Underscore(this string input) { return Regex.Replace( Regex.Replace( - Regex.Replace(input, @"([A-Z]+)([A-Z][a-z])", "$1_$2"), @"([a-z\d])([A-Z])", "$1_$2"), @"[-\s]", "_").ToLower(); + Regex.Replace(input, @"([\p{Lu}]+)([\p{Lu}][\p{Ll}])", "$1_$2"), @"([\p{Ll}\d])([\p{Lu}])", "$1_$2"), @"[-\s]", "_").ToLower(); } /// @@ -116,5 +116,15 @@ public static string Hyphenate(this string underscoredWord) { return Dasherize(underscoredWord); } + + /// + /// Separates the input words with hyphens and all the words are converted to lowercase + /// + /// + /// + public static string Kebaberize(this string input) + { + return Underscore(input).Dasherize(); + } } } \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs new file mode 100644 index 000000000..7b9f82ab2 --- /dev/null +++ b/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs @@ -0,0 +1,19 @@ +using System; + +namespace Humanizer.Localisation.DateToOrdinalWords +{ + internal class DefaultDateToOrdinalWordConverter : IDateToOrdinalWordConverter + { + + public virtual string Convert(DateTime date) + { + return date.Day.Ordinalize() + date.ToString(" MMMM yyyy"); + } + + public virtual string Convert(DateTime date, GrammaticalCase grammaticalCase) + { + return Convert(date); + } + + } +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs new file mode 100644 index 000000000..84fb4110e --- /dev/null +++ b/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs @@ -0,0 +1,25 @@ +using System; + +namespace Humanizer.Localisation.DateToOrdinalWords +{ + /// + /// The interface used to localise the ToOrdinalWords method. + /// + public interface IDateToOrdinalWordConverter + { + /// + /// Converts the date to Ordinal Words + /// + /// + /// + string Convert(DateTime date); + + /// + /// Converts the date to Ordinal Words using the provided grammatical case + /// + /// + /// + /// + string Convert(DateTime date, GrammaticalCase grammaticalCase); + } +} diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs new file mode 100644 index 000000000..4ccbab2af --- /dev/null +++ b/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs @@ -0,0 +1,12 @@ +using System; + +namespace Humanizer.Localisation.DateToOrdinalWords +{ + internal class UsDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter + { + public override string Convert(DateTime date) + { + return date.ToString("MMMM ") + date.Day.Ordinalize() + date.ToString(", yyyy"); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs b/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs index 0c704d764..20fbdeb1f 100644 --- a/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs @@ -61,15 +61,12 @@ public virtual string TimeSpanHumanize_Zero() /// /// Returns the string representation of the provided TimeSpan /// - /// Must be less than or equal to TimeUnit.Week + /// A time unit to represent. /// /// /// Is thrown when timeUnit is larger than TimeUnit.Week public virtual string TimeSpanHumanize(TimeUnit timeUnit, int unit) { - if (timeUnit > TimeUnit.Week) - throw new ArgumentOutOfRangeException(nameof(timeUnit), "There's no meaningful way to humanize passed timeUnit."); - return GetResourceForTimeSpan(timeUnit, unit); } @@ -86,24 +83,36 @@ private string GetResourceForTimeSpan(TimeUnit unit, int count) } /// - /// + /// Formats the specified resource key. /// - /// + /// The resource key. /// + /// If the resource not exists on the specified culture. protected virtual string Format(string resourceKey) { - return Resources.GetResource(GetResourceKey(resourceKey), _culture); + var resourceString = Resources.GetResource(GetResourceKey(resourceKey), _culture); + + if (string.IsNullOrEmpty(resourceString)) + throw new ArgumentException($"The resource object with key '{resourceKey}' was not found", nameof(resourceKey)); + + return resourceString; } /// - /// + /// Formats the specified resource key. /// - /// - /// + /// The resource key. + /// The number. /// + /// If the resource not exists on the specified culture. protected virtual string Format(string resourceKey, int number) { - return Resources.GetResource(GetResourceKey(resourceKey, number), _culture).FormatWith(number); + var resourceString = Resources.GetResource(GetResourceKey(resourceKey, number), _culture); + + if (string.IsNullOrEmpty(resourceString)) + throw new ArgumentException($"The resource object with key '{resourceKey}' was not found", nameof(resourceKey)); + + return resourceString.FormatWith(number); } /// diff --git a/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs index 2f33eb6b5..6a6b855a7 100644 --- a/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs @@ -22,9 +22,13 @@ internal class AfrikaansNumberToWordsConverter : GenderlessNumberToWordsConverte {19, "negentiende"} }; - public override string Convert(int number) + public override string Convert(long number) { - return Convert(number, false); + if(number > Int32.MaxValue|| number < Int32.MinValue) + { + throw new NotImplementedException(); + } + return Convert((int)number, false); } public override string ConvertToOrdinal(int number) diff --git a/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs index e27324297..ae6f47276 100644 --- a/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs @@ -17,8 +17,14 @@ internal class ArabicNumberToWordsConverter : GenderedNumberToWordsConverter private static readonly string[] FeminineOnesGroup = { "", "واحدة", "اثنتان", "ثلاث", "أربع", "خمس", "ست", "سبع", "ثمان", "تسع", "عشر", "إحدى عشرة", "اثنتا عشرة", "ثلاث عشرة", "أربع عشرة", "خمس عشرة", "ست عشرة", "سبع عشرة", "ثمان عشرة", "تسع عشرة" }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return "صفر"; diff --git a/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs index c5e58d11b..03d4cb67e 100644 --- a/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Humanizer.Localisation.NumberToWords { @@ -59,8 +60,14 @@ public override string ConvertToOrdinal(int number) return Convert(number) + " তম"; } - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return UnitsMap[0]; diff --git a/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs index 8b646a44d..4c89f97ed 100644 --- a/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs @@ -13,8 +13,14 @@ internal class BrazilianPortugueseNumberToWordsConverter : GenderedNumberToWords private static readonly string[] PortugueseOrdinalTensMap = { "zero", "décimo", "vigésimo", "trigésimo", "quadragésimo", "quinquagésimo", "sexagésimo", "septuagésimo", "octogésimo", "nonagésimo" }; private static readonly string[] PortugueseOrdinalHundredsMap = { "zero", "centésimo", "ducentésimo", "trecentésimo", "quadringentésimo", "quingentésimo", "sexcentésimo", "septingentésimo", "octingentésimo", "noningentésimo" }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return "zero"; diff --git a/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs index ece6e9b0c..9182194b7 100644 --- a/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs @@ -20,7 +20,7 @@ public DefaultNumberToWordsConverter(CultureInfo culture) /// /// Number to be turned to words /// - public override string Convert(int number) + public override string Convert(long number) { return number.ToString(_culture); } diff --git a/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs index f071b1b05..bfc1978d8 100644 --- a/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; namespace Humanizer.Localisation.NumberToWords @@ -31,8 +32,14 @@ class Fact new Fact {Value = 100, Name = "honderd", Prefix = "", Postfix = "", DisplayOneUnit = false} }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return UnitsMap[0]; diff --git a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs index 5a5daed00..9ef477c2e 100644 --- a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs @@ -8,7 +8,7 @@ internal class EnglishNumberToWordsConverter : GenderlessNumberToWordsConverter private static readonly string[] UnitsMap = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; private static readonly string[] TensMap = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; - private static readonly Dictionary OrdinalExceptions = new Dictionary + private static readonly Dictionary OrdinalExceptions = new Dictionary { {1, "first"}, {2, "second"}, @@ -20,7 +20,7 @@ internal class EnglishNumberToWordsConverter : GenderlessNumberToWordsConverter {12, "twelfth"}, }; - public override string Convert(int number) + public override string Convert(long number) { return Convert(number, false); } @@ -30,7 +30,7 @@ public override string ConvertToOrdinal(int number) return Convert(number, true); } - private string Convert(int number, bool isOrdinal) + private string Convert(long number, bool isOrdinal) { if (number == 0) return GetUnitValue(0, isOrdinal); @@ -40,6 +40,24 @@ private string Convert(int number, bool isOrdinal) var parts = new List(); + if ((number / 1000000000000000000) > 0) + { + parts.Add(string.Format("{0} quintillion", Convert(number / 1000000000000000000))); + number %= 1000000000000000000; + } + + if ((number / 1000000000000000) > 0) + { + parts.Add(string.Format("{0} quadrillion", Convert(number / 1000000000000000))); + number %= 1000000000000000; + } + + if ((number / 1000000000000) > 0) + { + parts.Add(string.Format("{0} trillion", Convert(number / 1000000000000))); + number %= 1000000000000; + } + if ((number / 1000000000) > 0) { parts.Add(string.Format("{0} billion", Convert(number / 1000000000))); @@ -93,7 +111,7 @@ private string Convert(int number, bool isOrdinal) return toWords; } - private static string GetUnitValue(int number, bool isOrdinal) + private static string GetUnitValue(long number, bool isOrdinal) { if (isOrdinal) { @@ -116,7 +134,7 @@ private static string RemoveOnePrefix(string toWords) return toWords; } - private static bool ExceptionNumbersToWords(int number, out string words) + private static bool ExceptionNumbersToWords(long number, out string words) { return OrdinalExceptions.TryGetValue(number, out words); } diff --git a/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs index 66d6b3f70..8f75b6a8c 100644 --- a/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs @@ -9,8 +9,14 @@ internal class FarsiNumberToWordsConverter : GenderlessNumberToWordsConverter private static readonly string[] FarsiTensMap = { "صفر", "ده", "بیست", "سی", "چهل", "پنجاه", "شصت", "هفتاد", "هشتاد", "نود" }; private static readonly string[] FarsiUnitsMap = { "صفر", "یک", "دو", "سه", "چهار", "پنج", "شش", "هفت", "هشت", "نه", "ده", "یازده", "دوازده", "سیزده", "چهارده", "پانزده", "شانزده", "هفده", "هجده", "نوزده" }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number < 0) return string.Format("منفی {0}", Convert(-number)); diff --git a/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs index 39cc17f53..657f5fc7c 100644 --- a/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Humanizer.Localisation.NumberToWords { @@ -13,8 +14,14 @@ internal class FinnishNumberToWordsConverter : GenderlessNumberToWordsConverter {2, "kahdes" } }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number < 0) return string.Format("miinus {0}", Convert(-number)); diff --git a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs index 7343557a9..f47c5c10e 100644 --- a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs @@ -2,7 +2,7 @@ namespace Humanizer.Localisation.NumberToWords { - internal class FrenchNumberToWordsConverter : FrenchNumberToWordsConverterBase + class FrenchNumberToWordsConverter : FrenchNumberToWordsConverterBase { protected override void CollectPartsUnderAHundred(ICollection parts, ref int number, GrammaticalGender gender, bool pluralize) { @@ -15,7 +15,7 @@ protected override void CollectPartsUnderAHundred(ICollection parts, ref var @base = number < 80 ? 60 : 80; int units = number - @base; var tens = @base/10; - parts.Add(string.Format("{0}-{1}", GetTens(tens), GetUnits(units, gender))); + parts.Add($"{GetTens(tens)}-{GetUnits(units, gender)}"); } else base.CollectPartsUnderAHundred(parts, ref number, gender, pluralize); diff --git a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs index 15ccad0d5..37bcfd4f5 100644 --- a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs +++ b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs @@ -1,14 +1,21 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Humanizer.Localisation.NumberToWords { abstract class FrenchNumberToWordsConverterBase : GenderedNumberToWordsConverter { - private static readonly string[] UnitsMap = new string[] { "zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf"}; - private static readonly string[] TensMap = new string[] { "zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "septante", "octante", "nonante" }; + static readonly string[] UnitsMap = { "zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf"}; + static readonly string[] TensMap = { "zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "septante", "octante", "nonante" }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return UnitsMap[0]; var parts = new List(); @@ -63,7 +70,7 @@ protected static string GetUnits(int number, GrammaticalGender gender) return UnitsMap[number]; } - private static void CollectHundreds(ICollection parts, ref int number, int d, string form, bool pluralize) + static void CollectHundreds(ICollection parts, ref int number, int d, string form, bool pluralize) { if (number < d) return; @@ -88,7 +95,7 @@ private static void CollectHundreds(ICollection parts, ref int number, i number %= d; } - private void CollectParts(ICollection parts, ref int number, int d, string form) + void CollectParts(ICollection parts, ref int number, int d, string form) { if (number < d) return; @@ -108,7 +115,7 @@ private void CollectParts(ICollection parts, ref int number, int d, stri number %= d; } - private void CollectPartsUnderAThousand(ICollection parts, int number, GrammaticalGender gender, bool pluralize) + void CollectPartsUnderAThousand(ICollection parts, int number, GrammaticalGender gender, bool pluralize) { CollectHundreds(parts, ref number, 100, "cent", pluralize); @@ -118,7 +125,7 @@ private void CollectPartsUnderAThousand(ICollection parts, int number, G } } - private void CollectThousands(ICollection parts, ref int number, int d, string form) + void CollectThousands(ICollection parts, ref int number, int d, string form) { if (number < d) return; @@ -155,7 +162,7 @@ protected virtual void CollectPartsUnderAHundred(ICollection parts, ref } else { - parts.Add(string.Format("{0}-{1}", tens, GetUnits(units, gender))); + parts.Add($"{tens}-{GetUnits(units, gender)}"); } } } diff --git a/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs index 4af91b4f3..3bd5d274c 100644 --- a/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs @@ -14,7 +14,7 @@ protected GenderedNumberToWordsConverter(GrammaticalGender defaultGender = Gramm /// /// /// - public string Convert(int number) + public string Convert(long number) { return Convert(number, _defaultGender); } @@ -25,7 +25,7 @@ public string Convert(int number) /// /// /// - public abstract string Convert(int number, GrammaticalGender gender); + public abstract string Convert(long number, GrammaticalGender gender); /// /// Converts the number to ordinal string using the locale's default grammatical gender diff --git a/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs index fa89f250d..7e449e133 100644 --- a/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs @@ -7,7 +7,7 @@ abstract class GenderlessNumberToWordsConverter : INumberToWordsConverter /// /// /// - public abstract string Convert(int number); + public abstract string Convert(long number); /// /// Converts the number to string ignoring the provided grammatical gender @@ -15,7 +15,7 @@ abstract class GenderlessNumberToWordsConverter : INumberToWordsConverter /// /// /// - public string Convert(int number, GrammaticalGender gender) + public string Convert(long number, GrammaticalGender gender) { return Convert(number); } diff --git a/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverter.cs index b138bb2e4..9ca130a4e 100644 --- a/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverter.cs @@ -13,8 +13,14 @@ internal class GermanNumberToWordsConverter : GenderedNumberToWordsConverter private static readonly string[] BillionOrdinalSingular = {"einmilliard", "einemilliarde"}; private static readonly string[] BillionOrdinalPlural = {"{0}milliard", "{0}milliarden"}; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return "null"; diff --git a/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs index 1155f8d48..91fbcddda 100644 --- a/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs @@ -38,8 +38,14 @@ public HebrewNumberToWordsConverter(CultureInfo culture) _culture = culture; } - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number < 0) return string.Format("מינוס {0}", Convert(-number, gender)); diff --git a/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs index 5a4f929be..151770be1 100644 --- a/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs @@ -10,7 +10,7 @@ public interface INumberToWordsConverter /// /// /// - string Convert(int number); + string Convert(long number); /// /// Converts the number to string using the provided grammatical gender @@ -18,7 +18,7 @@ public interface INumberToWordsConverter /// /// /// - string Convert(int number, GrammaticalGender gender); + string Convert(long number, GrammaticalGender gender); /// /// Converts the number to ordinal string using the locale's default grammatical gender diff --git a/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs index 9ffdb5ef0..67a978e37 100644 --- a/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs @@ -5,8 +5,14 @@ namespace Humanizer.Localisation.NumberToWords { internal class ItalianNumberToWordsConverter : GenderedNumberToWordsConverter { - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number < 0) return "meno " + Convert(Math.Abs(number), gender); diff --git a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs index b75c8ca70..fcd53d774 100644 --- a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs @@ -21,9 +21,14 @@ internal class NorwegianBokmalNumberToWordsConverter : GenderedNumberToWordsConv {12, "tolvte"} }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long number, GrammaticalGender gender) { - return Convert(number, false, gender); + if (number > Int32.MaxValue || number < Int32.MinValue) + { + throw new NotImplementedException(); + } + + return Convert((int)number, false, gender); } public override string ConvertToOrdinal(int number, GrammaticalGender gender) diff --git a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs index 894a90852..afa5ce45d 100644 --- a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; namespace Humanizer.Localisation.NumberToWords @@ -55,8 +56,13 @@ private static int GetMappingIndex(int number) return 2; //genitive } - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return "zero"; diff --git a/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs index 122d6fb22..f6071cf96 100644 --- a/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs @@ -5,10 +5,14 @@ namespace Humanizer.Localisation.NumberToWords { internal class RomanianNumberToWordsConverter : GenderedNumberToWordsConverter { - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long number, GrammaticalGender gender) { + if (number > Int32.MaxValue || number < Int32.MinValue) + { + throw new NotImplementedException(); + } var converter = new RomanianCardinalNumberConverter(); - return converter.Convert(number, gender); + return converter.Convert((int)number, gender); } public override string ConvertToOrdinal(int number, GrammaticalGender gender) diff --git a/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs index fe1f726bc..a446a0843 100644 --- a/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs @@ -14,8 +14,13 @@ internal class RussianNumberToWordsConverter : GenderedNumberToWordsConverter private static readonly string[] TensOrdinal = { string.Empty, "десят", "двадцат", "тридцат", "сороков", "пятидесят", "шестидесят", "семидесят", "восьмидесят", "девяност" }; private static readonly string[] UnitsOrdinal = { string.Empty, "перв", "втор", "трет", "четверт", "пят", "шест", "седьм", "восьм", "девят", "десят", "одиннадцат", "двенадцат", "тринадцат", "четырнадцат", "пятнадцат", "шестнадцат", "семнадцат", "восемнадцат", "девятнадцат" }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return "ноль"; diff --git a/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs index 208a6e118..1691f690b 100644 --- a/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs @@ -18,8 +18,14 @@ public SerbianCyrlNumberToWordsConverter(CultureInfo culture) _culture = culture; } - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return "нула"; diff --git a/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs index f3090416a..a3eabd47c 100644 --- a/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs @@ -18,8 +18,13 @@ public SerbianNumberToWordsConverter(CultureInfo culture) _culture = culture; } - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return "nula"; diff --git a/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs index eaa48ca2c..99f400761 100644 --- a/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; namespace Humanizer.Localisation.NumberToWords @@ -15,9 +16,14 @@ public SlovenianNumberToWordsConverter(CultureInfo culture) _culture = culture; } - public override string Convert(int number) - { - if (number == 0) + public override string Convert(long input) + { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + if (number == 0) return "nič"; if (number < 0) diff --git a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs index 97a308a5e..5cbdc7bd8 100644 --- a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs @@ -28,8 +28,13 @@ internal class SpanishNumberToWordsConverter : GenderedNumberToWordsConverter {10, "décimo"} }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return "cero"; diff --git a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs index 73a149a4c..bf80a1754 100644 --- a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs @@ -22,8 +22,13 @@ internal class TurkishNumberToWordConverter : GenderlessNumberToWordsConverter {'a', "ıncı"}, }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return UnitsMap[0]; diff --git a/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs index 039e7597c..c05fe9407 100644 --- a/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs @@ -14,8 +14,13 @@ internal class UkrainianNumberToWordsConverter : GenderedNumberToWordsConverter private static readonly string[] TensOrdinal = { string.Empty, "десят", "двадцят", "тридцят", "сороков", "п'ятдесят", "шістдесят", "сімдесят", "вісімдесят", "дев'яност" }; private static readonly string[] UnitsOrdinal = { "нульов", "перш", "друг", "трет", "четверт", "п'ят", "шост", "сьом", "восьм", "дев'ят", "десят", "одинадцят", "дванадцят", "тринадцят", "чотирнадцят", "п'ятнадцят", "шістнадцят", "сімнадцят", "вісімнадцят", "дев'ятнадцят" }; - public override string Convert(int number, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number == 0) return "нуль"; diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs index 7558b2552..bb9374109 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs @@ -12,8 +12,13 @@ internal class UzbekCyrlNumberToWordConverter : GenderlessNumberToWordsConverter private static readonly string[] OrdinalSuffixes = new string[] { "инчи", "нчи" }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number < 0) return string.Format("минус {0}", Convert(-number, true)); return Convert(number, true); diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs index f7960005b..da54f2ffe 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs @@ -12,8 +12,13 @@ internal class UzbekLatnNumberToWordConverter : GenderlessNumberToWordsConverter private static readonly string[] OrdinalSuffixes = new string[] { "inchi", "nchi" }; - public override string Convert(int number) + public override string Convert(long input) { + if (input > Int32.MaxValue || input < Int32.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; if (number < 0) return string.Format("minus {0}", Convert(-number, true)); return Convert(number, true); diff --git a/src/Humanizer/MetricNumeralExtensions.cs b/src/Humanizer/MetricNumeralExtensions.cs index ecfb1012f..e973165c3 100644 --- a/src/Humanizer/MetricNumeralExtensions.cs +++ b/src/Humanizer/MetricNumeralExtensions.cs @@ -90,27 +90,28 @@ public static double FromMetric(this string input) return BuildNumber(input, input[input.Length - 1]); } - /// - /// Converts a number into a valid and Human-readable Metric representation. - /// - /// - /// Inspired by a snippet from Thom Smith. - /// See this link for more. - /// - /// Number to convert to a Metric representation. - /// True will split the number and the symbol with a whitespace. - /// True will use symbol instead of name - /// - /// - /// 1000.ToMetric() => "1k" - /// 123.ToMetric() => "123" - /// 1E-1.ToMetric() => "100m" - /// - /// - /// A valid Metric representation - public static string ToMetric(this int input, bool hasSpace = false, bool useSymbol = true) + /// + /// Converts a number into a valid and Human-readable Metric representation. + /// + /// + /// Inspired by a snippet from Thom Smith. + /// See this link for more. + /// + /// Number to convert to a Metric representation. + /// True will split the number and the symbol with a whitespace. + /// True will use symbol instead of name + /// If not null it is the numbers of decimals to round the number to + /// + /// + /// 1000.ToMetric() => "1k" + /// 123.ToMetric() => "123" + /// 1E-1.ToMetric() => "100m" + /// + /// + /// A valid Metric representation + public static string ToMetric(this int input, bool hasSpace = false, bool useSymbol = true, int? decimals = null) { - return ((double)input).ToMetric(hasSpace, useSymbol); + return ((double)input).ToMetric(hasSpace, useSymbol, decimals); } /// @@ -123,6 +124,7 @@ public static string ToMetric(this int input, bool hasSpace = false, bool useSym /// Number to convert to a Metric representation. /// True will split the number and the symbol with a whitespace. /// True will use symbol instead of name + /// If not null it is the numbers of decimals to round the number to /// /// /// 1000d.ToMetric() => "1k" @@ -131,14 +133,14 @@ public static string ToMetric(this int input, bool hasSpace = false, bool useSym /// /// /// A valid Metric representation - public static string ToMetric(this double input, bool hasSpace = false, bool useSymbol = true) + public static string ToMetric(this double input, bool hasSpace = false, bool useSymbol = true, int? decimals = null) { if (input.Equals(0)) return input.ToString(); if (input.IsOutOfRange()) throw new ArgumentOutOfRangeException(nameof(input)); - return BuildRepresentation(input, hasSpace, useSymbol); + return BuildRepresentation(input, hasSpace, useSymbol, decimals); } /// @@ -199,19 +201,20 @@ private static string ReplaceNameBySymbol(string input) current.Replace(name.Value, name.Key.ToString())); } - /// - /// Build a Metric representation of the number. - /// - /// Number to convert to a Metric representation. - /// True will split the number and the symbol with a whitespace. - /// True will use symbol instead of name - /// A number in a Metric representation - private static string BuildRepresentation(double input, bool hasSpace, bool useSymbol) + /// + /// Build a Metric representation of the number. + /// + /// Number to convert to a Metric representation. + /// True will split the number and the symbol with a whitespace. + /// True will use symbol instead of name + /// If not null it is the numbers of decimals to round the number to + /// A number in a Metric representation + private static string BuildRepresentation(double input, bool hasSpace, bool useSymbol, int? decimals) { var exponent = (int)Math.Floor(Math.Log10(Math.Abs(input)) / 3); - return exponent.Equals(0) + return exponent.Equals(0) ? input.ToString() - : BuildMetricRepresentation(input, exponent, hasSpace, useSymbol); + : BuildMetricRepresentation(input, exponent, hasSpace, useSymbol, decimals); } /// @@ -221,10 +224,13 @@ private static string BuildRepresentation(double input, bool hasSpace, bool useS /// Exponent of the number in a scientific notation /// True will split the number and the symbol with a whitespace. /// True will use symbol instead of name + /// If not null it is the numbers of decimals to round the number to /// A number in a Metric representation - private static string BuildMetricRepresentation(double input, int exponent, bool hasSpace, bool useSymbol) + private static string BuildMetricRepresentation(double input, int exponent, bool hasSpace, bool useSymbol, int? decimals) { var number = input * Math.Pow(1000, -exponent); + if (decimals.HasValue) + number = Math.Round(number, decimals.Value); var symbol = Math.Sign(exponent) == 1 ? Symbols[0][exponent - 1] : Symbols[1][-exponent - 1]; diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index afab61866..cfcb189fb 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -16,7 +16,7 @@ public static class NumberToWordsExtension /// public static string ToWords(this int number, CultureInfo culture = null) { - return Configurator.GetNumberToWordsConverter(culture).Convert(number); + return ((long)number).ToWords(culture); } /// @@ -40,6 +40,42 @@ public static string ToWords(this int number, CultureInfo culture = null) /// Culture to use. If null, current thread's UI culture is used. /// public static string ToWords(this int number, GrammaticalGender gender, CultureInfo culture = null) + { + return ((long)number).ToWords(gender, culture); + } + + /// + /// 3501.ToWords() -> "three thousand five hundred and one" + /// + /// Number to be turned to words + /// Culture to use. If null, current thread's UI culture is used. + /// + public static string ToWords(this long number, CultureInfo culture = null) + { + return Configurator.GetNumberToWordsConverter(culture).Convert(number); + } + + /// + /// For locales that support gender-specific forms + /// + /// + /// Russian: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "один" + /// 1.ToWords(GrammaticalGender.Feminine) -> "одна" + /// + /// Hebrew: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "אחד" + /// 1.ToWords(GrammaticalGender.Feminine) -> "אחת" + /// + /// + /// + /// Number to be turned to words + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + /// + public static string ToWords(this long number, GrammaticalGender gender, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).Convert(number, gender); } diff --git a/src/Humanizer/Properties/AssemblyInfo.cs b/src/Humanizer/Properties/AssemblyInfo.cs index 9bafe18a0..73718e711 100644 --- a/src/Humanizer/Properties/AssemblyInfo.cs +++ b/src/Humanizer/Properties/AssemblyInfo.cs @@ -2,37 +2,4 @@ using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Humanizer")] -[assembly: AssemblyDescription("A micro-framework that turns your normal strings, type names, enum fields, date fields ETC into a human friendly format")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Mehdi Khalili")] -[assembly: AssemblyProduct("Humanizer")] -[assembly: AssemblyCopyright("Copyright © 2012-2015 Mehdi Khalili")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -//[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -//[assembly: Guid("24d4e306-6593-4f09-90fe-6410a8d08188")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0")] -[assembly: AssemblyFileVersion("1.0")] -[assembly: AssemblyInformationalVersion("1.0")] [assembly: NeutralResourcesLanguage("en")] \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.af.resx b/src/Humanizer/Properties/Resources.af.resx index 955479a5a..14a4166c2 100644 --- a/src/Humanizer/Properties/Resources.af.resx +++ b/src/Humanizer/Properties/Resources.af.resx @@ -231,4 +231,16 @@ oor 1 jaar + + 1 maand + + + {0} maande + + + {0} jaar + + + 1 jaar + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.ar.resx b/src/Humanizer/Properties/Resources.ar.resx index f70c4b314..ce2935ba0 100644 --- a/src/Humanizer/Properties/Resources.ar.resx +++ b/src/Humanizer/Properties/Resources.ar.resx @@ -401,4 +401,28 @@ الآن now + + {0} أشهر + + + شهرين + + + {0} أشهر + + + {0} سنة + + + سنتين + + + {0} سنة + + + شهر 1 + + + السنة 1 + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.bg.resx b/src/Humanizer/Properties/Resources.bg.resx index 585db32a6..104de5a71 100644 --- a/src/Humanizer/Properties/Resources.bg.resx +++ b/src/Humanizer/Properties/Resources.bg.resx @@ -231,4 +231,16 @@ след година - + + {0} месеца + + + {0} години + + + един месец + + + една година + + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.bn-BD.resx b/src/Humanizer/Properties/Resources.bn-BD.resx index 80c3fd9a2..f36b85ca3 100644 --- a/src/Humanizer/Properties/Resources.bn-BD.resx +++ b/src/Humanizer/Properties/Resources.bn-BD.resx @@ -231,4 +231,16 @@ এক বছর পর + + {0} মাস + + + {0} বছর + + + এক মাসের + + + এক বছর + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.cs.resx b/src/Humanizer/Properties/Resources.cs.resx index 7d53f6432..1b9dbab2a 100644 --- a/src/Humanizer/Properties/Resources.cs.resx +++ b/src/Humanizer/Properties/Resources.cs.resx @@ -285,4 +285,22 @@ {0} týdny + + {0} měsíců + + + {0} měsíce + + + {0} let + + + {0} roky + + + 1 měsíc + + + 1 rok + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.da.resx b/src/Humanizer/Properties/Resources.da.resx index ad88dee52..7466fefb9 100644 --- a/src/Humanizer/Properties/Resources.da.resx +++ b/src/Humanizer/Properties/Resources.da.resx @@ -231,4 +231,16 @@ et år fra nu + + {0} måneder + + + {0} år + + + en måned + + + et år + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.de.resx b/src/Humanizer/Properties/Resources.de.resx index a6f7884d8..87c3e700a 100644 --- a/src/Humanizer/Properties/Resources.de.resx +++ b/src/Humanizer/Properties/Resources.de.resx @@ -234,4 +234,16 @@ nie + + {0} Monate + + + {0} Jahre + + + Ein Monat + + + Ein Jahr + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.el.resx b/src/Humanizer/Properties/Resources.el.resx index 0080c4ae0..54460ba13 100644 --- a/src/Humanizer/Properties/Resources.el.resx +++ b/src/Humanizer/Properties/Resources.el.resx @@ -117,40 +117,439 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - πριν από ένα δευτερόλεπτο + + πριν από {0} ημέρες - - πριν από {0} δευτερόλεπτα + + πριν από {0} ημέρες - - πριν από ένα λεπτό + + πριν από {0} ημέρες - - πριν από {0} λεπτά + + πριν από {0} ημέρες - - πριν από μία ώρα + + πριν από {0} ημέρα + + + πριν από {0} ημέρες + + + {0} ημέρες από τώρα + + + {0} ημέρες από τώρα + + + {0} ημέρες από τώρα + + + {0} ημέρα από τώρα + + + {0} ημέρες από τώρα πριν από {0} ώρες + + πριν από {0} ώρες + + + πριν από {0} ώρες + + + πριν από {0} ώρες + + + πριν από {0} ώρες + + + πριν από {0} ώρα + + + πριν από {0} ώρες + + + {0} ώρες από τώρα + + + {0} ώρες από τώρα + + + {0} ώρες από τώρα + + + {0} ώρες από τώρα + + + {0} ώρα από τώρα + + + {0} ώρες από τώρα + + + πριν από {0} λεπτά + + + πριν από {0} λεπτά + + + πριν από {0} λεπτά + + + πριν από {0} λεπτά + + + πριν από {0} λεπτά + + + πριν από {0} λεπτό + + + πριν από {0} λεπτά + + + {0} λεπτά από τώρα + + + {0} λεπτά από τώρα + + + {0} λεπτά από τώρα + + + {0} λεπτά από τώρα + + + {0} λεπτό από τώρα + + + {0} λεπτά από τώρα + + + πριν από {0} μήνες + + + πριν από {0} μήνες + + + πριν από {0} μήνες + + + πριν από {0} μήνες + + + πριν από {0} μήνα + + + πριν από {0} μήνες + + + {0} μήνες από τώρα + + + {0} μήνες από τώρα + + + {0} μήνες από τώρα + + + {0} μήνες από τώρα + + + {0} μήνα από τώρα + + + {0} μήνες από τώρα + + + πριν από {0} δευτερόλεπτα + + + πριν από {0} δευτερόλεπτα + + + πριν από {0} δευτερόλεπτα + + + πριν από {0} δευτερόλεπτα + + + πριν από {0} δευτερόλεπτα + + + πριν από {0} δευτερόλεπτο + + + πριν από {0} δευτερόλεπτα + + + {0} δευτερόλεπτα από τώρα + + + {0} δευτερόλεπτα από τώρα + + + {0} δευτερόλεπτα από τώρα + + + {0} δευτερόλεπτο από τώρα + + + {0} δευτερόλεπτα από τώρα + + + {0} δευτερόλεπτα από τώρα + + + πριν από {0} χρόνια + + + πριν από {0} χρόνια + + + πριν από {0} χρόνια + + + πριν από {0} χρόνια + + + πριν από {0} χρόνια + + + πριν από {0} χρόνο + + + πριν από {0} χρόνια + + + {0} χρόνια από τώρα + + + {0} χρόνια από τώρα + + + {0} χρόνια από τώρα + + + {0} χρόνια από τώρα + + + {0} χρόνο από τώρα + + + {0} χρόνια από τώρα + + + ποτέ + + + τώρα + χθες - - πριν από {0} ημέρες + + αύριο + + + πριν από μία ώρα + + + πρίν από μία ώρα από τώρα + + + πριν από ένα λεπτό + + + πρίν από ένα λεπτό από τώρα πριν από έναν μήνα - - πριν από {0} μήνες + + πριν από έναν μήνα από τώρα + + + πριν από ένα δευτερόλεπτο + + + πριν από ένα δευτερόλεπτο από τώρα πριν από έναν χρόνο - - πριν από {0} χρόνια + + πριν από έναν χρόνο από τώρα + + + {0} μέρες + + + {0} μέρες + + + {0} μέρες + + + {0} μέρα + + + {0} days + + + {0} ώρες + + + {0} ώρες + + + {0} ώρες + + + {0} ώρες + + + {0} ώρα + + + {0} ώρες + + + {0} χιλιοστά του δευτερολέπτου + + + {0} χιλιοστά του δευτερολέπτου + + + {0} χιλιοστά του δευτερολέπτου + + + {0} χιλιοστά του δευτερολέπτου + + + {0} χιλιοσtό του δευτερολέπτου + + + {0} χιλιοστά του δευτερολέπτου + + + {0} λεπτά + + + {0} λεπτά + + + {0} λεπτά + + + {0} λεπτά + + + {0} λεπτό + + + {0} λεπτά + + + {0} μήνες + + + {0} μήνες + + + {0} μήνες + + + {0} μήνες + + + {0} μήνα + + + {0} μήνες + + + {0} δευτερόλεπτα + + + {0} δευτερόλεπτα + + + {0} δευτερόλεπτα + + + {0} δευτερόλεπτα + + + {0} δευτερόλεπτο + + + {0} δευτερόλεπτα + + + {0} βδομάδες + + + {0} βδομάδες + + + {0} βδομάδες + + + {0} βδομάδες + + + {0} βδομάδα + + + {0} βδομάδες + + + {0} χρόνια + + + {0} χρόνια + + + {0} χρόνια + + + {0} χρόνια + + + {0} χρόνο + + + {0} χρόνια + + + 1 μέρα + + + 1 ώρα + + + 1 χιλιοσtό του δευτερολέπτου + + + 1 λεπτό + + + 1 μήνα + + + 1 δευτερόλεπτο + + + 1 βδομάδα + + + 1 χρόνο + + + μηδέν χρόνος \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.es.resx b/src/Humanizer/Properties/Resources.es.resx index b738e9da1..d92340cd5 100644 --- a/src/Humanizer/Properties/Resources.es.resx +++ b/src/Humanizer/Properties/Resources.es.resx @@ -231,4 +231,16 @@ ahora + + {0} meses + + + {0} años + + + un mes + + + un año + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.fa.resx b/src/Humanizer/Properties/Resources.fa.resx index 412163855..ee6d7469a 100644 --- a/src/Humanizer/Properties/Resources.fa.resx +++ b/src/Humanizer/Properties/Resources.fa.resx @@ -231,4 +231,16 @@ یک سال بعد + + {0} ماه + + + {0} سال + + + یک ماه + + + یک سال + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.fr-BE.resx b/src/Humanizer/Properties/Resources.fr-BE.resx index 0a46359ab..50e6f4cf4 100644 --- a/src/Humanizer/Properties/Resources.fr-BE.resx +++ b/src/Humanizer/Properties/Resources.fr-BE.resx @@ -231,4 +231,16 @@ pas de temps + + {0} mois + + + {0} ans + + + 1 mois + + + 1 année + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.fr.resx b/src/Humanizer/Properties/Resources.fr.resx index 1503b4aa7..3ffc118db 100644 --- a/src/Humanizer/Properties/Resources.fr.resx +++ b/src/Humanizer/Properties/Resources.fr.resx @@ -234,4 +234,16 @@ jamais + + {0} mois + + + {0} ans + + + 1 mois + + + 1 année + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.he.resx b/src/Humanizer/Properties/Resources.he.resx index 3ed0a17b9..1c9720fb7 100644 --- a/src/Humanizer/Properties/Resources.he.resx +++ b/src/Humanizer/Properties/Resources.he.resx @@ -373,6 +373,10 @@ בעוד {0} שנים in {0} years + + כעת + now + מחר tomorrow @@ -409,4 +413,28 @@ בעוד שנייה in a second + + {0} חודשים + + + חודשיים + + + {0} חודשים + + + {0} שנים + + + שנתיים + + + {0} שנים + + + חודש + + + שנה + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.hr.resx b/src/Humanizer/Properties/Resources.hr.resx index 8d7a0b703..0c9ff334c 100644 --- a/src/Humanizer/Properties/Resources.hr.resx +++ b/src/Humanizer/Properties/Resources.hr.resx @@ -171,6 +171,9 @@ {0} dana + + {0} dana + {0} sati @@ -276,4 +279,22 @@ za godinu dana + + {0} mjeseci + + + {0} mjeseca + + + {0} godina + + + {0} godine + + + 1 mjesec + + + 1 godina + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.hu.resx b/src/Humanizer/Properties/Resources.hu.resx index df687010d..b15b707e3 100644 --- a/src/Humanizer/Properties/Resources.hu.resx +++ b/src/Humanizer/Properties/Resources.hu.resx @@ -231,4 +231,16 @@ egy év múlva + + {0} hónap + + + {0} év + + + egy hónap + + + egy év + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.id.resx b/src/Humanizer/Properties/Resources.id.resx index e7c4c6023..88711e17c 100644 --- a/src/Humanizer/Properties/Resources.id.resx +++ b/src/Humanizer/Properties/Resources.id.resx @@ -269,4 +269,16 @@ setahun dari sekarang one year from now + + {0} bulan + + + {0} tahun + + + 1 bulan + + + 1 tahun + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.it.resx b/src/Humanizer/Properties/Resources.it.resx index 2be83b07a..58e5d7d65 100644 --- a/src/Humanizer/Properties/Resources.it.resx +++ b/src/Humanizer/Properties/Resources.it.resx @@ -1,6 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + un secondo fa - + {0} secondi fa - + un minuto fa - + {0} minuti fa - + un'ora fa - + {0} ore fa - + ieri - + {0} giorni fa - + un mese fa - + {0} mesi fa - + un anno fa - + {0} anni fa - + {0} giorni - + {0} ore - + {0} millisecondi - + {0} minuti - + {0} secondi - + 1 giorno - + 1 ora - + 1 millisecondo - + 1 minuto - + 1 secondo - + 0 secondi - + {0} settimane - + 1 settimana - + tra {0} giorni - + tra {0} ore - + tra {0} minuti - + tra {0} mesi - + tra {0} secondi - + tra {0} anni - + adesso - + domani - + tra un'ora - + tra un minuto - + tra un mese - + tra un secondo - + tra un anno + + {0} mesi + + + {0} anni + + + 1 mese + + + 1 anno + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.ja.resx b/src/Humanizer/Properties/Resources.ja.resx index 34b8fe66b..bddb2d20d 100644 --- a/src/Humanizer/Properties/Resources.ja.resx +++ b/src/Humanizer/Properties/Resources.ja.resx @@ -231,4 +231,16 @@ 来年 + + {0} ヶ月 + + + {0} 年 + + + 1 ヶ月 + + + 1 年間の + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.lv.resx b/src/Humanizer/Properties/Resources.lv.resx new file mode 100644 index 000000000..94ccb5552 --- /dev/null +++ b/src/Humanizer/Properties/Resources.lv.resx @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pirms sekundes + + + pirms {0} sekundēm + + + pirms minūtes + + + pirms {0} minūtēm + + + pirms stundas + + + pirms {0} stundām + + + vakardien + + + pirms {0} dienām + + + pirms mēneša + + + pirms {0} mēnešiem + + + pirms gada + + + pirms {0} gadiem + + + {0} dienas + + + {0} stundas + + + {0} milisekundes + + + {0} minūtes + + + {0} sekundes + + + 1 diena + + + 1 stunda + + + 1 milisekunde + + + 1 minūte + + + 1 sekunde + + + bez laika + + + {0} nedēļas + + + 1 nedēļa + + + pēc {0} dienām + + + pēc {0} stundām + + + pēc {0} minūtēm + + + pēc {0} mēnešiem + + + pēc {0} sekundēm + + + pēc {0} gadiem + + + tagad + + + rītdien + + + pēc stundas + + + pēc minūtēs + + + pēc mēneša + + + pēc sekundes + + + pēc gada + + + pēc {0} stundām + + + pēc {0} minūtēm + + + pirms {0} sekundēm + + + pēc {0} sekundēm + + + pēc {0} gadiem + + + {0} dienas + + + {0} dienas + + + {0} stundas + + + {0} milisekundes + + + {0} minūtes + + + {0} minūtes + + + {0} sekundes + + + {0} milisekundes + + + pirms {0} dienām + + + pirms {0} dienām + + + pirms {0} dienām + + + pirms {0} dienas + + + pirms {0} dienām + + + pēc {0} dienām + + + pēc {0} dienām + + + pēc {0} dienas + + + pēc {0} dienām + + + pirms {0} stundām + + + pirms {0} stundām + + + pirms {0} stundām + + + pirms {0} stundas + + + pirms {0} stundām + + + pēc {0} stundām + + + pēc {0} stundas + + + pēc {0} stundām + + + pirms {0} minūtēm + + + pirms {0} minūtēm + + + pirms {0} minūtēm + + + pirms {0} minūtes + + + pirms {0} minūtēm + + + pēc {0} minūtēm + + + pēc {0} minūtes + + + pēc {0} minūtēm + + + pirms {0} mēnešiem + + + pirms {0} mēnešiem + + + pirms {0} mēneša + + + pirms {0} mēnešiem + + + pēc {0} mēnešiem + + + pēc {0} mēnešiem + + + pēc {0} mēneša + + + pēc {0} mēnešiem + + + pirms {0} sekundēm + + + pirms {0} sekundēm + + + pirms {0} sekundes + + + pirms {0} sekundēm + + + pēc {0} sekundēm + + + pēc {0} sekundes + + + pēc {0} sekundēm + + + pirms {0} gadiem + + + pirms {0} gadiem + + + pirms {0} gadiem + + + pirms {0} gada + + + pirms {0} gadiem + + + pēc {0} gadiem + + + pēc {0} gada + + + pēc {0} gadiem + + + {0} diena + + + {0} dienas + + + {0} stundas + + + {0} stunda + + + {0} stundas + + + {0} milisekunde + + + {0} milisekundes + + + {0} minūte + + + {0} minūtes + + + {0} sekundes + + + {0} sekunde + + + {0} sekundes + + + {0} nedēļas + + + {0} nedēļas + + + {0} nedēļa + + + {0} nedēļas + + + {0} mēneši + + + {0} gadi + + + 1 mēnesis + + + 1 gads + + + pirms {0} stundām + + + pēc {0} stundām + + + pirms {0} minūtēm + + + pēc {0} minūtēm + + + pirms {0} mēnešiem + + + pēc {0} mēnešiem + + + pirms {0} sekundēm + + + pēc {0} sekundēm + + + pirms {0} gadiem + + + pēc {0} gadiem + + + {0} stundas + + + {0} milisekundes + + + {0} minūtes + + + {0} sekundes + + + {0} nedēļas + + + nekad + + diff --git a/src/Humanizer/Properties/Resources.nb-NO.resx b/src/Humanizer/Properties/Resources.nb-NO.resx index 240a6ba25..8a731ca43 100644 --- a/src/Humanizer/Properties/Resources.nb-NO.resx +++ b/src/Humanizer/Properties/Resources.nb-NO.resx @@ -231,4 +231,16 @@ ett år fra nå + + {0} måneder + + + {0} år + + + en måned + + + ett år + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.nb.resx b/src/Humanizer/Properties/Resources.nb.resx index 240a6ba25..8a731ca43 100644 --- a/src/Humanizer/Properties/Resources.nb.resx +++ b/src/Humanizer/Properties/Resources.nb.resx @@ -231,4 +231,16 @@ ett år fra nå + + {0} måneder + + + {0} år + + + en måned + + + ett år + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.nl.resx b/src/Humanizer/Properties/Resources.nl.resx index 9139cf7e3..9c72e6662 100644 --- a/src/Humanizer/Properties/Resources.nl.resx +++ b/src/Humanizer/Properties/Resources.nl.resx @@ -192,43 +192,55 @@ geen tijd - + over {0} dagen - + over {0} uur - + over {0} minuten - + over {0} maanden - + over {0} seconden - + over {0} jaar - + nu - + morgen - + over 1 uur - + over 1 minuut - + over 1 maand - + over 1 seconde - + over 1 jaar + + {0} maanden + + + {0} jaar + + + 1 maand + + + 1 jaar + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.pl.resx b/src/Humanizer/Properties/Resources.pl.resx index 44db8f0cd..214e3bad9 100644 --- a/src/Humanizer/Properties/Resources.pl.resx +++ b/src/Humanizer/Properties/Resources.pl.resx @@ -285,4 +285,22 @@ {0} tygodnie + + {0} miesięcy + + + {0} miesiące + + + {0} lat + + + {0} lata + + + 1 miesiąc + + + 1 rok + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.pt.resx b/src/Humanizer/Properties/Resources.pt.resx index 985e39661..60c15f3dd 100644 --- a/src/Humanizer/Properties/Resources.pt.resx +++ b/src/Humanizer/Properties/Resources.pt.resx @@ -231,4 +231,16 @@ agora + + {0} meses + + + {0} anos + + + 1 mês + + + 1 ano + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.resx b/src/Humanizer/Properties/Resources.resx index 16b94e1fa..a9e82425e 100644 --- a/src/Humanizer/Properties/Resources.resx +++ b/src/Humanizer/Properties/Resources.resx @@ -522,4 +522,34 @@ never + + {0} months + + + {0} months + + + {0} months + + + {0} months + + + {0} months + + + {0} years + + + {0} years + + + {0} years + + + {0} years + + + {0} years + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.ro.resx b/src/Humanizer/Properties/Resources.ro.resx index 8dadb6f11..417d8d94d 100644 --- a/src/Humanizer/Properties/Resources.ro.resx +++ b/src/Humanizer/Properties/Resources.ro.resx @@ -231,4 +231,16 @@ niciun timp + + {0}{1} luni + + + {0}{1} ani + + + 1 luna + + + 1 ani + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.ru.resx b/src/Humanizer/Properties/Resources.ru.resx index d7841691d..c10b26311 100644 --- a/src/Humanizer/Properties/Resources.ru.resx +++ b/src/Humanizer/Properties/Resources.ru.resx @@ -339,4 +339,28 @@ через год + + {0} месяцев + + + {0} месяца + + + {0} месяц + + + {0} лет + + + {0} года + + + {0} год + + + один месяц + + + один год + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.sk.resx b/src/Humanizer/Properties/Resources.sk.resx index acebbfe4f..5bf60d03d 100644 --- a/src/Humanizer/Properties/Resources.sk.resx +++ b/src/Humanizer/Properties/Resources.sk.resx @@ -285,4 +285,22 @@ {0} týždne + + {0} mesiacov + + + {0} mesiace + + + {0} rokov + + + {0} roky + + + 1 mesiac + + + 1 rok + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.sl.resx b/src/Humanizer/Properties/Resources.sl.resx index 77f8c1621..4a5029baf 100644 --- a/src/Humanizer/Properties/Resources.sl.resx +++ b/src/Humanizer/Properties/Resources.sl.resx @@ -342,4 +342,28 @@ nikoli + + {0} mesecev + + + {0} meseca + + + {0} mesece + + + {0} let + + + {0} leti + + + {0} leta + + + 1 mesec + + + 1 leto + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.sr-Latn.resx b/src/Humanizer/Properties/Resources.sr-Latn.resx index 44974d84e..3d596f319 100644 --- a/src/Humanizer/Properties/Resources.sr-Latn.resx +++ b/src/Humanizer/Properties/Resources.sr-Latn.resx @@ -117,172 +117,190 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - -pre sekund - - -pre {0} sekundi - - -pre minut - - -pre {0} minuta - - -pre sat vremena - - -pre {0} sati - - -juče - - -pre {0} dana - - -pre mesec dana - - -pre {0} meseci - - -pre godinu dana - - -pre {0} godina - - -{0} dana - - -{0} sati - - -{0} milisekundi - - -{0} minuta - - -{0} sekundi - - -1 dan - - -1 sat - - -1 milisekunda - - -1 minut - - -1 sekunda - - -bez proteklog vremena - - -{0} nedelja - - -1 nedelja - - -za {0} dana - - -za {0} sati - - -za {0} minuta - - -za {0} meseci - - -za {0} sekundi - - -za {0} godina - - -sada - - -sutra - - -za sat vremena - - -za minut - - -za mesec dana - - -za sekund - - -za godinu dana - - -pre {0} dana - - -za {0} dana - - -pre {0} sata - - -za {0} sata - - -pre {0} minuta - - -za {0} minuta - - -pre {0} meseca - - -za {0} meseca - - -pre {0} sekunde - - -za {0} sekunde - - -pre {0} godine - - -za {0} godine - - -{0} dana - - -{0} sata - - -{0} milisekunde - - -{0} minuta - - -{0} sekunde - - -{0} nedelje - + + pre sekund + + + pre {0} sekundi + + + pre minut + + + pre {0} minuta + + + pre sat vremena + + + pre {0} sati + + + juče + + + pre {0} dana + + + pre mesec dana + + + pre {0} meseci + + + pre godinu dana + + + pre {0} godina + + + {0} dana + + + {0} sati + + + {0} milisekundi + + + {0} minuta + + + {0} sekundi + + + 1 dan + + + 1 sat + + + 1 milisekunda + + + 1 minut + + + 1 sekunda + + + bez proteklog vremena + + + {0} nedelja + + + 1 nedelja + + + za {0} dana + + + za {0} sati + + + za {0} minuta + + + za {0} meseci + + + za {0} sekundi + + + za {0} godina + + + sada + + + sutra + + + za sat vremena + + + za minut + + + za mesec dana + + + za sekund + + + za godinu dana + + + pre {0} dana + + + za {0} dana + + + pre {0} sata + + + za {0} sata + + + pre {0} minuta + + + za {0} minuta + + + pre {0} meseca + + + za {0} meseca + + + pre {0} sekunde + + + za {0} sekunde + + + pre {0} godine + + + za {0} godine + + + {0} dana + + + {0} sata + + + {0} milisekunde + + + {0} minuta + + + {0} sekunde + + + {0} nedelje + + + {0} meseci + + + {0} meseca + + + {0} godina + + + {0} godine + + + 1 mesec + + + 1 godina + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.sr.resx b/src/Humanizer/Properties/Resources.sr.resx index bd9d54e72..1d31059e3 100644 --- a/src/Humanizer/Properties/Resources.sr.resx +++ b/src/Humanizer/Properties/Resources.sr.resx @@ -285,4 +285,22 @@ {0} недеље + + {0} месеци + + + {0} месеца + + + {0} година + + + {0} године + + + 1 месец + + + 1 година + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.sv.resx b/src/Humanizer/Properties/Resources.sv.resx index 5a1fa791c..4a0131672 100644 --- a/src/Humanizer/Properties/Resources.sv.resx +++ b/src/Humanizer/Properties/Resources.sv.resx @@ -231,4 +231,16 @@ om ett år + + {0} månader + + + {0} år + + + en månad + + + ett år + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.tr.resx b/src/Humanizer/Properties/Resources.tr.resx index 0cc608d90..963a18c75 100644 --- a/src/Humanizer/Properties/Resources.tr.resx +++ b/src/Humanizer/Properties/Resources.tr.resx @@ -231,4 +231,16 @@ bir yıl sonra + + {0} ay + + + {0} yıl + + + 1 ay + + + 1 yıl + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.uk.resx b/src/Humanizer/Properties/Resources.uk.resx index dc3481968..1147b8176 100644 --- a/src/Humanizer/Properties/Resources.uk.resx +++ b/src/Humanizer/Properties/Resources.uk.resx @@ -339,4 +339,28 @@ через рік - + + {0} місяців + + + {0} місяці + + + {0} місяць + + + {0} років + + + {0} роки + + + {0} рік + + + один місяць + + + один рік + + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.uz-Cyrl-UZ.resx b/src/Humanizer/Properties/Resources.uz-Cyrl-UZ.resx index f6f910d3d..34ed648f4 100644 --- a/src/Humanizer/Properties/Resources.uz-Cyrl-UZ.resx +++ b/src/Humanizer/Properties/Resources.uz-Cyrl-UZ.resx @@ -204,12 +204,18 @@ {0} минут + + {0} ой + {0} секунд {0} ҳафта + + {0} йил + 1 кун @@ -222,12 +228,18 @@ 1 минут + + 1 ой + 1 секунд 1 ҳафта + + 1 йил + вақт йўқ diff --git a/src/Humanizer/Properties/Resources.uz-Latn-UZ.resx b/src/Humanizer/Properties/Resources.uz-Latn-UZ.resx index 4f9a367bc..00f28f865 100644 --- a/src/Humanizer/Properties/Resources.uz-Latn-UZ.resx +++ b/src/Humanizer/Properties/Resources.uz-Latn-UZ.resx @@ -204,12 +204,18 @@ {0} minut + + {0} oy + {0} sekund {0} hafta + + {0} yil + 1 kun @@ -222,12 +228,18 @@ 1 minut + + 1 oy + 1 sekund 1 hafta + + 1 yil + vaqt yo`q diff --git a/src/Humanizer/Properties/Resources.vi.resx b/src/Humanizer/Properties/Resources.vi.resx index e2e015a60..9a47069d1 100644 --- a/src/Humanizer/Properties/Resources.vi.resx +++ b/src/Humanizer/Properties/Resources.vi.resx @@ -231,4 +231,16 @@ một năm nữa + + {0} tháng + + + {0} năm + + + 1 tháng + + + 1 năm + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.zh-CN.resx b/src/Humanizer/Properties/Resources.zh-CN.resx index d080f8076..d54a24259 100644 --- a/src/Humanizer/Properties/Resources.zh-CN.resx +++ b/src/Humanizer/Properties/Resources.zh-CN.resx @@ -231,4 +231,16 @@ 明年 + + {0} 个月 + + + {0} 年 + + + 1 个月 + + + 1 年 + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.zh-Hans.resx b/src/Humanizer/Properties/Resources.zh-Hans.resx index d080f8076..d54a24259 100644 --- a/src/Humanizer/Properties/Resources.zh-Hans.resx +++ b/src/Humanizer/Properties/Resources.zh-Hans.resx @@ -231,4 +231,16 @@ 明年 + + {0} 个月 + + + {0} 年 + + + 1 个月 + + + 1 年 + \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.zh-Hant.resx b/src/Humanizer/Properties/Resources.zh-Hant.resx index 3f3823235..c8274e226 100644 --- a/src/Humanizer/Properties/Resources.zh-Hant.resx +++ b/src/Humanizer/Properties/Resources.zh-Hant.resx @@ -231,4 +231,16 @@ 明年 + + {0} 個月 + + + {0} 年 + + + 1 個月 + + + 1 年 + \ No newline at end of file diff --git a/src/Humanizer/StringHumanizeExtensions.cs b/src/Humanizer/StringHumanizeExtensions.cs index 3c4a50f5a..b4fe36273 100644 --- a/src/Humanizer/StringHumanizeExtensions.cs +++ b/src/Humanizer/StringHumanizeExtensions.cs @@ -14,7 +14,7 @@ public static class StringHumanizeExtensions static StringHumanizeExtensions() { - PascalCaseWordPartsRegex = new Regex(@"[\p{Lu}]?[\p{Ll}]+|[0-9]+[\p{Ll}]*|[\p{Lu}]+(?=[\p{Lu}][\p{Ll}]|[0-9]|\b)", + PascalCaseWordPartsRegex = new Regex(@"[\p{Lu}]?[\p{Ll}]+|[0-9]+[\p{Ll}]*|[\p{Lu}]+(?=[\p{Lu}][\p{Ll}]|[0-9]|\b)|[\p{Lo}]+", RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture | RegexOptionsUtil.Compiled); FreestandingSpacingCharRegex = new Regex(@"\s[-_]|[-_]\s", RegexOptionsUtil.Compiled); } diff --git a/src/Humanizer/TimeSpanHumanizeExtensions.cs b/src/Humanizer/TimeSpanHumanizeExtensions.cs index a384c9f19..e098c6c2f 100644 --- a/src/Humanizer/TimeSpanHumanizeExtensions.cs +++ b/src/Humanizer/TimeSpanHumanizeExtensions.cs @@ -13,8 +13,9 @@ namespace Humanizer /// public static class TimeSpanHumanizeExtensions { - private const int _lastTimeUnitTypeIndexImplemented = (int)TimeUnit.Week; private const int _daysInAWeek = 7; + private const double _daysInAYear = 365.2425; // see https://en.wikipedia.org/wiki/Gregorian_calendar + private const double _daysInAMonth = _daysInAYear / 12; /// /// Turns a TimeSpan into a human readable form. E.g. 1 day. @@ -22,7 +23,7 @@ public static class TimeSpanHumanizeExtensions /// /// The maximum number of time units to return. Defaulted is 1 which means the largest unit is returned /// Culture to use. If null, current thread's UI culture is used. - /// The maximum unit of time to output. + /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger 30 days by calculating with 365.2425 days a year and 30.4369 days a month. /// The minimum unit of time to output. /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. /// @@ -38,19 +39,19 @@ public static string Humanize(this TimeSpan timeSpan, int precision = 1, Culture /// The maximum number of time units to return. /// Controls whether empty time units should be counted towards maximum number of time units. Leading empty time units never count. /// Culture to use. If null, current thread's UI culture is used. - /// The maximum unit of time to output. + /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger than 30 days by calculating with 365.2425 days a year and 30.4369 days a month. /// The minimum unit of time to output. /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. /// public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string collectionSeparator = ", ") { - var timeParts = CreateTheTimePartsWithUperAndLowerLimits(timeSpan, culture, maxUnit, minUnit); + var timeParts = CreateTheTimePartsWithUpperAndLowerLimits(timeSpan, culture, maxUnit, minUnit); timeParts = SetPrecisionOfTimeSpan(timeParts, precision, countEmptyUnits); return ConcatenateTimeSpanParts(timeParts, collectionSeparator); } - private static IEnumerable CreateTheTimePartsWithUperAndLowerLimits(TimeSpan timespan, CultureInfo culture, TimeUnit maxUnit, TimeUnit minUnit) + private static IEnumerable CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan timespan, CultureInfo culture, TimeUnit maxUnit, TimeUnit minUnit) { var cultureFormatter = Configurator.GetFormatter(culture); var firstValueFound = false; @@ -78,14 +79,12 @@ private static IEnumerable CreateTheTimePartsWithUperAndLowerLimits(Time private static IEnumerable GetEnumTypesForTimeUnit() { var enumTypeEnumerator = (IEnumerable)Enum.GetValues(typeof(TimeUnit)); - enumTypeEnumerator = enumTypeEnumerator.Take(_lastTimeUnitTypeIndexImplemented + 1); - return enumTypeEnumerator.Reverse(); } private static string GetTimeUnitPart(TimeUnit timeUnitToGet, TimeSpan timespan, CultureInfo culture, TimeUnit maximumTimeUnit, TimeUnit minimumTimeUnit, IFormatter cultureFormatter) { - if(timeUnitToGet <= maximumTimeUnit && timeUnitToGet >= minimumTimeUnit) + if (timeUnitToGet <= maximumTimeUnit && timeUnitToGet >= minimumTimeUnit) { var isTimeUnitToGetTheMaximumTimeUnit = (timeUnitToGet == maximumTimeUnit); var numberOfTimeUnits = GetTimeUnitNumericalValue(timeUnitToGet, timespan, isTimeUnitToGetTheMaximumTimeUnit); @@ -111,21 +110,38 @@ private static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan ti case TimeUnit.Week: return GetSpecialCaseWeeksAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit); case TimeUnit.Month: - // To be implemented + return GetSpecialCaseMonthAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit); case TimeUnit.Year: - // To be implemented + return GetSpecialCaseYearAsInteger(timespan); default: return 0; } } - private static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) + private static int GetSpecialCaseMonthAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) { if (isTimeUnitToGetTheMaximumTimeUnit) + { + return (int)((double)timespan.Days / _daysInAMonth); + } + else + { + var remainingDays = (double)timespan.Days % _daysInAYear; + return (int)(remainingDays / _daysInAMonth); + } + } + + private static int GetSpecialCaseYearAsInteger(TimeSpan timespan) + { + return (int)((double)timespan.Days / _daysInAYear); + } + + private static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) + { + if (isTimeUnitToGetTheMaximumTimeUnit || timespan.Days < _daysInAMonth) { return timespan.Days / _daysInAWeek; } - // To be implemented with the implementation of Month and Year return 0; } @@ -135,7 +151,12 @@ private static int GetSpecialCaseDaysAsInteger(TimeSpan timespan, bool isTimeUni { return timespan.Days; } - return timespan.Days % _daysInAWeek; + if (timespan.Days < _daysInAMonth) + { + var remainingDays = timespan.Days % _daysInAWeek; + return remainingDays; + } + return (int)((double)timespan.Days % _daysInAMonth); } private static int GetNormalCaseTimeAsInteger(int timeNumberOfUnits, double totalTimeNumberOfUnits, bool isTimeUnitToGetTheMaximumTimeUnit) @@ -194,4 +215,4 @@ private static string ConcatenateTimeSpanParts(IEnumerable timeSpanParts return string.Join(collectionSeparator, timeSpanParts); } } -} \ No newline at end of file +} diff --git a/src/Humanizer/ToQuantityExtensions.cs b/src/Humanizer/ToQuantityExtensions.cs index 574bce730..021a62e4a 100644 --- a/src/Humanizer/ToQuantityExtensions.cs +++ b/src/Humanizer/ToQuantityExtensions.cs @@ -67,7 +67,44 @@ public static string ToQuantity(this string input, int quantity, string format, return input.ToQuantity(quantity, showQuantityAs: ShowQuantityAs.Numeric, format: format, formatProvider: formatProvider); } - private static string ToQuantity(this string input, int quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric, string format = null, IFormatProvider formatProvider = null) + /// + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word + /// + /// The word to be prefixed + /// The quantity of the word + /// How to show the quantity. Numeric by default + /// + /// "request".ToQuantity(0) => "0 requests" + /// "request".ToQuantity(1) => "1 request" + /// "request".ToQuantity(2) => "2 requests" + /// "men".ToQuantity(2) => "2 men" + /// "process".ToQuantity(1200, ShowQuantityAs.Words) => "one thousand two hundred processes" + /// + /// + public static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric) + { + return input.ToQuantity(quantity, showQuantityAs, format: null, formatProvider: null); + } + + /// + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word + /// + /// The word to be prefixed + /// The quantity of the word + /// A standard or custom numeric format string. + /// An object that supplies culture-specific formatting information. + /// + /// "request".ToQuantity(0) => "0 requests" + /// "request".ToQuantity(10000, format: "N0") => "10,000 requests" + /// "request".ToQuantity(1, format: "N0") => "1 request" + /// + /// + public static string ToQuantity(this string input, long quantity, string format, IFormatProvider formatProvider = null) + { + return input.ToQuantity(quantity, showQuantityAs: ShowQuantityAs.Numeric, format: format, formatProvider: formatProvider); + } + + private static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric, string format = null, IFormatProvider formatProvider = null) { var transformedInput = quantity == 1 ? input.Singularize(inputIsKnownToBePlural: false) @@ -79,6 +116,7 @@ private static string ToQuantity(this string input, int quantity, ShowQuantityAs if (showQuantityAs == ShowQuantityAs.Numeric) return string.Format(formatProvider, "{0} {1}", quantity.ToString(format, formatProvider), transformedInput); + return string.Format("{0} {1}", quantity.ToWords(), transformedInput); } } diff --git a/src/Humanizer/project.json b/src/Humanizer/project.json deleted file mode 100644 index 2ffa2be28..000000000 --- a/src/Humanizer/project.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "frameworks": { - "netstandard1.0": {} - } -} diff --git a/src/PublicApiApprovalTest.approve_public_api.approved.txt b/src/PublicApiApprovalTest.approve_public_api.approved.txt deleted file mode 100644 index 349ae0586..000000000 --- a/src/PublicApiApprovalTest.approve_public_api.approved.txt +++ /dev/null @@ -1,1147 +0,0 @@ -[assembly: System.Resources.NeutralResourcesLanguageAttribute("en")] -[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETPortable,Version=v5.0", FrameworkDisplayName=".NET Portable Subset")] - -namespace Humanizer.Bytes -{ - - public class ByteRate - { - public ByteRate(Humanizer.Bytes.ByteSize size, System.TimeSpan interval) { } - public System.TimeSpan Interval { get; } - public Humanizer.Bytes.ByteSize Size { get; } - public string Humanize(Humanizer.Localisation.TimeUnit timeUnit = 1) { } - public string Humanize(string format, Humanizer.Localisation.TimeUnit timeUnit = 1) { } - } - public struct ByteSize : System.IComparable, System.IComparable, System.IEquatable - { - public const long BitsInByte = 8; - public const string BitSymbol = "b"; - public const long BytesInGigabyte = 1073741824; - public const long BytesInKilobyte = 1024; - public const long BytesInMegabyte = 1048576; - public const long BytesInTerabyte = 1099511627776; - public const string ByteSymbol = "B"; - public const string GigabyteSymbol = "GB"; - public const string KilobyteSymbol = "KB"; - public static readonly Humanizer.Bytes.ByteSize MaxValue; - public const string MegabyteSymbol = "MB"; - public static readonly Humanizer.Bytes.ByteSize MinValue; - public const string TerabyteSymbol = "TB"; - public ByteSize(double byteSize) { } - public long Bits { get; } - public double Bytes { get; } - public double Gigabytes { get; } - public double Kilobytes { get; } - public string LargestWholeNumberSymbol { get; } - public double LargestWholeNumberValue { get; } - public double Megabytes { get; } - public double Terabytes { get; } - public Humanizer.Bytes.ByteSize Add(Humanizer.Bytes.ByteSize bs) { } - public Humanizer.Bytes.ByteSize AddBits(long value) { } - public Humanizer.Bytes.ByteSize AddBytes(double value) { } - public Humanizer.Bytes.ByteSize AddGigabytes(double value) { } - public Humanizer.Bytes.ByteSize AddKilobytes(double value) { } - public Humanizer.Bytes.ByteSize AddMegabytes(double value) { } - public Humanizer.Bytes.ByteSize AddTerabytes(double value) { } - public int CompareTo(object obj) { } - public int CompareTo(Humanizer.Bytes.ByteSize other) { } - public override bool Equals(object value) { } - public bool Equals(Humanizer.Bytes.ByteSize value) { } - public static Humanizer.Bytes.ByteSize FromBits(long value) { } - public static Humanizer.Bytes.ByteSize FromBytes(double value) { } - public static Humanizer.Bytes.ByteSize FromGigabytes(double value) { } - public static Humanizer.Bytes.ByteSize FromKilobytes(double value) { } - public static Humanizer.Bytes.ByteSize FromMegabytes(double value) { } - public static Humanizer.Bytes.ByteSize FromTerabytes(double value) { } - public override int GetHashCode() { } - public static Humanizer.Bytes.ByteSize Parse(string s) { } - public Humanizer.Bytes.ByteSize Subtract(Humanizer.Bytes.ByteSize bs) { } - public override string ToString() { } - public string ToString(string format) { } - public static bool TryParse(string s, out Humanizer.Bytes.ByteSize result) { } - } -} -namespace Humanizer -{ - - public class static ByteSizeExtensions - { - public static Humanizer.Bytes.ByteSize Bits(this byte input) { } - public static Humanizer.Bytes.ByteSize Bits(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Bits(this short input) { } - public static Humanizer.Bytes.ByteSize Bits(this ushort input) { } - public static Humanizer.Bytes.ByteSize Bits(this int input) { } - public static Humanizer.Bytes.ByteSize Bits(this uint input) { } - public static Humanizer.Bytes.ByteSize Bits(this long input) { } - public static Humanizer.Bytes.ByteSize Bytes(this byte input) { } - public static Humanizer.Bytes.ByteSize Bytes(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Bytes(this short input) { } - public static Humanizer.Bytes.ByteSize Bytes(this ushort input) { } - public static Humanizer.Bytes.ByteSize Bytes(this int input) { } - public static Humanizer.Bytes.ByteSize Bytes(this uint input) { } - public static Humanizer.Bytes.ByteSize Bytes(this double input) { } - public static Humanizer.Bytes.ByteSize Bytes(this long input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this byte input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this short input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this ushort input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this int input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this uint input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this double input) { } - public static Humanizer.Bytes.ByteSize Gigabytes(this long input) { } - public static string Humanize(this Humanizer.Bytes.ByteSize input, string format = null) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this byte input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this short input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this ushort input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this int input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this uint input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this double input) { } - public static Humanizer.Bytes.ByteSize Kilobytes(this long input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this byte input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this short input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this ushort input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this int input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this uint input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this double input) { } - public static Humanizer.Bytes.ByteSize Megabytes(this long input) { } - public static Humanizer.Bytes.ByteRate Per(this Humanizer.Bytes.ByteSize size, System.TimeSpan interval) { } - public static Humanizer.Bytes.ByteSize Terabytes(this byte input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this sbyte input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this short input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this ushort input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this int input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this uint input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this double input) { } - public static Humanizer.Bytes.ByteSize Terabytes(this long input) { } - } - public class static CasingExtensions - { - public static string ApplyCase(this string input, Humanizer.LetterCasing casing) { } - } - public class static CollectionHumanizeExtensions - { - public static string Humanize(this System.Collections.Generic.IEnumerable collection) { } - public static string Humanize(this System.Collections.Generic.IEnumerable collection, System.Func displayFormatter) { } - public static string Humanize(this System.Collections.Generic.IEnumerable collection, string separator) { } - public static string Humanize(this System.Collections.Generic.IEnumerable collection, System.Func displayFormatter, string separator) { } - } - public class static DateHumanizeExtensions - { - public static string Humanize(this System.DateTime input, bool utcDate = True, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } - public static string Humanize(this System.Nullable input, bool utcDate = True, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } - public static string Humanize(this System.DateTimeOffset input, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } - public static string Humanize(this System.Nullable input, System.Nullable dateToCompareAgainst = null, System.Globalization.CultureInfo culture = null) { } - } - public class static EnumDehumanizeExtensions - { - public static TTargetEnum DehumanizeTo(this string input) - where TTargetEnum : struct, System.IComparable, System.IFormattable { } - public static System.Enum DehumanizeTo(this string input, System.Type targetEnum, Humanizer.OnNoMatch onNoMatch = 0) { } - } - public class static EnumHumanizeExtensions - { - public static string Humanize(this System.Enum input) { } - public static string Humanize(this System.Enum input, Humanizer.LetterCasing casing) { } - } - public enum GrammaticalCase - { - Nominative = 0, - Genitive = 1, - Dative = 2, - Accusative = 3, - Instrumental = 4, - Prepositional = 5, - } - public enum GrammaticalGender - { - Masculine = 0, - Feminine = 1, - Neuter = 2, - } - public class In - { - public In() { } - public static System.DateTime April { get; } - public static System.DateTime August { get; } - public static System.DateTime December { get; } - public static System.DateTime February { get; } - public static System.DateTime January { get; } - public static System.DateTime July { get; } - public static System.DateTime June { get; } - public static System.DateTime March { get; } - public static System.DateTime May { get; } - public static System.DateTime November { get; } - public static System.DateTime October { get; } - public static System.DateTime September { get; } - public static System.DateTime AprilOf(int year) { } - public static System.DateTime AugustOf(int year) { } - public static System.DateTime DecemberOf(int year) { } - public static System.DateTime FebruaryOf(int year) { } - public static System.DateTime JanuaryOf(int year) { } - public static System.DateTime JulyOf(int year) { } - public static System.DateTime JuneOf(int year) { } - public static System.DateTime MarchOf(int year) { } - public static System.DateTime MayOf(int year) { } - public static System.DateTime NovemberOf(int year) { } - public static System.DateTime OctoberOf(int year) { } - public static System.DateTime SeptemberOf(int year) { } - public static System.DateTime TheYear(int year) { } - public class static Eight - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Five - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Four - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Nine - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static One - { - public static System.DateTime Day { get; } - public static System.DateTime Hour { get; } - public static System.DateTime Minute { get; } - public static System.DateTime Month { get; } - public static System.DateTime Second { get; } - public static System.DateTime Week { get; } - public static System.DateTime Year { get; } - public static System.DateTime DayFrom(System.DateTime date) { } - public static System.DateTime HourFrom(System.DateTime date) { } - public static System.DateTime MinuteFrom(System.DateTime date) { } - public static System.DateTime MonthFrom(System.DateTime date) { } - public static System.DateTime SecondFrom(System.DateTime date) { } - public static System.DateTime WeekFrom(System.DateTime date) { } - public static System.DateTime YearFrom(System.DateTime date) { } - } - public class static Seven - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Six - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Ten - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Three - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - public class static Two - { - public static System.DateTime Days { get; } - public static System.DateTime Hours { get; } - public static System.DateTime Minutes { get; } - public static System.DateTime Months { get; } - public static System.DateTime Seconds { get; } - public static System.DateTime Weeks { get; } - public static System.DateTime Years { get; } - public static System.DateTime DaysFrom(System.DateTime date) { } - public static System.DateTime HoursFrom(System.DateTime date) { } - public static System.DateTime MinutesFrom(System.DateTime date) { } - public static System.DateTime MonthsFrom(System.DateTime date) { } - public static System.DateTime SecondsFrom(System.DateTime date) { } - public static System.DateTime WeeksFrom(System.DateTime date) { } - public static System.DateTime YearsFrom(System.DateTime date) { } - } - } - public class static InflectorExtensions - { - public static string Camelize(this string input) { } - public static string Dasherize(this string underscoredWord) { } - public static string Hyphenate(this string underscoredWord) { } - public static string Pascalize(this string input) { } - public static string Pluralize(this string word, bool inputIsKnownToBeSingular = True) { } - public static string Singularize(this string word, bool inputIsKnownToBePlural = True) { } - public static string Titleize(this string input) { } - public static string Underscore(this string input) { } - } - public interface IStringTransformer - { - string Transform(string input); - } - public interface ITruncator - { - string Truncate(string value, int length, string truncationString, Humanizer.TruncateFrom truncateFrom = 1); - } - public enum LetterCasing - { - Title = 0, - AllCaps = 1, - LowerCase = 2, - Sentence = 3, - } - public class static MetricNumeralExtensions - { - public static double FromMetric(this string input) { } - public static string ToMetric(this int input, bool hasSpace = False, bool useSymbol = True) { } - public static string ToMetric(this double input, bool hasSpace = False, bool useSymbol = True) { } - } - public class NoMatchFoundException : System.Exception - { - public NoMatchFoundException() { } - public NoMatchFoundException(string message) { } - public NoMatchFoundException(string message, System.Exception inner) { } - } - public class static NumberToTimeSpanExtensions - { - public static System.TimeSpan Days(this byte days) { } - public static System.TimeSpan Days(this sbyte days) { } - public static System.TimeSpan Days(this short days) { } - public static System.TimeSpan Days(this ushort days) { } - public static System.TimeSpan Days(this int days) { } - public static System.TimeSpan Days(this uint days) { } - public static System.TimeSpan Days(this long days) { } - public static System.TimeSpan Days(this ulong days) { } - public static System.TimeSpan Days(this double days) { } - public static System.TimeSpan Hours(this byte hours) { } - public static System.TimeSpan Hours(this sbyte hours) { } - public static System.TimeSpan Hours(this short hours) { } - public static System.TimeSpan Hours(this ushort hours) { } - public static System.TimeSpan Hours(this int hours) { } - public static System.TimeSpan Hours(this uint hours) { } - public static System.TimeSpan Hours(this long hours) { } - public static System.TimeSpan Hours(this ulong hours) { } - public static System.TimeSpan Hours(this double hours) { } - public static System.TimeSpan Milliseconds(this byte ms) { } - public static System.TimeSpan Milliseconds(this sbyte ms) { } - public static System.TimeSpan Milliseconds(this short ms) { } - public static System.TimeSpan Milliseconds(this ushort ms) { } - public static System.TimeSpan Milliseconds(this int ms) { } - public static System.TimeSpan Milliseconds(this uint ms) { } - public static System.TimeSpan Milliseconds(this long ms) { } - public static System.TimeSpan Milliseconds(this ulong ms) { } - public static System.TimeSpan Milliseconds(this double ms) { } - public static System.TimeSpan Minutes(this byte minutes) { } - public static System.TimeSpan Minutes(this sbyte minutes) { } - public static System.TimeSpan Minutes(this short minutes) { } - public static System.TimeSpan Minutes(this ushort minutes) { } - public static System.TimeSpan Minutes(this int minutes) { } - public static System.TimeSpan Minutes(this uint minutes) { } - public static System.TimeSpan Minutes(this long minutes) { } - public static System.TimeSpan Minutes(this ulong minutes) { } - public static System.TimeSpan Minutes(this double minutes) { } - public static System.TimeSpan Seconds(this byte seconds) { } - public static System.TimeSpan Seconds(this sbyte seconds) { } - public static System.TimeSpan Seconds(this short seconds) { } - public static System.TimeSpan Seconds(this ushort seconds) { } - public static System.TimeSpan Seconds(this int seconds) { } - public static System.TimeSpan Seconds(this uint seconds) { } - public static System.TimeSpan Seconds(this long seconds) { } - public static System.TimeSpan Seconds(this ulong seconds) { } - public static System.TimeSpan Seconds(this double seconds) { } - public static System.TimeSpan Weeks(this byte input) { } - public static System.TimeSpan Weeks(this sbyte input) { } - public static System.TimeSpan Weeks(this short input) { } - public static System.TimeSpan Weeks(this ushort input) { } - public static System.TimeSpan Weeks(this int input) { } - public static System.TimeSpan Weeks(this uint input) { } - public static System.TimeSpan Weeks(this long input) { } - public static System.TimeSpan Weeks(this ulong input) { } - public static System.TimeSpan Weeks(this double input) { } - } - public class static NumberToWordsExtension - { - public static string ToOrdinalWords(this int number, System.Globalization.CultureInfo culture = null) { } - public static string ToOrdinalWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo culture = null) { } - public static string ToWords(this int number, System.Globalization.CultureInfo culture = null) { } - public static string ToWords(this int number, Humanizer.GrammaticalGender gender, System.Globalization.CultureInfo culture = null) { } - } - public class On - { - public On() { } - public class April - { - public April() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class August - { - public August() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class December - { - public December() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class February - { - public February() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class January - { - public January() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class July - { - public July() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class June - { - public June() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class March - { - public March() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class May - { - public May() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class November - { - public November() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class October - { - public October() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The31st { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - public class September - { - public September() { } - public static System.DateTime The10th { get; } - public static System.DateTime The11th { get; } - public static System.DateTime The12th { get; } - public static System.DateTime The13th { get; } - public static System.DateTime The14th { get; } - public static System.DateTime The15th { get; } - public static System.DateTime The16th { get; } - public static System.DateTime The17th { get; } - public static System.DateTime The18th { get; } - public static System.DateTime The19th { get; } - public static System.DateTime The1st { get; } - public static System.DateTime The20th { get; } - public static System.DateTime The21st { get; } - public static System.DateTime The22nd { get; } - public static System.DateTime The23rd { get; } - public static System.DateTime The24th { get; } - public static System.DateTime The25th { get; } - public static System.DateTime The26th { get; } - public static System.DateTime The27th { get; } - public static System.DateTime The28th { get; } - public static System.DateTime The29th { get; } - public static System.DateTime The2nd { get; } - public static System.DateTime The30th { get; } - public static System.DateTime The3rd { get; } - public static System.DateTime The4th { get; } - public static System.DateTime The5th { get; } - public static System.DateTime The6th { get; } - public static System.DateTime The7th { get; } - public static System.DateTime The8th { get; } - public static System.DateTime The9th { get; } - public static System.DateTime The(int dayNumber) { } - } - } - public enum OnNoMatch - { - ThrowsException = 0, - ReturnsNull = 1, - } - public class static OrdinalizeExtensions - { - public static string Ordinalize(this string numberString) { } - public static string Ordinalize(this string numberString, Humanizer.GrammaticalGender gender) { } - public static string Ordinalize(this int number) { } - public static string Ordinalize(this int number, Humanizer.GrammaticalGender gender) { } - } - public enum Plurality - { - Singular = 0, - Plural = 1, - CouldBeEither = 2, - } - public class static PrepositionsExtensions - { - public static System.DateTime At(this System.DateTime date, int hour, int min = 0, int second = 0, int millisecond = 0) { } - public static System.DateTime AtMidnight(this System.DateTime date) { } - public static System.DateTime AtNoon(this System.DateTime date) { } - public static System.DateTime In(this System.DateTime date, int year) { } - } - public class static RomanNumeralExtensions - { - public static int FromRoman(this string input) { } - public static string ToRoman(this int input) { } - } - public enum ShowQuantityAs - { - None = 0, - Numeric = 1, - Words = 2, - } - public class static StringDehumanizeExtensions - { - public static string Dehumanize(this string input) { } - } - public class static StringExtensions - { - public static string FormatWith(this string format, params object[] args) { } - public static string FormatWith(this string format, System.IFormatProvider provider, params object[] args) { } - } - public class static StringHumanizeExtensions - { - public static string Humanize(this string input) { } - public static string Humanize(this string input, Humanizer.LetterCasing casing) { } - } - public class static TimeSpanHumanizeExtensions - { - public static string Humanize(this System.TimeSpan timeSpan, int precision = 1, System.Globalization.CultureInfo culture = null, Humanizer.Localisation.TimeUnit maxUnit = 5, Humanizer.Localisation.TimeUnit minUnit = 0, string collectionSeparator = ", ") { } - public static string Humanize(this System.TimeSpan timeSpan, int precision, bool countEmptyUnits, System.Globalization.CultureInfo culture = null, Humanizer.Localisation.TimeUnit maxUnit = 5, Humanizer.Localisation.TimeUnit minUnit = 0, string collectionSeparator = ", ") { } - } - public class static To - { - public static Humanizer.IStringTransformer LowerCase { get; } - public static Humanizer.IStringTransformer SentenceCase { get; } - public static Humanizer.IStringTransformer TitleCase { get; } - public static Humanizer.IStringTransformer UpperCase { get; } - public static string Transform(this string input, params Humanizer.IStringTransformer[] transformers) { } - } - public class static ToQuantityExtensions - { - public static string ToQuantity(this string input, int quantity, Humanizer.ShowQuantityAs showQuantityAs = 1) { } - public static string ToQuantity(this string input, int quantity, string format, System.IFormatProvider formatProvider = null) { } - } - public class static TruncateExtensions - { - public static string Truncate(this string input, int length) { } - public static string Truncate(this string input, int length, Humanizer.ITruncator truncator, Humanizer.TruncateFrom from = 1) { } - public static string Truncate(this string input, int length, string truncationString, Humanizer.TruncateFrom from = 1) { } - public static string Truncate(this string input, int length, string truncationString, Humanizer.ITruncator truncator, Humanizer.TruncateFrom from = 1) { } - } - public enum TruncateFrom - { - Left = 0, - Right = 1, - } - public class static Truncator - { - public static Humanizer.ITruncator FixedLength { get; } - public static Humanizer.ITruncator FixedNumberOfCharacters { get; } - public static Humanizer.ITruncator FixedNumberOfWords { get; } - } -} -namespace Humanizer.Configuration -{ - - public class static Configurator - { - public static Humanizer.Configuration.LocaliserRegistry CollectionFormatters { get; } - public static Humanizer.DateTimeHumanizeStrategy.IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } - public static Humanizer.DateTimeHumanizeStrategy.IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy { get; set; } - public static System.Func EnumDescriptionPropertyLocator { get; set; } - public static Humanizer.Configuration.LocaliserRegistry Formatters { get; } - public static Humanizer.Configuration.LocaliserRegistry NumberToWordsConverters { get; } - public static Humanizer.Configuration.LocaliserRegistry Ordinalizers { get; } - } - public class LocaliserRegistry - where TLocaliser : class - { - public LocaliserRegistry(TLocaliser defaultLocaliser) { } - public LocaliserRegistry(System.Func defaultLocaliser) { } - public void Register(string localeCode, TLocaliser localiser) { } - public void Register(string localeCode, System.Func localiser) { } - public TLocaliser ResolveForCulture(System.Globalization.CultureInfo culture) { } - public TLocaliser ResolveForUiCulture() { } - } -} -namespace Humanizer.DateTimeHumanizeStrategy -{ - - public class DefaultDateTimeHumanizeStrategy : Humanizer.DateTimeHumanizeStrategy.IDateTimeHumanizeStrategy - { - public DefaultDateTimeHumanizeStrategy() { } - public string Humanize(System.DateTime input, System.DateTime comparisonBase, System.Globalization.CultureInfo culture) { } - } - public class DefaultDateTimeOffsetHumanizeStrategy : Humanizer.DateTimeHumanizeStrategy.IDateTimeOffsetHumanizeStrategy - { - public DefaultDateTimeOffsetHumanizeStrategy() { } - public string Humanize(System.DateTimeOffset input, System.DateTimeOffset comparisonBase, System.Globalization.CultureInfo culture) { } - } - public interface IDateTimeHumanizeStrategy - { - string Humanize(System.DateTime input, System.DateTime comparisonBase, System.Globalization.CultureInfo culture); - } - public interface IDateTimeOffsetHumanizeStrategy - { - string Humanize(System.DateTimeOffset input, System.DateTimeOffset comparisonBase, System.Globalization.CultureInfo culture); - } - public class PrecisionDateTimeHumanizeStrategy : Humanizer.DateTimeHumanizeStrategy.IDateTimeHumanizeStrategy - { - public PrecisionDateTimeHumanizeStrategy(double precision = 0.75) { } - public string Humanize(System.DateTime input, System.DateTime comparisonBase, System.Globalization.CultureInfo culture) { } - } - public class PrecisionDateTimeOffsetHumanizeStrategy : Humanizer.DateTimeHumanizeStrategy.IDateTimeOffsetHumanizeStrategy - { - public PrecisionDateTimeOffsetHumanizeStrategy(double precision = 0.75) { } - public string Humanize(System.DateTimeOffset input, System.DateTimeOffset comparisonBase, System.Globalization.CultureInfo culture) { } - } -} -namespace Humanizer.Inflections -{ - - public class static Vocabularies - { - public static Humanizer.Inflections.Vocabulary Default { get; } - } - public class Vocabulary - { - public void AddIrregular(string singular, string plural, bool matchEnding = True) { } - public void AddPlural(string rule, string replacement) { } - public void AddSingular(string rule, string replacement) { } - public void AddUncountable(string word) { } - public string Pluralize(string word, bool inputIsKnownToBeSingular = True) { } - public string Singularize(string word, bool inputIsKnownToBePlural = True) { } - } -} -namespace Humanizer.Localisation.CollectionFormatters -{ - - public interface ICollectionFormatter - { - string Humanize(System.Collections.Generic.IEnumerable collection); - string Humanize(System.Collections.Generic.IEnumerable collection, System.Func objectFormatter); - string Humanize(System.Collections.Generic.IEnumerable collection, string separator); - string Humanize(System.Collections.Generic.IEnumerable collection, System.Func objectFormatter, string separator); - } -} -namespace Humanizer.Localisation.Formatters -{ - - public class DefaultFormatter : Humanizer.Localisation.Formatters.IFormatter - { - public DefaultFormatter(string localeCode) { } - public virtual string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.Tense timeUnitTense, int unit) { } - public virtual string DateHumanize_Never() { } - public virtual string DateHumanize_Now() { } - protected virtual string Format(string resourceKey) { } - protected virtual string Format(string resourceKey, int number) { } - protected virtual string GetResourceKey(string resourceKey, int number) { } - protected virtual string GetResourceKey(string resourceKey) { } - public virtual string TimeSpanHumanize(Humanizer.Localisation.TimeUnit timeUnit, int unit) { } - public virtual string TimeSpanHumanize_Zero() { } - } - public interface IFormatter - { - string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.Tense timeUnitTense, int unit); - string DateHumanize_Never(); - string DateHumanize_Now(); - string TimeSpanHumanize(Humanizer.Localisation.TimeUnit timeUnit, int unit); - string TimeSpanHumanize_Zero(); - } -} -namespace Humanizer.Localisation.NumberToWords -{ - - public interface INumberToWordsConverter - { - string Convert(int number); - string Convert(int number, Humanizer.GrammaticalGender gender); - string ConvertToOrdinal(int number); - string ConvertToOrdinal(int number, Humanizer.GrammaticalGender gender); - } -} -namespace Humanizer.Localisation.Ordinalizers -{ - - public interface IOrdinalizer - { - string Convert(int number, string numberString); - string Convert(int number, string numberString, Humanizer.GrammaticalGender gender); - } -} -namespace Humanizer.Localisation -{ - - public class ResourceKeys - { - public ResourceKeys() { } - public class static DateHumanize - { - public const string Never = "DateHumanize_Never"; - public const string Now = "DateHumanize_Now"; - public static string GetResourceKey(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.Tense timeUnitTense, int count = 1) { } - } - public class static TimeSpanHumanize - { - public static string GetResourceKey(Humanizer.Localisation.TimeUnit unit, int count = 1) { } - } - } - public class static Resources - { - public static string GetResource(string resourceKey, System.Globalization.CultureInfo culture = null) { } - } - public enum Tense - { - Future = 0, - Past = 1, - } - public enum TimeUnit - { - Millisecond = 0, - Second = 1, - Minute = 2, - Hour = 3, - Day = 4, - Week = 5, - Month = 6, - Year = 7, - } -} \ No newline at end of file diff --git a/src/global.json b/src/global.json deleted file mode 100644 index ecd9d1861..000000000 --- a/src/global.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "sources": [ ".", "Humanizer.Tests.DotNet" ] -}