diff --git a/release_notes.md b/release_notes.md index d34c56089..996175888 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,5 @@ ###In Development + - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) diff --git a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt index 2b662786b..5ac70bb3c 100644 --- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt +++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt @@ -163,6 +163,13 @@ public interface IFormatter string TimeSpanHumanize_Zero(); } +public class EnglishNumberToWordsConverter +{ + public EnglishNumberToWordsConverter() { } + public string Convert(int number) { } + public string ConvertToOrdinal(int number) { } +} + public interface INumberToWordsConverter { string Convert(int number); diff --git a/src/Humanizer.Tests/DateHumanizeTests.cs b/src/Humanizer.Tests/DateHumanizeTests.cs index 1eb3b3d50..f51c81cd1 100644 --- a/src/Humanizer.Tests/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/DateHumanizeTests.cs @@ -4,8 +4,13 @@ namespace Humanizer.Tests { - public class DateHumanizeTests + public class DateHumanizeTests : AmbientCulture { + public DateHumanizeTests() + : base("en-US") + { + } + [Theory] [InlineData(1, "one second ago")] [InlineData(10, "10 seconds ago")] diff --git a/src/Humanizer.Tests/NumberToWordsTests.cs b/src/Humanizer.Tests/NumberToWordsTests.cs index ea9468499..c0cd88527 100644 --- a/src/Humanizer.Tests/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/NumberToWordsTests.cs @@ -3,8 +3,13 @@ namespace Humanizer.Tests { - public class NumberToWordsTests + public class NumberToWordsTests : AmbientCulture { + public NumberToWordsTests() + : base("en-US") + { + } + [InlineData(1, "one")] [InlineData(10, "ten")] [InlineData(11, "eleven")] diff --git a/src/Humanizer.Tests/ToQuantityTests.cs b/src/Humanizer.Tests/ToQuantityTests.cs index 1f1ac3085..9812b3d29 100644 --- a/src/Humanizer.Tests/ToQuantityTests.cs +++ b/src/Humanizer.Tests/ToQuantityTests.cs @@ -3,8 +3,13 @@ namespace Humanizer.Tests { - public class ToQuantityTests + public class ToQuantityTests : AmbientCulture { + public ToQuantityTests() + : base("en-US") + { + } + [Theory] [InlineData("case", 0, "0 cases")] [InlineData("case", 1, "1 case")] diff --git a/src/Humanizer/FluentDate/In.SomeTimeFrom.tt b/src/Humanizer/FluentDate/In.SomeTimeFrom.tt index fad3f7551..a2f7731ed 100644 --- a/src/Humanizer/FluentDate/In.SomeTimeFrom.tt +++ b/src/Humanizer/FluentDate/In.SomeTimeFrom.tt @@ -28,10 +28,11 @@ namespace Humanizer var month = "Month" + plural; var year = "Year" + plural; + var converter= new Humanizer.Localisation.NumberToWords.EnglishNumberToWordsConverter(); #> /// /// - public static class <#= i.ToWords().Dehumanize() #> + public static class <#= converter.Convert(i).Dehumanize() #> { /// /// <#= i #> seconds from now diff --git a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs index c6a88f444..d1b157835 100644 --- a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs @@ -3,7 +3,7 @@ namespace Humanizer.Localisation.NumberToWords { - internal class EnglishNumberToWordsConverter : INumberToWordsConverter + public class EnglishNumberToWordsConverter : INumberToWordsConverter { private static readonly string[] UnitsMap = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; private static readonly string[] TensMap = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };