Skip to content

Commit

Permalink
Merge pull request #419 from dampee/master
Browse files Browse the repository at this point in the history
Add Dutch Ordinalizer
  • Loading branch information
MehdiK committed May 27, 2015
2 parents 2f8293a + 8d3f507 commit c733622
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
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";
}
}
}

0 comments on commit c733622

Please sign in to comment.