Skip to content

Commit

Permalink
Merge pull request #931 from Terra-jin/feature/dutch_number_to_long_w…
Browse files Browse the repository at this point in the history
…ords

Added support for converting big numbers to Dutch
  • Loading branch information
clairernovotny authored May 11, 2020
2 parents 2b8ae7b + c569141 commit b17fff2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
15 changes: 14 additions & 1 deletion src/Humanizer.Tests.Shared/Localisation/nl/NumberToWordsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,20 @@ public class NumberToWordsTests
[InlineData(415618, "vierhonderdvijftienduizend zeshonderdachttien")]
[InlineData(16415618, "zestien miljoen vierhonderdvijftienduizend zeshonderdachttien")]
[InlineData(322, "driehonderdtweeëntwintig")]
public void ToWords(int number, string expected)
public void IntToWords(int number, string expected)
{
Assert.Equal(expected, number.ToWords());
}

[Theory]
[InlineData(100_000_000_000L, "honderd miljard")]
[InlineData(1_000_000_000_000L, "een biljoen")]
[InlineData(100_000_000_000_000L, "honderd biljoen")]
[InlineData(1_000_000_000_000_000L, "een biljard")]
[InlineData(100_000_000_000_000_000L, "honderd biljard")]
[InlineData(1_000_000_000_000_000_000L, "een triljoen")]
[InlineData(9_223_372_036_854_775_807L, "negen triljoen tweehonderddrieëntwintig biljard driehonderdtweeënzeventig biljoen zesendertig miljard achthonderdvierenvijftig miljoen zevenhonderdvijfenzeventigduizend achthonderdzeven")]
public void LongToWords(long number, string expected)
{
Assert.Equal(expected, number.ToWords());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class DutchNumberToWordsConverter : GenderlessNumberToWordsConverter

private class Fact
{
public int Value { get; set; }
public long Value { get; set; }
public string Name { get; set; }
public string Prefix { get; set; }
public string Postfix { get; set; }
Expand All @@ -26,19 +26,18 @@ private class Fact

private static readonly Fact[] Hunderds =
{
new Fact {Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1000000, Name = "miljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1000, Name = "duizend", Prefix = "", Postfix = " ", DisplayOneUnit = false},
new Fact {Value = 100, Name = "honderd", Prefix = "", Postfix = "", DisplayOneUnit = false}
new Fact {Value = 1_000_000_000_000_000_000L, Name = "triljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1_000_000_000_000_000L, Name = "biljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1_000_000_000_000L, Name = "biljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1000000, Name = "miljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true},
new Fact {Value = 1000, Name = "duizend", Prefix = "", Postfix = " ", DisplayOneUnit = false},
new Fact {Value = 100, Name = "honderd", Prefix = "", Postfix = "", DisplayOneUnit = false}
};

public override string Convert(long input)
{
if (input > Int32.MaxValue || input < Int32.MinValue)
{
throw new NotImplementedException();
}
var number = (int)input;
var number = input;

if (number == 0)
{
Expand Down Expand Up @@ -133,4 +132,4 @@ public override string ConvertToOrdinal(int number)
return word + "de";
}
}
}
}

0 comments on commit b17fff2

Please sign in to comment.