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

bulgarian number fix: "един" shoud be "едно" in string[] UnitsMap. #1193

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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class NumberToWordsTests

[Theory]
[InlineData(0, "нула")]
[InlineData(1, "един")]
[InlineData(1, "едно")]
[InlineData(10, "десет")]
[InlineData(11, "единадесет")]
[InlineData(12, "дванадесет")]
Expand Down Expand Up @@ -48,6 +48,7 @@ public class NumberToWordsTests
[InlineData(4000210, "четири милиона двеста и десет")]
[InlineData(5200, "пет хиляди и двеста")]
[InlineData(1125000, "един милион и сто двадесет и пет хиляди")]
[InlineData(1000000000, "един милиард")]
public void ToWordsBg(long number, string expected)
{
Assert.Equal(expected, number.ToWords());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class BulgarianNumberToWordsConverter : GenderedNumberToWordsConverter
{
private static readonly string[] UnitsMap =
{
"нула", "един", "две", "три", "четири", "пет", "шест", "седем", "осем", "девет", "десет", "единадесет",
"нула", "едно", "две", "три", "четири", "пет", "шест", "седем", "осем", "девет", "десет", "единадесет",
"дванадесет", "тринадесет", "четиринадесет", "петнадесет", "шестнадесет", "седемнадесет", "осемнадесет",
"деветнадесет"
};
Expand All @@ -24,14 +24,12 @@ internal class BulgarianNumberToWordsConverter : GenderedNumberToWordsConverter
"осемстотин", "деветстотин"
};


private static readonly string[] HundredsOrdinalMap =
{
String.Empty, "стот", "двест", "трист", "четиристот", "петстот", "шестстот", "седемстот", "осемстот",
"деветстот"
};


private static readonly string[] UnitsOrdinal =
{
string.Empty, "първ", "втор", "трет", "четвърт", "пет", "шест", "седм", "осм", "девeт", "десeт",
Expand Down Expand Up @@ -77,8 +75,7 @@ private string Convert(long input, GrammaticalGender gender, bool isOrdinal, boo

if ((input / 1000000000) > 0)
{
parts.Add(Convert(input / 1000000000, gender, false) +
$" {(input < 2000000000 ? "милиард" : "милиарда")}");
parts.Add(input < 2000000000 ? "един милиард" : Convert(input / 1000000000, gender, false) + " милиарда");

if (isOrdinal)
lastOrdinalSubstitution = Convert(input / 1000000000, gender, false) + " милиард" +
Expand All @@ -88,7 +85,7 @@ private string Convert(long input, GrammaticalGender gender, bool isOrdinal, boo

if ((input / 1000000) > 0)
{
parts.Add(Convert(input / 1000000, gender, false) + $" {(input < 2000000 ? "милион" : "милиона")}");
parts.Add(input < 2000000 ? "един милион" : Convert(input / 1000000, gender, false) + " милиона");

if (isOrdinal)
lastOrdinalSubstitution = Convert(input / 1000000, gender, false) + " милион" +
Expand Down