From dc90d4e1bd7c37c7b387773081b506e45933f524 Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Fri, 11 Apr 2014 14:44:31 +0300 Subject: [PATCH 01/30] Added Bulgarian localization, date and timespan tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 2 + .../Localisation/bg/DateHumanizeTests.cs | 115 +++++++++ .../Localisation/bg/TimeSpanHumanizeTests.cs | 66 +++++ src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.bg.resx | 234 ++++++++++++++++++ 5 files changed, 418 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs create mode 100644 src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs create mode 100644 src/Humanizer/Properties/Resources.bg.resx diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 13513efe2..554611345 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -76,6 +76,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs new file mode 100644 index 000000000..725cea72f --- /dev/null +++ b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs @@ -0,0 +1,115 @@ +using Humanizer.Localisation; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.bg +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() : base("bg-BG") + { + } + + [Theory] + [InlineData(1, "преди секунда")] + [InlineData(2, "преди 2 секунди")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(1, "след секунда")] + [InlineData(2, "след 2 секунди")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(1, "преди минута")] + [InlineData(2, "преди 2 минути")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "след минута")] + [InlineData(2, "след 2 минути")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [InlineData(1, "преди час")] + [InlineData(2, "преди 2 часа")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "след час")] + [InlineData(2, "след 2 часа")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(1, "вчера")] + [InlineData(2, "преди 2 дена")] + public void DaysAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "утре")] + [InlineData(2, "след 2 дена")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "преди месец")] + [InlineData(2, "преди 2 месеца")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "след месец")] + [InlineData(2, "след 2 месеца")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(1, "преди година")] + [InlineData(2, "преди 2 години")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "след година")] + [InlineData(2, "след 2 години")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + [Fact] + public void Now() + { + DateHumanize.Verify("сега", 0, TimeUnit.Day, Tense.Past); + } + } +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..3c1d3fe21 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs @@ -0,0 +1,66 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.bg +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("bg-BG") { } + + [Theory] + [InlineData(7, "една седмица")] + [InlineData(14, "2 седмици")] + public void Weeks(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "един ден")] + [InlineData(2, "2 дена")] + public void Days(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "един час")] + [InlineData(2, "2 часа")] + public void Hours(int hours, string expected) + { + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + } + + [Theory] + [InlineData(1, "една минута")] + [InlineData(2, "2 минути")] + public void Minutes(int minutes, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(1, "една секунда")] + [InlineData(2, "2 секунди")] + public void Seconds(int seconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(1, "една милисекунда")] + [InlineData(2, "2 милисекунди")] + public void Milliseconds(int milliseconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + } + + [Fact] + public void NoTime() + { + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("няма време", TimeSpan.Zero.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index efb54f5d9..adc0c742a 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -153,6 +153,7 @@ + diff --git a/src/Humanizer/Properties/Resources.bg.resx b/src/Humanizer/Properties/Resources.bg.resx new file mode 100644 index 000000000..585db32a6 --- /dev/null +++ b/src/Humanizer/Properties/Resources.bg.resx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + преди секунда + + + преди {0} секунди + + + преди минута + + + преди {0} минути + + + преди час + + + преди {0} часа + + + вчера + + + преди {0} дена + + + преди месец + + + преди {0} месеца + + + преди година + + + преди {0} години + + + {0} дена + + + {0} часа + + + {0} милисекунди + + + {0} минути + + + {0} секунди + + + един ден + + + един час + + + една милисекунда + + + една минута + + + една секунда + + + няма време + + + {0} седмици + + + една седмица + + + след {0} дена + + + след {0} часа + + + след {0} минути + + + след {0} месеца + + + след {0} секунди + + + след {0} години + + + сега + + + утре + + + след час + + + след минута + + + след месец + + + след секунда + + + след година + + From 18c51a1073cb258aaa96b11895f1dc3f3641e6fd Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Sat, 12 Apr 2014 11:37:45 +0300 Subject: [PATCH 02/30] Added PR to the release notes --- release_notes.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/release_notes.md b/release_notes.md index b33614dea..12db5a9d7 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,9 +1,21 @@ ###In Development + - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) + - [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize + +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) + - [#181](https://github.com/Mehdik/Humanizer/pull/181): Added Bulgarian localization, date and timespan tests +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) + +###v1.20.2 - 2014-04-11 - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation + - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations + - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords + - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) ###v1.19.1 - 2014-04-10 - [#149](https://github.com/MehdiK/Humanizer/pull/149): Improved & refactored number to words localisation @@ -145,4 +157,3 @@ fix it based on your requirements. ###v1.0.0 - 2013-11-10 No release history before this point: check out http://www.mehdi-khalili.com/humanizer-v1 for the feature-set at V1 - From 93b8aee38efd9a0f7d5c4d2c37fb6292e44a5be4 Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Sat, 12 Apr 2014 12:05:32 +0300 Subject: [PATCH 03/30] Revert "Added PR to the release notes" This reverts commit 18c51a1073cb258aaa96b11895f1dc3f3641e6fd. --- release_notes.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/release_notes.md b/release_notes.md index 12db5a9d7..b33614dea 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,21 +1,9 @@ ###In Development - - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) - - [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize - -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) - - [#181](https://github.com/Mehdik/Humanizer/pull/181): Added Bulgarian localization, date and timespan tests -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) - -###v1.20.2 - 2014-04-11 - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation - - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations - - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords - - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) ###v1.19.1 - 2014-04-10 - [#149](https://github.com/MehdiK/Humanizer/pull/149): Improved & refactored number to words localisation @@ -157,3 +145,4 @@ fix it based on your requirements. ###v1.0.0 - 2013-11-10 No release history before this point: check out http://www.mehdi-khalili.com/humanizer-v1 for the feature-set at V1 + From f06e119adae5cd01e4eb8773abacff486dfcea5f Mon Sep 17 00:00:00 2001 From: "Alexander I. Zaytsev" Date: Thu, 10 Apr 2014 21:05:32 +1200 Subject: [PATCH 04/30] Add NumberToWordsTests for invariant culture --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../invariant/NumberToWordsTests.cs | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 554611345..b927a0292 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -86,6 +86,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs new file mode 100644 index 000000000..dc74d39d5 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs @@ -0,0 +1,44 @@ +using System.Globalization; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.invariant +{ + public class NumberToWordsTests : AmbientCulture + { + public NumberToWordsTests() : base(CultureInfo.InvariantCulture) { } + + [Theory] + [InlineData(1)] + [InlineData(10)] + [InlineData(11)] + [InlineData(122)] + [InlineData(3501)] + [InlineData(100)] + [InlineData(1000)] + [InlineData(100000)] + [InlineData(1000000)] + [InlineData(10000000)] + [InlineData(100000000)] + [InlineData(1000000000)] + [InlineData(111)] + [InlineData(1111)] + [InlineData(111111)] + [InlineData(1111111)] + [InlineData(11111111)] + [InlineData(111111111)] + [InlineData(1111111111)] + [InlineData(123)] + [InlineData(1234)] + [InlineData(12345)] + [InlineData(123456)] + [InlineData(1234567)] + [InlineData(12345678)] + [InlineData(123456789)] + [InlineData(1234567890)] + public void ToWords(int number) + { + Assert.Equal(number.ToString(), number.ToWords()); + } + } +} From e0cefdc5ffbde1c1c7cda8ce5b33fcba0d3abdcf Mon Sep 17 00:00:00 2001 From: "Alexander I. Zaytsev" Date: Thu, 10 Apr 2014 21:14:39 +1200 Subject: [PATCH 05/30] Add ToQuantityTests for invariant culture --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/invariant/ToQuantityTests.cs | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index b927a0292..97078d7d3 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -87,6 +87,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs b/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs new file mode 100644 index 000000000..f477321cb --- /dev/null +++ b/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs @@ -0,0 +1,81 @@ +using System.Globalization; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.invariant +{ + public class ToQuantityTests : AmbientCulture + { + public ToQuantityTests() : base(CultureInfo.InvariantCulture) { } + + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantity(string word, int quatity, string expected) + { + Assert.Equal(expected, word.ToQuantity(quatity)); + } + + [Theory] + [InlineData("case", 0, "cases")] + [InlineData("case", 1, "case")] + [InlineData("case", 5, "cases")] + [InlineData("man", 0, "men")] + [InlineData("man", 1, "man")] + [InlineData("man", 2, "men")] + [InlineData("men", 2, "men")] + [InlineData("process", 2, "processes")] + [InlineData("process", 1, "process")] + [InlineData("processes", 2, "processes")] + [InlineData("processes", 1, "process")] + public void ToQuantityWithNoQuantity(string word, int quatity, string expected) + { + Assert.Equal(expected, word.ToQuantity(quatity, ShowQuantityAs.None)); + } + + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantityNumeric(string word, int quatity, string expected) + { +// ReSharper disable once RedundantArgumentDefaultValue + Assert.Equal(expected, word.ToQuantity(quatity, ShowQuantityAs.Numeric)); + } + + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1200, "1200 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantityWords(string word, int quatity, string expected) + { + Assert.Equal(expected, word.ToQuantity(quatity, ShowQuantityAs.Words)); + } + } +} From 75ab297b69fa886739b09c37deb0b8314ad7fcfc Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 17:38:11 +0430 Subject: [PATCH 06/30] (re)setting CurrentCulture on ambient culture --- src/Humanizer.Tests/AmbientCulture.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Humanizer.Tests/AmbientCulture.cs b/src/Humanizer.Tests/AmbientCulture.cs index 4d857cd8d..d8515f329 100644 --- a/src/Humanizer.Tests/AmbientCulture.cs +++ b/src/Humanizer.Tests/AmbientCulture.cs @@ -23,6 +23,7 @@ public AmbientCulture(string cultureName) public void Dispose() { Thread.CurrentThread.CurrentUICulture = _culture; + Thread.CurrentThread.CurrentCulture = _culture; } } } \ No newline at end of file From 476b15962c88887643e318f27ae2477e2442ec78 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Wed, 9 Apr 2014 16:55:27 -0700 Subject: [PATCH 07/30] Added Spanish toWords --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/es/NumberToWordsTests.cs | 51 +++++++++++ src/Humanizer/Humanizer.csproj | 1 + .../SpanishNumberToWordsConverter.cs | 88 +++++++++++++++++++ src/Humanizer/NumberToWordsExtension.cs | 20 ++--- 5 files changed, 149 insertions(+), 12 deletions(-) create mode 100644 src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs create mode 100644 src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 97078d7d3..7dab28a70 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -88,6 +88,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs new file mode 100644 index 000000000..017dcad73 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs @@ -0,0 +1,51 @@ +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.es +{ + public class NumberToWordsTests : AmbientCulture + { + public NumberToWordsTests() : base("es-ES") { } + + [Theory] + [InlineData(0, "cero")] + [InlineData(1, "uno")] + [InlineData(10, "diez")] + [InlineData(11, "once")] + [InlineData(122, "ciento veinte dos")] + [InlineData(3501, "tres mil quinientos uno")] + [InlineData(100, "cien")] + [InlineData(1000, "mil")] + [InlineData(100000, "cien mil")] + [InlineData(1000000, "millón")] + [InlineData(10000000, "diez millones")] + [InlineData(100000000, "cien millones")] + [InlineData(1000000000, "mil millones")] + [InlineData(111, "ciento once")] + [InlineData(1111, "mil ciento once")] + [InlineData(111111, "ciento once mil ciento once")] + [InlineData(1111111, "millón ciento once mil ciento once")] + [InlineData(11111111, "once millones ciento once mil ciento once")] + [InlineData(111111111, "ciento once millones ciento once mil ciento once")] + [InlineData(1111111111, "mil millones ciento once millones ciento once mil ciento once")] + [InlineData(123, "ciento veinte tres")] + [InlineData(1234, "mil doscientos treinta y cuatro")] + [InlineData(12345, "doce mil trescientos cuarenta y cinco")] + [InlineData(123456, "ciento veinte tres mil cuatrocientos cincuenta y seis")] + [InlineData(1234567, "millón doscientos treinta y cuatro mil quinientos sesenta y siete")] + [InlineData(12345678, "doce millones trescientos cuarenta y cinco mil seiscientos setenta y ocho")] + [InlineData(123456789, "ciento veinte tres millones cuatrocientos cincuenta y seis mil setecientos ochenta y nueve")] + [InlineData(1234567890, "mil millones doscientos treinta y cuatro millones quinientos sesenta y siete mil ochocientos noventa")] + [InlineData(15, "quince")] + [InlineData(16, "dieciséis")] + [InlineData(25, "veinte cinco")] + [InlineData(35, "treinta y cinco")] + [InlineData(1999, "mil novecientos noventa y nueve")] + [InlineData(2014, "dos mil catorce")] + [InlineData(2048, "dos mil cuarenta y ocho")] + public void ToWordsSpanish(int number, string expected) + { + Assert.Equal(expected, number.ToWords()); + } + } +} diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index adc0c742a..7a10d1708 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -80,6 +80,7 @@ + True diff --git a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs new file mode 100644 index 000000000..793a3d836 --- /dev/null +++ b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs @@ -0,0 +1,88 @@ +using Humanizer.Localisation.NumberToWords; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Humanizer { + public class SpanishNumberToWordsConverter : INumberToWordsConverter { + private static readonly string[] HundredsMap = { "cero", "ciento", "doscientos", "trescientos", "cuatrocientos", "quinientos", "seiscientos", "setecientos", "ochocientos", "novecientos" }; + private static readonly string[] UnitsMap = { "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince", "dieciséis", "diecisiete", "dieciocho", "diecinueve" }; + private static readonly string[] TensMap = { "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa" }; + + public string Convert(int number) + { + if (number == 0) + return "cero"; + + if (number < 0) + return string.Format("menos {0}", Convert(Math.Abs(number))); + + var parts = new List(); + + if ((number / 1000000000) > 0) + { + if (number / 1000000000 == 1) + parts.Add(string.Format("mil millones", Convert(number / 1000000000))); + else + parts.Add(string.Format("{0} mil millones", Convert(number / 1000000000))); + number %= 1000000000; + } + + if ((number / 1000000) > 0) + { + if (number / 1000000 == 1) + parts.Add(string.Format("millón", Convert(number / 1000000))); + else + parts.Add(string.Format("{0} millones", Convert(number / 1000000))); + number %= 1000000; + } + + if ((number / 1000) > 0) + { + if (number / 1000 == 1) + parts.Add(string.Format("mil", Convert(number / 1000))); + else + parts.Add(string.Format("{0} mil", Convert(number / 1000))); + number %= 1000; + } + + if ((number / 100) > 0) + { + if (number == 100) + parts.Add(string.Format("cien", Convert(number / 100))); + else + parts.Add(HundredsMap[(number / 100)]); + + number %= 100; + } + + if (number > 0) + { + if (number < 20) + parts.Add(UnitsMap[number]); + else if (number > 20 && number < 30) { + var lastPart = TensMap[number / 10]; + if ((number % 10) > 0) + lastPart += string.Format(" {0}", UnitsMap[number % 10]); + + parts.Add(lastPart); + } + else + { + var lastPart = TensMap[number / 10]; + if ((number % 10) > 0) + lastPart += string.Format(" y {0}", UnitsMap[number % 10]); + + parts.Add(lastPart); + } + } + + return string.Join(" ", parts.ToArray()); + } + + public string ConvertToOrdinal(int number) { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index 3315f4142..ffc2ffb8e 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -3,19 +3,18 @@ using System.Globalization; using Humanizer.Localisation.NumberToWords; -namespace Humanizer -{ +namespace Humanizer { /// /// Transform a number into words; e.g. 1 => one /// - public static class NumberToWordsExtension - { + public static class NumberToWordsExtension { private static readonly IDictionary> ConverterFactories = new Dictionary> { { "en", () => new EnglishNumberToWordsConverter() }, { "ar", () => new ArabicNumberToWordsConverter() }, - { "fa", () => new FarsiNumberToWordsConverter() } + { "fa", () => new FarsiNumberToWordsConverter() }, + { "es", () => new SpanishNumberToWordsConverter() } }; /// @@ -23,15 +22,12 @@ public static class NumberToWordsExtension /// /// Number to be turned to words /// - public static string ToWords(this int number) - { + public static string ToWords(this int number) { return Converter.Convert(number); } - private static INumberToWordsConverter Converter - { - get - { + private static INumberToWordsConverter Converter { + get { Func converterFactory; if (ConverterFactories.TryGetValue(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out converterFactory)) return converterFactory(); @@ -40,4 +36,4 @@ private static INumberToWordsConverter Converter } } } -} +} \ No newline at end of file From d4c99e2c61e8fabc3808c14aa92aa1996fc86696 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Wed, 9 Apr 2014 16:59:36 -0700 Subject: [PATCH 08/30] Adding PR to release notes --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index b33614dea..1f475bad5 100644 --- a/release_notes.md +++ b/release_notes.md @@ -2,6 +2,7 @@ - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation + - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) From acc4a07a5032700dc87334ebd070dd4a64c81a92 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 01:10:25 -0700 Subject: [PATCH 09/30] Cleaning up my braces --- .../NumberToWords/SpanishNumberToWordsConverter.cs | 3 ++- src/Humanizer/NumberToWordsExtension.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs index 793a3d836..52cd31949 100644 --- a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs @@ -81,7 +81,8 @@ public string Convert(int number) return string.Join(" ", parts.ToArray()); } - public string ConvertToOrdinal(int number) { + public string ConvertToOrdinal(int number) + { throw new NotImplementedException(); } } diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index ffc2ffb8e..4cdacdc5e 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -22,12 +22,15 @@ public static class NumberToWordsExtension { /// /// Number to be turned to words /// - public static string ToWords(this int number) { + public static string ToWords(this int number) + { return Converter.Convert(number); } - private static INumberToWordsConverter Converter { - get { + private static INumberToWordsConverter Converter + { + get + { Func converterFactory; if (ConverterFactories.TryGetValue(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out converterFactory)) return converterFactory(); From 1193722aaf7300ee906c4bc2349216215d481954 Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 18:39:04 +0430 Subject: [PATCH 10/30] tidying up ToWords converter particularly Spanish --- ...provalTest.approve_public_api.approved.txt | 7 --- .../EnglishNumberToWordsConverter.cs | 2 +- .../SpanishNumberToWordsConverter.cs | 62 +++++++++---------- 3 files changed, 30 insertions(+), 41 deletions(-) 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 229ba4474..7f8823fa2 100644 --- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt +++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt @@ -181,13 +181,6 @@ 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/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs index d1b157835..c6a88f444 100644 --- a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs @@ -3,7 +3,7 @@ namespace Humanizer.Localisation.NumberToWords { - public class EnglishNumberToWordsConverter : INumberToWordsConverter + internal 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" }; diff --git a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs index 52cd31949..017a56bde 100644 --- a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs @@ -1,16 +1,15 @@ -using Humanizer.Localisation.NumberToWords; -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -namespace Humanizer { - public class SpanishNumberToWordsConverter : INumberToWordsConverter { +namespace Humanizer.Localisation.NumberToWords +{ + internal class SpanishNumberToWordsConverter : INumberToWordsConverter + { private static readonly string[] HundredsMap = { "cero", "ciento", "doscientos", "trescientos", "cuatrocientos", "quinientos", "seiscientos", "setecientos", "ochocientos", "novecientos" }; private static readonly string[] UnitsMap = { "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince", "dieciséis", "diecisiete", "dieciocho", "diecinueve" }; private static readonly string[] TensMap = { "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa" }; - public string Convert(int number) + public string Convert(int number) { if (number == 0) return "cero"; @@ -20,55 +19,52 @@ public string Convert(int number) var parts = new List(); - if ((number / 1000000000) > 0) + if ((number / 1000000000) > 0) { - if (number / 1000000000 == 1) - parts.Add(string.Format("mil millones", Convert(number / 1000000000))); - else - parts.Add(string.Format("{0} mil millones", Convert(number / 1000000000))); + parts.Add(number/1000000000 == 1 + ? string.Format("mil millones") + : string.Format("{0} mil millones", Convert(number/1000000000))); + number %= 1000000000; } - if ((number / 1000000) > 0) + if ((number / 1000000) > 0) { - if (number / 1000000 == 1) - parts.Add(string.Format("millón", Convert(number / 1000000))); - else - parts.Add(string.Format("{0} millones", Convert(number / 1000000))); + parts.Add(number/1000000 == 1 + ? string.Format("millón") + : string.Format("{0} millones", Convert(number/1000000))); + number %= 1000000; } - if ((number / 1000) > 0) + if ((number / 1000) > 0) { - if (number / 1000 == 1) - parts.Add(string.Format("mil", Convert(number / 1000))); - else - parts.Add(string.Format("{0} mil", Convert(number / 1000))); + parts.Add(number/1000 == 1 + ? string.Format("mil") + : string.Format("{0} mil", Convert(number/1000))); + number %= 1000; } - if ((number / 100) > 0) + if ((number / 100) > 0) { - if (number == 100) - parts.Add(string.Format("cien", Convert(number / 100))); - else - parts.Add(HundredsMap[(number / 100)]); - + parts.Add(number == 100 ? string.Format("cien") : HundredsMap[(number/100)]); number %= 100; } - if (number > 0) + if (number > 0) { if (number < 20) parts.Add(UnitsMap[number]); - else if (number > 20 && number < 30) { + else if (number > 20 && number < 30) + { var lastPart = TensMap[number / 10]; if ((number % 10) > 0) lastPart += string.Format(" {0}", UnitsMap[number % 10]); parts.Add(lastPart); - } - else + } + else { var lastPart = TensMap[number / 10]; if ((number % 10) > 0) @@ -81,7 +77,7 @@ public string Convert(int number) return string.Join(" ", parts.ToArray()); } - public string ConvertToOrdinal(int number) + public string ConvertToOrdinal(int number) { throw new NotImplementedException(); } From d59b5d3f868bca2f66cc174ab479b4bc9b146e54 Mon Sep 17 00:00:00 2001 From: Marcin Nowacki Date: Thu, 10 Apr 2014 22:12:49 +0200 Subject: [PATCH 11/30] Added Polish translation for ToWords --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/pl/NumberToWordsTests.cs | 64 ++++++++++ src/Humanizer/Humanizer.csproj | 1 + .../PolishNumberToWordsConverter.cs | 115 ++++++++++++++++++ src/Humanizer/NumberToWordsExtension.cs | 9 +- 5 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs create mode 100644 src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 7dab28a70..10eb3d056 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -91,6 +91,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs new file mode 100644 index 000000000..d7527e05e --- /dev/null +++ b/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs @@ -0,0 +1,64 @@ +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.pl +{ + public class NumberToWordsTests : AmbientCulture + { + public NumberToWordsTests() : base("pl") { } + + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "jeden")] + [InlineData(2, "dwa")] + [InlineData(3, "trzy")] + [InlineData(4, "cztery")] + [InlineData(5, "pięć")] + [InlineData(6, "sześć")] + [InlineData(7, "siedem")] + [InlineData(8, "osiem")] + [InlineData(9, "dziewięć")] + [InlineData(10, "dziesięć")] + [InlineData(11, "jedenaście")] + [InlineData(12, "dwanaście")] + [InlineData(13, "trzynaście")] + [InlineData(14, "czternaście")] + [InlineData(15, "piętnaście")] + [InlineData(16, "szesnaście")] + [InlineData(17, "siedemnaście")] + [InlineData(18, "osiemnaście")] + [InlineData(19, "dziewiętnaście")] + [InlineData(20, "dwadzieścia")] + [InlineData(30, "trzydzieści")] + [InlineData(40, "czterdzieści")] + [InlineData(50, "pięćdziesiąt")] + [InlineData(60, "sześćdziesiąt")] + [InlineData(70, "siedemdziesiąt")] + [InlineData(80, "osiemdziesiąt")] + [InlineData(90, "dziewięćdziesiąt")] + [InlineData(100, "sto")] + [InlineData(112, "sto dwanaście")] + [InlineData(128, "sto dwadzieścia osiem")] + [InlineData(1000, "tysiąc")] + [InlineData(2000, "dwa tysiące")] + [InlineData(5000, "pięć tysięcy")] + [InlineData(10000, "dziesięć tysięcy")] + [InlineData(20000, "dwadzieścia tysięcy")] + [InlineData(22000, "dwadzieścia dwa tysiące")] + [InlineData(25000, "dwadzieścia pięć tysięcy")] + [InlineData(100000, "sto tysięcy")] + [InlineData(500000, "pięćset tysięcy")] + [InlineData(1000000, "milion")] + [InlineData(2000000, "dwa miliony")] + [InlineData(5000000, "pięć milionów")] + [InlineData(1000000000, "miliard")] + [InlineData(2000000000, "dwa miliardy")] + [InlineData(1501001892, "miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] + [InlineData(2147483647, "dwa miliardy sto czterdzieści siedem milionów czterysta osiemdziesiąt trzy tysiące sześćset czterdzieści siedem")] + [InlineData(-1501001892, "minus miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] + public void ToWordsPolish(int number, string expected) + { + Assert.Equal(expected, number.ToWords()); + } + } +} diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 7a10d1708..7194d124d 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -79,6 +79,7 @@ + diff --git a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs new file mode 100644 index 000000000..dc9e1018b --- /dev/null +++ b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs @@ -0,0 +1,115 @@ +using System; +using System.Linq; +using System.Text; + +namespace Humanizer.Localisation.NumberToWords +{ + internal class PolishNumberToWordsConverter : DefaultNumberToWordsConverter + { + private enum Numeral + { + One = 1, + Thousand = 1000, + Million = 1000000,//10^6 + Miliard = 1000000000,//10^9 + } + + private static readonly string Negative = "minus"; + private static readonly string Zero = "zero"; + + private static string ConvertNumberUnderThousand(Numeral numeral, int number) + { + if (numeral != Numeral.One && number == 1) + return string.Empty; + + var result = new StringBuilder(); + + var hundreds = number / 100; + if (hundreds > 0) + { + var map = new[] { "", "sto", "dwieście", "trzysta", "czterysta", "pięćset", "sześćset", "siedemset", "osiemset", "dziewięćset" }; + result.AppendFormat(@"{0} ", map[hundreds]); + number = number % 100; + } + + var tens = number / 10; + if (tens > 1) + { + var map = new[] { "", "dziesięć", "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt" }; + result.AppendFormat(@"{0} ", map[tens]); + number = number % 10; + } + + if (number > 0) + { + var map = new[] { "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "dziesięć", "jedenaście", "dwanaście", "trzynaście", "czternaście", "piętnaście", "szesnaście", "siedemnaście", "osiemnaście", "dziewiętnaście" }; + result.AppendFormat(@"{0} ", map[number]); + } + + return result.ToString(); + } + private static int GetMappingIndex(int number) + { + if (number == 1) + return 0; + + if (number > 1 && number < 5) + return 1;//denominator + + var tens = number / 10; + if (tens > 1) + { + var unity = number % 10; + if (unity > 1 && unity < 5) + return 1;//denominator + } + + return 2;//genitive + } + private static string GetSuffix(Numeral numeral, int num) + { + switch (numeral) + { + case Numeral.Miliard: + var miliard = new[] { "miliard", "miliardy", "miliardów" }; //one, denominator, genitive + return miliard[GetMappingIndex(num)]; + case Numeral.Million: + var million = new[] { "milion", "miliony", "milionów" }; //one, denominator, genitive + return million[GetMappingIndex(num)]; + case Numeral.Thousand: + var thousand = new[] { "tysiąc", "tysiące", "tysięcy" }; //one, denominator, genitive + return thousand[GetMappingIndex(num)]; + default: + return string.Empty; + } + } + + public override string Convert(int number) + { + if (number == 0) + return Zero; + + var result = new StringBuilder(); + + if (number < 0) + { + result.AppendFormat(@"{0} ", Negative); + number = Math.Abs(number); + } + + var numerals = ((Numeral[])Enum.GetValues(typeof(Numeral))).Reverse(); + foreach (var numeral in numerals) + { + var num = number / (int)numeral; + if (num > 0) + { + result.AppendFormat(@"{0}{1} ", ConvertNumberUnderThousand(numeral, num), GetSuffix(numeral, num)); + number %= (int)numeral; + } + } + + return result.ToString().Trim(); + } + + } +} diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index 4cdacdc5e..35945be07 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -1,7 +1,7 @@ -using System; +using Humanizer.Localisation.NumberToWords; +using System; using System.Collections.Generic; using System.Globalization; -using Humanizer.Localisation.NumberToWords; namespace Humanizer { /// @@ -14,7 +14,8 @@ public static class NumberToWordsExtension { { "en", () => new EnglishNumberToWordsConverter() }, { "ar", () => new ArabicNumberToWordsConverter() }, { "fa", () => new FarsiNumberToWordsConverter() }, - { "es", () => new SpanishNumberToWordsConverter() } + { "es", () => new SpanishNumberToWordsConverter() }, + { "pl", () => new PolishNumberToWordsConverter() } }; /// @@ -39,4 +40,4 @@ private static INumberToWordsConverter Converter } } } -} \ No newline at end of file +} From 58f59c5844e3a71a9ed39a0b1fe6f9e878e1ec34 Mon Sep 17 00:00:00 2001 From: Marcin Nowacki Date: Thu, 10 Apr 2014 22:27:23 +0200 Subject: [PATCH 12/30] Added Polish localization test for Now and NoTime --- src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs | 7 +++++++ .../Localisation/pl/TimeSpanHumanizeTests.cs | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs index 0ca929fcb..0a9d09f37 100644 --- a/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs @@ -1,4 +1,5 @@ using Humanizer.Localisation; +using Xunit; using Xunit.Extensions; namespace Humanizer.Tests.Localisation.pl @@ -164,5 +165,11 @@ public void YearsAgo(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); } + + [Fact] + public void Now() + { + DateHumanize.Verify("teraz", 0, TimeUnit.Day, Tense.Past); + } } } diff --git a/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs index d535fe868..f26440b24 100644 --- a/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs @@ -84,7 +84,13 @@ public void Days(int number, string expected) [InlineData(6, "6 tygodni")] public void Weeks(int number, string expected) { - Assert.Equal(expected, TimeSpan.FromDays(number*7).Humanize()); + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); + } + + [Fact] + public void NoTime() + { + Assert.Equal("brak czasu", TimeSpan.Zero.Humanize()); } } } From 002f5572ac1476fb44544f243a3f4ac9bcfd1340 Mon Sep 17 00:00:00 2001 From: Marcin Nowacki Date: Fri, 11 Apr 2014 10:45:56 +0200 Subject: [PATCH 13/30] Added PR to the release notes --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index 1f475bad5..3ef9a26ad 100644 --- a/release_notes.md +++ b/release_notes.md @@ -3,6 +3,7 @@ - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations + - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) From e4952b0d90d4baf6b91b33d51c7ac9033333c7af Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 19:12:53 +0430 Subject: [PATCH 14/30] minor cleanup --- .../NumberToWords/PolishNumberToWordsConverter.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs index dc9e1018b..c8a820677 100644 --- a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs @@ -14,8 +14,8 @@ private enum Numeral Miliard = 1000000000,//10^9 } - private static readonly string Negative = "minus"; - private static readonly string Zero = "zero"; + private const string Negative = "minus"; + private const string Zero = "zero"; private static string ConvertNumberUnderThousand(Numeral numeral, int number) { @@ -48,6 +48,7 @@ private static string ConvertNumberUnderThousand(Numeral numeral, int number) return result.ToString(); } + private static int GetMappingIndex(int number) { if (number == 1) @@ -66,6 +67,7 @@ private static int GetMappingIndex(int number) return 2;//genitive } + private static string GetSuffix(Numeral numeral, int num) { switch (numeral) @@ -110,6 +112,5 @@ public override string Convert(int number) return result.ToString().Trim(); } - } } From 2e63de862e7ae7a78701c23fa2c4b4f2374cce6b Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 19:52:08 +0430 Subject: [PATCH 15/30] lifted the contribution guideline & fixed #154 --- readme.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 2efef9428..4eb078c17 100644 --- a/readme.md +++ b/readme.md @@ -656,17 +656,24 @@ I have also flagged some of the easier issues as 'jump in' so you can start with I use [GitHub flow](http://scottchacon.com/2011/08/31/github-flow.html) for pull requests. So if you want to contribute, fork the repo, preferrably create a local branch to avoid conflicts with other activities, fix an issue and send a PR. -Pull requests are code reviewed. Here is what I look for in your pull request: - - - Clean implementation - - Very little or no comments because comments shouldn't be needed if you write clean code - - Xml documentation for new extensions or updating the existing documentation when you make a change - - Proper unit test coverage - - Adherence to the existing coding styles - - Updated readme if you change an existing feature or add something - - Add an entry in the release_notes.md file in the 'In Development' section with a link to your PR link and description of what's changed. Please follow the wording style for the description. - -Also please link to the issue(s) you're fixing from your PR description. +Pull requests are code reviewed. Here is a checklist you should tick through before submitting a pull request: + + - [ ] Implementation is clean + - [ ] Code adheres to the existing coding standards; e.g. no curlies for one-line blocks & no redundant empty lines between methods or code blocks + - [ ] No ReSharper warnings + - [ ] There is proper unit test coverage + - [ ] If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution + - [ ] There is very little or no comments (because comments shouldn't be needed if you write clean code) + - [ ] Xml documentation is added/updated for the addition/change + - [ ] Your PR is (re)based on top of the latest commits (more info below) + - [ ] Link to the issue(s) you're fixing from your PR description. Use `fixes #` + - [ ] Readme is updated if you change an existing feature or add a new one + - [ ] An entry is added in the release_notes.md file in the 'In Development' section with a link to your PR and a description of what's changed. Please follow the wording style for the description. + +Please rebase your code on top of the latest commits. +Before working on your fork make sure you pull the latest so you work on top of the latest commits to avoid merge conflicts. +Also before sending the pull request pleast rebase your code as there is a chance there has been a few commits pushed up after you pulled last. +Please refer to [this guide](https://gist.github.com/jbenet/ee6c9ac48068889b0912#the-workflow) if you're new to git. ###Need your help with localisation One area Humanizer could always use your help is localisation. From 8f4cf15020eba4e3e17673ced4fc9df6979b4578 Mon Sep 17 00:00:00 2001 From: danmalcolm Date: Fri, 11 Apr 2014 14:24:10 +0100 Subject: [PATCH 16/30] Including namespaces in MVC ModelMetadataProvider example Similar classes exist in System.Web.ModelBinding, which aren't used by ASP.Net MVC. Users copying and pasting the sample from the readme might end up using the wrong namespace. --- readme.md | 69 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/readme.md b/readme.md index 4eb078c17..c7753945e 100644 --- a/readme.md +++ b/readme.md @@ -568,43 +568,54 @@ You may find an Asp.Net MVC sample [in the code](https://github.com/MehdiK/Human This is achieved using a custom `DataAnnotationsModelMetadataProvider` I called [HumanizerMetadataProvider](https://github.com/MehdiK/Humanizer/blob/master/src/Humanizer.MvcSample/HumanizerMetadataProvider.cs). It is small enough to repeat here; so here we go: ```C# -public class HumanizerMetadataProvider : DataAnnotationsModelMetadataProvider +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using Humanizer; + +namespace YourApp { - protected override ModelMetadata CreateMetadata( - IEnumerable attributes, - Type containerType, - Func modelAccessor, - Type modelType, - string propertyName) + public class HumanizerMetadataProvider : DataAnnotationsModelMetadataProvider { - var propertyAttributes = attributes.ToList(); - var modelMetadata = base.CreateMetadata(propertyAttributes, containerType, modelAccessor, modelType, propertyName); - - if (IsTransformRequired(modelMetadata, propertyAttributes)) - modelMetadata.DisplayName = modelMetadata.PropertyName.Humanize(); - - return modelMetadata; - } - - private static bool IsTransformRequired(ModelMetadata modelMetadata, IList propertyAttributes) - { - if (string.IsNullOrEmpty(modelMetadata.PropertyName)) - return false; - - if (propertyAttributes.OfType().Any()) - return false; - - if (propertyAttributes.OfType().Any()) - return false; - - return true; + protected override ModelMetadata CreateMetadata( + IEnumerable attributes, + Type containerType, + Func modelAccessor, + Type modelType, + string propertyName) + { + var propertyAttributes = attributes.ToList(); + var modelMetadata = base.CreateMetadata(propertyAttributes, containerType, modelAccessor, modelType, propertyName); + + if (IsTransformRequired(modelMetadata, propertyAttributes)) + modelMetadata.DisplayName = modelMetadata.PropertyName.Humanize(); + + return modelMetadata; + } + + private static bool IsTransformRequired(ModelMetadata modelMetadata, IList propertyAttributes) + { + if (string.IsNullOrEmpty(modelMetadata.PropertyName)) + return false; + + if (propertyAttributes.OfType().Any()) + return false; + + if (propertyAttributes.OfType().Any()) + return false; + + return true; + } } } ``` This class calls the base class to extract the metadata and then, if required, humanizes the property name. It is checking if the property already has a `DisplayName` or `Display` attribute on it in which case the metadata provider will just honor the attribute and leave the property alone. For other properties it will Humanize the property name. That is all. -Now I need to register this metadata provider with Asp.Net MVC: +Now I need to register this metadata provider with Asp.Net MVC (making sure that I use System.Web.Mvc.ModelMetadataProviders, not System.Web.ModelBinding.ModelMetadataProviders): ```C# ModelMetadataProviders.Current = new HumanizerMetadataProvider(); From 967bedb2256bf546e2952f52cf5db69c196b14cd Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 20:42:19 +0430 Subject: [PATCH 17/30] changed the Model Binding sentence a bit --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index c7753945e..71255fd1f 100644 --- a/readme.md +++ b/readme.md @@ -615,13 +615,13 @@ namespace YourApp This class calls the base class to extract the metadata and then, if required, humanizes the property name. It is checking if the property already has a `DisplayName` or `Display` attribute on it in which case the metadata provider will just honor the attribute and leave the property alone. For other properties it will Humanize the property name. That is all. -Now I need to register this metadata provider with Asp.Net MVC (making sure that I use System.Web.Mvc.ModelMetadataProviders, not System.Web.ModelBinding.ModelMetadataProviders): +Now you need to register this metadata provider with Asp.Net MVC. Make sure you use System.Web.Mvc.ModelMetadataProviders, not System.Web.ModelBinding.ModelMetadataProviders): ```C# ModelMetadataProviders.Current = new HumanizerMetadataProvider(); ``` -... and now I can replace: +... and now you can replace: ```C# public class RegisterModel From 6139bf5bebd7e49cc2860100f7a1bd8ca8af1321 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 09:17:53 -0700 Subject: [PATCH 18/30] Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter --- src/Humanizer.Tests/NumberToOrdinalWordsTests.cs | 2 +- .../Localisation/NumberToWords/EnglishNumberToWordsConverter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Humanizer.Tests/NumberToOrdinalWordsTests.cs b/src/Humanizer.Tests/NumberToOrdinalWordsTests.cs index 60e0b72e9..079af043e 100644 --- a/src/Humanizer.Tests/NumberToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/NumberToOrdinalWordsTests.cs @@ -10,7 +10,7 @@ public class NumberToOrdinalWordsTests [InlineData(1, "first")] [InlineData(2, "second")] [InlineData(3, "third")] - [InlineData(4, "forth")] + [InlineData(4, "fourth")] [InlineData(5, "fifth")] [InlineData(6, "sixth")] [InlineData(7, "seventh")] diff --git a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs index c6a88f444..bae21a84a 100644 --- a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs @@ -13,7 +13,7 @@ internal class EnglishNumberToWordsConverter : INumberToWordsConverter {1, "first"}, {2, "second"}, {3, "third"}, - {4, "forth"}, + {4, "fourth"}, {5, "fifth"}, {8, "eighth"}, {9, "ninth"}, From 0954ae627d06604b73940de15d83ca6a8e872792 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 09:52:33 -0700 Subject: [PATCH 19/30] Updated release notes --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index 3ef9a26ad..1781a4573 100644 --- a/release_notes.md +++ b/release_notes.md @@ -4,6 +4,7 @@ - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords + - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) From 60ca6f11147edbf60a8450a2d471fd71ae75cd25 Mon Sep 17 00:00:00 2001 From: MehdiK Date: Fri, 11 Apr 2014 21:37:08 +0430 Subject: [PATCH 20/30] releasing v1.20.2 --- release_notes.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 1781a4573..1d64a0941 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,8 @@ ###In Development + +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) + +###v1.20.2 - 2014-04-11 - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation @@ -6,7 +10,7 @@ - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) ###v1.19.1 - 2014-04-10 - [#149](https://github.com/MehdiK/Humanizer/pull/149): Improved & refactored number to words localisation From 97bf7aa4fd79fea56e8dd7f37690105526351597 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 10:51:55 -0700 Subject: [PATCH 21/30] Refactor ToOrdinalWords to use existing NumberToWordsExtension instead of a separate extension --- ...provalTest.approve_public_api.approved.txt | 6 +----- src/Humanizer/Humanizer.csproj | 1 - .../NumberToOrdinalWordsExtension.cs | 20 ------------------- src/Humanizer/NumberToWordsExtension.cs | 10 ++++++++++ 4 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 src/Humanizer/NumberToOrdinalWordsExtension.cs 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 7f8823fa2..697c3256b 100644 --- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt +++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt @@ -224,11 +224,6 @@ public class NoMatchFoundException public NoMatchFoundException(string message, System.Exception inner) { } } -public class NumberToOrdinalWordsExtension -{ - public string ToOrdinalWords(int number) { } -} - public class NumberToTimeSpanExtensions { public System.TimeSpan Days(int days) { } @@ -241,6 +236,7 @@ public class NumberToTimeSpanExtensions public class NumberToWordsExtension { + public string ToOrdinalWords(int number) { } public string ToWords(int number) { } } diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 7194d124d..90952b650 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -107,7 +107,6 @@ - diff --git a/src/Humanizer/NumberToOrdinalWordsExtension.cs b/src/Humanizer/NumberToOrdinalWordsExtension.cs deleted file mode 100644 index d25dd325d..000000000 --- a/src/Humanizer/NumberToOrdinalWordsExtension.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Humanizer.Localisation.NumberToWords; - -namespace Humanizer -{ - /// - /// Transforms a number into ordinal words; e.g. 1 => first - /// - public static class NumberToOrdinalWordsExtension - { - /// - /// 1.ToOrdinalWords() -> "first" - /// - /// Number to be turned to ordinal words - /// - public static string ToOrdinalWords(this int number) - { - return new EnglishNumberToWordsConverter().ConvertToOrdinal(number); - } - } -} diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index 35945be07..3c980fdf4 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -28,6 +28,16 @@ public static string ToWords(this int number) return Converter.Convert(number); } + /// + /// 1.ToOrdinalWords() -> "first" + /// + /// Number to be turned to ordinal words + /// + public static string ToOrdinalWords(this int number) + { + return Converter.ConvertToOrdinal(number); + } + private static INumberToWordsConverter Converter { get From 5b9615e6f8c86c4780d48898bf501bd5831f7c2c Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 11:02:13 -0700 Subject: [PATCH 22/30] Updated readme with ToOrdinalWords refactoring --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index 1d64a0941..bda463439 100644 --- a/release_notes.md +++ b/release_notes.md @@ -9,6 +9,7 @@ - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter + - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization. [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) From 66666781ddfb2ccff8a38fbfb9c27f43c76d3fb1 Mon Sep 17 00:00:00 2001 From: Thomas Hunsaker Date: Fri, 11 Apr 2014 11:08:17 -0700 Subject: [PATCH 23/30] Moved PR to In Dev section Oops. --- release_notes.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/release_notes.md b/release_notes.md index bda463439..314c35d10 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,5 @@ ###In Development - + - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization. [Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) ###v1.20.2 - 2014-04-11 @@ -9,7 +9,6 @@ - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter - - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization. [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) From 212adc2af1d00efe310d263352fcc509179bc1d3 Mon Sep 17 00:00:00 2001 From: MehdiK Date: Sat, 12 Apr 2014 09:07:51 +0430 Subject: [PATCH 24/30] fixes the null exception on date humanize --- src/Humanizer/Configuration/Configurator.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Humanizer/Configuration/Configurator.cs b/src/Humanizer/Configuration/Configurator.cs index 437e8ca83..fbf52af16 100644 --- a/src/Humanizer/Configuration/Configurator.cs +++ b/src/Humanizer/Configuration/Configurator.cs @@ -22,6 +22,8 @@ public static class Configurator { "pl", () => new CzechSlovakPolishFormatter() } }; + private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy(); + /// /// The formatter to be used /// @@ -37,6 +39,10 @@ public static IFormatter Formatter } } - public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } + public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy + { + get { return _dateTimeHumanizeStrategy; } + set { _dateTimeHumanizeStrategy = value; } + } } } From 3e2fbfaa7c21f4892ca37e97d715bdaadab06679 Mon Sep 17 00:00:00 2001 From: MehdiK Date: Sat, 12 Apr 2014 09:10:35 +0430 Subject: [PATCH 25/30] added the PR to release notes --- release_notes.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 314c35d10..8cf4bc5d2 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,8 @@ ###In Development - - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization. + - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) + - [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize + [Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) ###v1.20.2 - 2014-04-11 From 72fa52159df6406029f6d76a0499fee71266eafb Mon Sep 17 00:00:00 2001 From: MehdiK Date: Sat, 12 Apr 2014 13:12:24 +0430 Subject: [PATCH 26/30] released v1.20.15 --- release_notes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release_notes.md b/release_notes.md index 8cf4bc5d2..10cafb4c5 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,9 +1,11 @@ ###In Development +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.15...master) + +###v1.20.15 - 2014-04-12 - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) - [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master) +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...v1.20.15) ###v1.20.2 - 2014-04-11 - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. From fb807102b02bc633650e5db378baa45b32cbec62 Mon Sep 17 00:00:00 2001 From: Max Malook Date: Sat, 12 Apr 2014 11:01:46 +0200 Subject: [PATCH 27/30] correct inline code escaping --- release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 10cafb4c5..0bf9a8279 100644 --- a/release_notes.md +++ b/release_notes.md @@ -2,7 +2,7 @@ [Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.15...master) ###v1.20.15 - 2014-04-12 - - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization + - [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored `ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization - [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize [Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...v1.20.15) From fc824d235ea42019605b098612c3a61c16aa00df Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Sat, 12 Apr 2014 12:28:19 +0300 Subject: [PATCH 28/30] fixed conflicts --- release_notes.md | 1 - 1 file changed, 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 0bf9a8279..e5b553235 100644 --- a/release_notes.md +++ b/release_notes.md @@ -157,4 +157,3 @@ fix it based on your requirements. ###v1.0.0 - 2013-11-10 No release history before this point: check out http://www.mehdi-khalili.com/humanizer-v1 for the feature-set at V1 - From bd4ed1ada04e65aef1398a7b8c2738a50e70b137 Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Sat, 12 Apr 2014 12:43:21 +0300 Subject: [PATCH 29/30] fixed conflicts --- release_notes.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/release_notes.md b/release_notes.md index e5b553235..26d576ebb 100644 --- a/release_notes.md +++ b/release_notes.md @@ -11,11 +11,8 @@ - [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library. - [#165](https://github.com/MehdiK/Humanizer/pull/165): Added precision based `DateTime.Humanize` strategy - [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation - - [#151](https://github.com/MehdiK/Humanizer/pull/151): Added Spanish ToWords Translations - - [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords - - [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter -[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2) +[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) ###v1.19.1 - 2014-04-10 - [#149](https://github.com/MehdiK/Humanizer/pull/149): Improved & refactored number to words localisation From 8346c23720332111c9a0a429d60f16375e561754 Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Sat, 12 Apr 2014 12:48:14 +0300 Subject: [PATCH 30/30] Added PR to the release notes --- release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release_notes.md b/release_notes.md index 26d576ebb..0ffe54643 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,6 @@ ###In Development + - [#181](https://github.com/Mehdik/Humanizer/pull/181): Added Bulgarian localization, date and timespan tests + [Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.15...master) ###v1.20.15 - 2014-04-12