Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dutch Ordinalizer #419

Merged
merged 3 commits into from
May 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Compile Include="Localisation\pl\NumberToWordsTests.cs" />
<Compile Include="Localisation\pl\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\NumberToWordsTests.cs" />
<Compile Include="Localisation\nl\OrdinalizeTests.cs" />
<Compile Include="Localisation\pt-BR\OrdinalizeTests.cs" />
<Compile Include="Localisation\ro-Ro\TimeSpanHumanizerTests.cs" />
<Compile Include="Localisation\ru-RU\NumberToWordsTests.cs" />
Expand Down
32 changes: 32 additions & 0 deletions src/Humanizer.Tests/Localisation/nl/OrdinalizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.nl
{
public class OrdinalizeTests : AmbientCulture
{
public OrdinalizeTests()
: base("nl")
{
}

[Theory]
[InlineData("0", "0")]
[InlineData("1", "1e")]
[InlineData("2", "2e")]
[InlineData("3", "3e")]
[InlineData("4", "4e")]
[InlineData("5", "5e")]
[InlineData("6", "6e")]
[InlineData("23", "23e")]
[InlineData("100", "100e")]
[InlineData("101", "101e")]
[InlineData("102", "102e")]
[InlineData("103", "103e")]
[InlineData("1001", "1001e")]
public void OrdinalizeString(string number, string ordinalized)
{
Assert.Equal(number.Ordinalize(), ordinalized);
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Configuration/OrdinalizerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public OrdinalizerRegistry() : base(new DefaultOrdinalizer())
Register("en", new EnglishOrdinalizer());
Register("es", new SpanishOrdinalizer());
Register("it", new ItalianOrdinalizer());
Register("nl", new DutchOrdinalizer());
Register("pt-BR", new BrazilianPortugueseOrdinalizer());
Register("ru", new RussianOrdinalizer());
Register("tr", new TurkishOrdinalizer());
Expand Down
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<Compile Include="Localisation\Ordinalizers\IOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\GermanOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\RussianOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\DutchOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\SpanishOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\DefaultOrdinalizer.cs" />
<Compile Include="Localisation\Ordinalizers\EnglishOrdinalizer.cs" />
Expand Down
19 changes: 19 additions & 0 deletions src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Humanizer.Localisation.Ordinalizers
{
internal class DutchOrdinalizer : DefaultOrdinalizer
{
public override string Convert(int number, string numberString)
{
return Convert(number, numberString, GrammaticalGender.Masculine);
}

public override string Convert(int number, string numberString, GrammaticalGender gender)
{
// N/A in Dutch
if (number == 0)
return "0";

return numberString + "e";
}
}
}