-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from dampee/master
Add Dutch Ordinalizer
- Loading branch information
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} |