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

Added support for converting big numbers to Dutch #931

Merged
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
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";
}
}
}
}