From 47a5f260a5206eb434b7a490b3dae0bd012ab264 Mon Sep 17 00:00:00 2001 From: Muhammad Azeez Date: Sat, 24 Apr 2021 14:06:07 +0300 Subject: [PATCH 1/2] fix a bug in number to words for central kurdish --- .../Localisation/ku/NumberToWordsTests.cs | 3 ++- .../NumberToWords/CentralKurdishNumberToWordsConverter.cs | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs index 5a7e8585d..06ef8a231 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs @@ -21,13 +21,14 @@ public class NumberToWordsTests [InlineData(1000, "هەزار")] [InlineData(100000, "سەد هەزار")] [InlineData(1000000, "یەک میلیۆن")] + [InlineData(51000, "پەنجا و یەک هەزار")] [InlineData(10000000, "دە میلیۆن")] [InlineData(100000000, "سەد میلیۆن")] [InlineData(1000000000, "یەک میلیارد")] [InlineData(111, "سەد و یازدە")] [InlineData(1111, "هەزار و سەد و یازدە")] [InlineData(111111, "سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(1001001, "یەک میلیۆن و هەزار و یەک")] + [InlineData(1001001, "یەک میلیۆن و یەک هەزار و یەک")] [InlineData(1111111, "یەک میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] [InlineData(11111111, "یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] [InlineData(111111111, "سەد و یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] diff --git a/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs index d379c208f..7f42786e7 100644 --- a/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs @@ -58,7 +58,11 @@ public override string Convert(long number) parts.Add(KurdishUnitsMap[number]); } - return string.Join(" و ", parts).Replace("یەک هەزار", "هەزار"); + var sentence = string.Join(" و ", parts); + if (sentence.StartsWith("یەک هەزار")) + return sentence.Substring(" یەک".Length); + else + return sentence; } public override string ConvertToOrdinal(int number) From 2378d19f7c153884b309ec5625c313f1d9fd6784 Mon Sep 17 00:00:00 2001 From: Muhammad Azeez Date: Sat, 24 Apr 2021 19:34:27 +0300 Subject: [PATCH 2/2] add more test cases --- .../Localisation/ku/NumberToWordsTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs index 06ef8a231..d45614977 100644 --- a/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs +++ b/src/Humanizer.Tests.Shared/Localisation/ku/NumberToWordsTests.cs @@ -20,8 +20,11 @@ public class NumberToWordsTests [InlineData(100, "سەد")] [InlineData(1000, "هەزار")] [InlineData(100000, "سەد هەزار")] + [InlineData(100001, "سەد هەزار و یەک")] + [InlineData(101000, "سەد و یەک هەزار")] [InlineData(1000000, "یەک میلیۆن")] [InlineData(51000, "پەنجا و یەک هەزار")] + [InlineData(151000, "سەد و پەنجا و یەک هەزار")] [InlineData(10000000, "دە میلیۆن")] [InlineData(100000000, "سەد میلیۆن")] [InlineData(1000000000, "یەک میلیارد")]