From ff0a61fc1059cd8cd26c55d12f276732960749cd Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 09:55:09 +0200 Subject: [PATCH 01/10] Adding basic Hungarian localization --- src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.hu.resx | 234 +++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 src/Humanizer/Properties/Resources.hu.resx diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index efb54f5d9..3bb43fb9b 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -154,6 +154,7 @@ + diff --git a/src/Humanizer/Properties/Resources.hu.resx b/src/Humanizer/Properties/Resources.hu.resx new file mode 100644 index 000000000..420467a48 --- /dev/null +++ b/src/Humanizer/Properties/Resources.hu.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 + + + egy másodperce + + + {0} másodperce + + + egy perce + + + {0} perce + + + egy órája + + + {0} órája + + + tegnap + + + {0} napja + + + egy hónapja + + + {0} hónapja + + + egy éve + + + {0} éve + + + {0} nap + + + {0} óra + + + {0} miliszekundum + + + {0} perc + + + {0} másodperc + + + 1 nap + + + 1 óra + + + 1 miliszekundum + + + 1 perc + + + 1 másodperc + + + nincs idő + + + {0} hét + + + 1 hét + + + {0} nap múlva + + + {0} óra múlva + + + {0} perc múlva + + + {0} hónap műlva + + + {0} másodperc múlva + + + {0} év múlva + + + most + + + holnap + + + egy óra múlva + + + egy perc múlva + + + egy hónap múlva + + + egy másodperc múlva + + + egy év múlva + + \ No newline at end of file From 8c5a9d772877a6ff116902c8924e4e4b5831755b Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 10:50:26 +0200 Subject: [PATCH 02/10] Adding Hungarian date tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/hu/DateHumanizeTests.cs | 133 ++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 13513efe2..abbf6084a 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -84,6 +84,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs new file mode 100644 index 000000000..472ba446e --- /dev/null +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -0,0 +1,133 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.hu +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() + : base("hu-HU") + { + } + + [Theory] + [InlineData(1, "egy másodperce")] + [InlineData(10, "10 másodperce")] + [InlineData(59, "59 másodperce")] + [InlineData(60, "egy perce")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(1, "egy másodperc múlva")] + [InlineData(10, "10 másodperc múlva")] + [InlineData(59, "59 másodperc múlva")] + [InlineData(60, "egy perc múlva")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(1, "egy perce")] + [InlineData(10, "10 perce")] + [InlineData(44, "44 perce")] + [InlineData(45, "egy órája")] + [InlineData(120, "2 órája")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "egy perc múlva")] + [InlineData(10, "10 perc múlva")] + [InlineData(44, "44 perc múlva")] + [InlineData(45, "egy óra múlva")] + [InlineData(119, "egy óra múlva")] + [InlineData(120, "2 óra múlva")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [InlineData(1, "egy órája")] + [InlineData(10, "10 órája")] + [InlineData(23, "23 órája")] + [InlineData(24, "tegnap")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "egy óra múlva")] + [InlineData(10, "10 óra múlva")] + [InlineData(23, "23 óra múlva")] + [InlineData(24, "holnap")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(1, "tegnap")] + [InlineData(10, "10 napja")] + [InlineData(28, "28 napja")] + [InlineData(32, "egy hónapja")] + public void DaysAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "holnap")] + [InlineData(10, "10 nap múlva")] + [InlineData(28, "28 nap múlva")] + [InlineData(32, "egy hónap múlva")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "egy hónapja")] + [InlineData(10, "10 hónapja")] + [InlineData(11, "11 hónapja")] + [InlineData(12, "egy éve")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "one month from now")] + [InlineData(10, "10 months from now")] + [InlineData(11, "11 months from now")] + [InlineData(12, "one year from now")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(1, "one year ago")] + [InlineData(2, "2 years ago")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "one year from now")] + [InlineData(2, "2 years from now")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + } +} From b246872149982927b192ca1bab51e6694998d548 Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 11:08:12 +0200 Subject: [PATCH 03/10] Finishing Hungarian date and timespan tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/hu/DateHumanizeTests.cs | 16 +-- .../Localisation/hu/TimeSpanHumanizeTests.cs | 114 ++++++++++++++++++ src/Humanizer/Properties/Resources.hu.resx | 6 +- 4 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index abbf6084a..3429911d5 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -85,6 +85,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs index 472ba446e..6106a3566 100644 --- a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -104,26 +104,26 @@ public void MonthsAgo(int months, string expected) } [Theory] - [InlineData(1, "one month from now")] - [InlineData(10, "10 months from now")] - [InlineData(11, "11 months from now")] - [InlineData(12, "one year from now")] + [InlineData(1, "egy hónap múlva")] + [InlineData(10, "10 hónap múlva")] + [InlineData(11, "11 hónap múlva")] + [InlineData(12, "egy év múlva")] public void MonthsFromNow(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); } [Theory] - [InlineData(1, "one year ago")] - [InlineData(2, "2 years ago")] + [InlineData(1, "egy éve")] + [InlineData(2, "2 éve")] public void YearsAgo(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); } [Theory] - [InlineData(1, "one year from now")] - [InlineData(2, "2 years from now")] + [InlineData(1, "egy év múlva")] + [InlineData(2, "2 év múlva")] public void YearsFromNow(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..01e8b408c --- /dev/null +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -0,0 +1,114 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.hu +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("hu-HU") { } + + [Theory] + [InlineData(14, "2 hét")] + [InlineData(7, "1 hét")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(6, "6 nap")] + [InlineData(2, "2 nap")] + [InlineData(1, "1 nap")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 óra")] + [InlineData(1, "1 óra")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 perc")] + [InlineData(1, "1 perc")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(135, "2 perc")] + [InlineData(60, "1 perc")] + [InlineData(2, "2 másodperc")] + [InlineData(1, "1 másodperc")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2500, "2 másodperc")] + [InlineData(1400, "1 másodperc")] + [InlineData(2, "2 ezredmásodperc")] + [InlineData(1, "1 ezredmásodperc")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nincs idő")] + [InlineData(0, 2, "nincs idő")] + [InlineData(10, 2, "10 ezredmásodperc")] + [InlineData(1400, 2, "1 másodperc, 400 ezredmásodperc")] + [InlineData(2500, 2, "2 másodperc, 500 ezredmásodperc")] + [InlineData(120000, 2, "2 perc")] + [InlineData(62000, 2, "1 perc, 2 másodperc")] + [InlineData(62020, 2, "1 perc, 2 másodperc")] + [InlineData(62020, 3, "1 perc, 2 másodperc, 20 ezredmásodperc")] + [InlineData(3600020, 4, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 3, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 2, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 1, "1 óra")] + [InlineData(3603001, 2, "1 óra, 3 másodperc")] + [InlineData(3603001, 3, "1 óra, 3 másodperc, 1 ezredmásodperc")] + [InlineData(86400000, 3, "1 nap")] + [InlineData(86400000, 2, "1 nap")] + [InlineData(86400000, 1, "1 nap")] + [InlineData(86401000, 1, "1 nap")] + [InlineData(86401000, 2, "1 nap, 1 másodperc")] + [InlineData(86401200, 2, "1 nap, 1 másodperc")] + [InlineData(86401200, 3, "1 nap, 1 másodperc, 200 ezredmásodperc")] + [InlineData(1296000000, 1, "2 hét")] + [InlineData(1296000000, 2, "2 hét, 1 nap")] + [InlineData(1299600000, 2, "2 hét, 1 nap")] + [InlineData(1299600000, 3, "2 hét, 1 nap, 1 óra")] + [InlineData(1299630020, 3, "2 hét, 1 nap, 1 óra")] + [InlineData(1299630020, 4, "2 hét, 1 nap, 1 óra, 30 másodperc")] + [InlineData(1299630020, 5, "2 hét, 1 nap, 1 óra, 30 másodperc, 20 ezredmásodperc")] + public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); + Assert.Equal(expected, actual); + } + + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("nincs idő", actual); + } + } +} diff --git a/src/Humanizer/Properties/Resources.hu.resx b/src/Humanizer/Properties/Resources.hu.resx index 420467a48..df687010d 100644 --- a/src/Humanizer/Properties/Resources.hu.resx +++ b/src/Humanizer/Properties/Resources.hu.resx @@ -160,7 +160,7 @@ {0} óra - {0} miliszekundum + {0} ezredmásodperc {0} perc @@ -175,7 +175,7 @@ 1 óra - 1 miliszekundum + 1 ezredmásodperc 1 perc @@ -202,7 +202,7 @@ {0} perc múlva - {0} hónap műlva + {0} hónap múlva {0} másodperc múlva From 09f99554e8d223bffb0f0b523722a259b6e725bc Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 20:19:54 +0200 Subject: [PATCH 04/10] fixing issues as requested in the pull request --- release_notes.md | 1 + .../Localisation/hu/DateHumanizeTests.cs | 23 ------------------- .../Localisation/hu/TimeSpanHumanizeTests.cs | 11 --------- 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/release_notes.md b/release_notes.md index b33614dea..4e16ed190 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 + - [#179](https://github.com/MehdiK/Humanizer/pull/179): Adding Hungarian localisation [Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...master) diff --git a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs index 6106a3566..1bf2b32a6 100644 --- a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -13,8 +13,6 @@ public DateHumanizeTests() [Theory] [InlineData(1, "egy másodperce")] [InlineData(10, "10 másodperce")] - [InlineData(59, "59 másodperce")] - [InlineData(60, "egy perce")] public void SecondsAgo(int seconds, string expected) { DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); @@ -23,8 +21,6 @@ public void SecondsAgo(int seconds, string expected) [Theory] [InlineData(1, "egy másodperc múlva")] [InlineData(10, "10 másodperc múlva")] - [InlineData(59, "59 másodperc múlva")] - [InlineData(60, "egy perc múlva")] public void SecondsFromNow(int seconds, string expected) { DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); @@ -33,9 +29,6 @@ public void SecondsFromNow(int seconds, string expected) [Theory] [InlineData(1, "egy perce")] [InlineData(10, "10 perce")] - [InlineData(44, "44 perce")] - [InlineData(45, "egy órája")] - [InlineData(120, "2 órája")] public void MinutesAgo(int minutes, string expected) { DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); @@ -44,10 +37,6 @@ public void MinutesAgo(int minutes, string expected) [Theory] [InlineData(1, "egy perc múlva")] [InlineData(10, "10 perc múlva")] - [InlineData(44, "44 perc múlva")] - [InlineData(45, "egy óra múlva")] - [InlineData(119, "egy óra múlva")] - [InlineData(120, "2 óra múlva")] public void MinutesFromNow(int minutes, string expected) { DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); @@ -56,8 +45,6 @@ public void MinutesFromNow(int minutes, string expected) [Theory] [InlineData(1, "egy órája")] [InlineData(10, "10 órája")] - [InlineData(23, "23 órája")] - [InlineData(24, "tegnap")] public void HoursAgo(int hours, string expected) { DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); @@ -66,8 +53,6 @@ public void HoursAgo(int hours, string expected) [Theory] [InlineData(1, "egy óra múlva")] [InlineData(10, "10 óra múlva")] - [InlineData(23, "23 óra múlva")] - [InlineData(24, "holnap")] public void HoursFromNow(int hours, string expected) { DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); @@ -76,8 +61,6 @@ public void HoursFromNow(int hours, string expected) [Theory] [InlineData(1, "tegnap")] [InlineData(10, "10 napja")] - [InlineData(28, "28 napja")] - [InlineData(32, "egy hónapja")] public void DaysAgo(int days, string expected) { DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); @@ -86,8 +69,6 @@ public void DaysAgo(int days, string expected) [Theory] [InlineData(1, "holnap")] [InlineData(10, "10 nap múlva")] - [InlineData(28, "28 nap múlva")] - [InlineData(32, "egy hónap múlva")] public void DaysFromNow(int days, string expected) { DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); @@ -96,8 +77,6 @@ public void DaysFromNow(int days, string expected) [Theory] [InlineData(1, "egy hónapja")] [InlineData(10, "10 hónapja")] - [InlineData(11, "11 hónapja")] - [InlineData(12, "egy éve")] public void MonthsAgo(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); @@ -106,8 +85,6 @@ public void MonthsAgo(int months, string expected) [Theory] [InlineData(1, "egy hónap múlva")] [InlineData(10, "10 hónap múlva")] - [InlineData(11, "11 hónap múlva")] - [InlineData(12, "egy év múlva")] public void MonthsFromNow(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs index 01e8b408c..b81fb4fb7 100644 --- a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -56,17 +56,6 @@ public void Seconds(int seconds, string expected) Assert.Equal(expected, actual); } - [Theory] - [InlineData(2500, "2 másodperc")] - [InlineData(1400, "1 másodperc")] - [InlineData(2, "2 ezredmásodperc")] - [InlineData(1, "1 ezredmásodperc")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } - [Theory] [InlineData(0, 3, "nincs idő")] [InlineData(0, 2, "nincs idő")] From 9b4ced87234f5467f2a3cd3f239533bff243b8bc Mon Sep 17 00:00:00 2001 From: gyurisc Date: Sat, 12 Apr 2014 10:02:07 +0200 Subject: [PATCH 05/10] removing further tests --- src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs index b81fb4fb7..37c720629 100644 --- a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -18,7 +18,6 @@ public void Weeks(int days, string expected) } [Theory] - [InlineData(6, "6 nap")] [InlineData(2, "2 nap")] [InlineData(1, "1 nap")] public void Days(int days, string expected) @@ -46,8 +45,6 @@ public void Minutes(int minutes, string expected) } [Theory] - [InlineData(135, "2 perc")] - [InlineData(60, "1 perc")] [InlineData(2, "2 másodperc")] [InlineData(1, "1 másodperc")] public void Seconds(int seconds, string expected) From ab02f19a3c96667c0f49bb0635980f6e309ee543 Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 09:55:09 +0200 Subject: [PATCH 06/10] Adding basic Hungarian localization --- src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.hu.resx | 234 +++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 src/Humanizer/Properties/Resources.hu.resx diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 42f8ae754..b75f1673a 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -155,6 +155,7 @@ + diff --git a/src/Humanizer/Properties/Resources.hu.resx b/src/Humanizer/Properties/Resources.hu.resx new file mode 100644 index 000000000..420467a48 --- /dev/null +++ b/src/Humanizer/Properties/Resources.hu.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 + + + egy másodperce + + + {0} másodperce + + + egy perce + + + {0} perce + + + egy órája + + + {0} órája + + + tegnap + + + {0} napja + + + egy hónapja + + + {0} hónapja + + + egy éve + + + {0} éve + + + {0} nap + + + {0} óra + + + {0} miliszekundum + + + {0} perc + + + {0} másodperc + + + 1 nap + + + 1 óra + + + 1 miliszekundum + + + 1 perc + + + 1 másodperc + + + nincs idő + + + {0} hét + + + 1 hét + + + {0} nap múlva + + + {0} óra múlva + + + {0} perc múlva + + + {0} hónap műlva + + + {0} másodperc múlva + + + {0} év múlva + + + most + + + holnap + + + egy óra múlva + + + egy perc múlva + + + egy hónap múlva + + + egy másodperc múlva + + + egy év múlva + + \ No newline at end of file From 34c0cc966e1455d9d67f8ee7dee5edb28b035f05 Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 10:50:26 +0200 Subject: [PATCH 07/10] Adding Hungarian date tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/hu/DateHumanizeTests.cs | 133 ++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index b36032eae..36c56cc5c 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/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs new file mode 100644 index 000000000..472ba446e --- /dev/null +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -0,0 +1,133 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.hu +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() + : base("hu-HU") + { + } + + [Theory] + [InlineData(1, "egy másodperce")] + [InlineData(10, "10 másodperce")] + [InlineData(59, "59 másodperce")] + [InlineData(60, "egy perce")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(1, "egy másodperc múlva")] + [InlineData(10, "10 másodperc múlva")] + [InlineData(59, "59 másodperc múlva")] + [InlineData(60, "egy perc múlva")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(1, "egy perce")] + [InlineData(10, "10 perce")] + [InlineData(44, "44 perce")] + [InlineData(45, "egy órája")] + [InlineData(120, "2 órája")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "egy perc múlva")] + [InlineData(10, "10 perc múlva")] + [InlineData(44, "44 perc múlva")] + [InlineData(45, "egy óra múlva")] + [InlineData(119, "egy óra múlva")] + [InlineData(120, "2 óra múlva")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [InlineData(1, "egy órája")] + [InlineData(10, "10 órája")] + [InlineData(23, "23 órája")] + [InlineData(24, "tegnap")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "egy óra múlva")] + [InlineData(10, "10 óra múlva")] + [InlineData(23, "23 óra múlva")] + [InlineData(24, "holnap")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(1, "tegnap")] + [InlineData(10, "10 napja")] + [InlineData(28, "28 napja")] + [InlineData(32, "egy hónapja")] + public void DaysAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "holnap")] + [InlineData(10, "10 nap múlva")] + [InlineData(28, "28 nap múlva")] + [InlineData(32, "egy hónap múlva")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "egy hónapja")] + [InlineData(10, "10 hónapja")] + [InlineData(11, "11 hónapja")] + [InlineData(12, "egy éve")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "one month from now")] + [InlineData(10, "10 months from now")] + [InlineData(11, "11 months from now")] + [InlineData(12, "one year from now")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(1, "one year ago")] + [InlineData(2, "2 years ago")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "one year from now")] + [InlineData(2, "2 years from now")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + } +} From 912833d1594678aa7d7920547363d58e934815bf Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 11:08:12 +0200 Subject: [PATCH 08/10] Finishing Hungarian date and timespan tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../Localisation/hu/DateHumanizeTests.cs | 16 +-- .../Localisation/hu/TimeSpanHumanizeTests.cs | 114 ++++++++++++++++++ src/Humanizer/Properties/Resources.hu.resx | 6 +- 4 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 36c56cc5c..40f7c389a 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/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs index 472ba446e..6106a3566 100644 --- a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -104,26 +104,26 @@ public void MonthsAgo(int months, string expected) } [Theory] - [InlineData(1, "one month from now")] - [InlineData(10, "10 months from now")] - [InlineData(11, "11 months from now")] - [InlineData(12, "one year from now")] + [InlineData(1, "egy hónap múlva")] + [InlineData(10, "10 hónap múlva")] + [InlineData(11, "11 hónap múlva")] + [InlineData(12, "egy év múlva")] public void MonthsFromNow(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); } [Theory] - [InlineData(1, "one year ago")] - [InlineData(2, "2 years ago")] + [InlineData(1, "egy éve")] + [InlineData(2, "2 éve")] public void YearsAgo(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); } [Theory] - [InlineData(1, "one year from now")] - [InlineData(2, "2 years from now")] + [InlineData(1, "egy év múlva")] + [InlineData(2, "2 év múlva")] public void YearsFromNow(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..01e8b408c --- /dev/null +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -0,0 +1,114 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.hu +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("hu-HU") { } + + [Theory] + [InlineData(14, "2 hét")] + [InlineData(7, "1 hét")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(6, "6 nap")] + [InlineData(2, "2 nap")] + [InlineData(1, "1 nap")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 óra")] + [InlineData(1, "1 óra")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 perc")] + [InlineData(1, "1 perc")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(135, "2 perc")] + [InlineData(60, "1 perc")] + [InlineData(2, "2 másodperc")] + [InlineData(1, "1 másodperc")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2500, "2 másodperc")] + [InlineData(1400, "1 másodperc")] + [InlineData(2, "2 ezredmásodperc")] + [InlineData(1, "1 ezredmásodperc")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nincs idő")] + [InlineData(0, 2, "nincs idő")] + [InlineData(10, 2, "10 ezredmásodperc")] + [InlineData(1400, 2, "1 másodperc, 400 ezredmásodperc")] + [InlineData(2500, 2, "2 másodperc, 500 ezredmásodperc")] + [InlineData(120000, 2, "2 perc")] + [InlineData(62000, 2, "1 perc, 2 másodperc")] + [InlineData(62020, 2, "1 perc, 2 másodperc")] + [InlineData(62020, 3, "1 perc, 2 másodperc, 20 ezredmásodperc")] + [InlineData(3600020, 4, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 3, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 2, "1 óra, 20 ezredmásodperc")] + [InlineData(3600020, 1, "1 óra")] + [InlineData(3603001, 2, "1 óra, 3 másodperc")] + [InlineData(3603001, 3, "1 óra, 3 másodperc, 1 ezredmásodperc")] + [InlineData(86400000, 3, "1 nap")] + [InlineData(86400000, 2, "1 nap")] + [InlineData(86400000, 1, "1 nap")] + [InlineData(86401000, 1, "1 nap")] + [InlineData(86401000, 2, "1 nap, 1 másodperc")] + [InlineData(86401200, 2, "1 nap, 1 másodperc")] + [InlineData(86401200, 3, "1 nap, 1 másodperc, 200 ezredmásodperc")] + [InlineData(1296000000, 1, "2 hét")] + [InlineData(1296000000, 2, "2 hét, 1 nap")] + [InlineData(1299600000, 2, "2 hét, 1 nap")] + [InlineData(1299600000, 3, "2 hét, 1 nap, 1 óra")] + [InlineData(1299630020, 3, "2 hét, 1 nap, 1 óra")] + [InlineData(1299630020, 4, "2 hét, 1 nap, 1 óra, 30 másodperc")] + [InlineData(1299630020, 5, "2 hét, 1 nap, 1 óra, 30 másodperc, 20 ezredmásodperc")] + public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); + Assert.Equal(expected, actual); + } + + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("nincs idő", actual); + } + } +} diff --git a/src/Humanizer/Properties/Resources.hu.resx b/src/Humanizer/Properties/Resources.hu.resx index 420467a48..df687010d 100644 --- a/src/Humanizer/Properties/Resources.hu.resx +++ b/src/Humanizer/Properties/Resources.hu.resx @@ -160,7 +160,7 @@ {0} óra - {0} miliszekundum + {0} ezredmásodperc {0} perc @@ -175,7 +175,7 @@ 1 óra - 1 miliszekundum + 1 ezredmásodperc 1 perc @@ -202,7 +202,7 @@ {0} perc múlva - {0} hónap műlva + {0} hónap múlva {0} másodperc múlva From 9335c062a24e8aecead640b42eea4a110e3f9479 Mon Sep 17 00:00:00 2001 From: gyurisc Date: Fri, 11 Apr 2014 20:19:54 +0200 Subject: [PATCH 09/10] fixing issues as requested in the pull request --- release_notes.md | 2 +- .../Localisation/hu/DateHumanizeTests.cs | 23 ------------------- .../Localisation/hu/TimeSpanHumanizeTests.cs | 11 --------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/release_notes.md b/release_notes.md index 8cf4bc5d2..c035d665c 100644 --- a/release_notes.md +++ b/release_notes.md @@ -2,8 +2,8 @@ - [#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) + - [#179](https://github.com/MehdiK/Humanizer/pull/179): Adding Hungarian localisation ###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. diff --git a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs index 6106a3566..1bf2b32a6 100644 --- a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -13,8 +13,6 @@ public DateHumanizeTests() [Theory] [InlineData(1, "egy másodperce")] [InlineData(10, "10 másodperce")] - [InlineData(59, "59 másodperce")] - [InlineData(60, "egy perce")] public void SecondsAgo(int seconds, string expected) { DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); @@ -23,8 +21,6 @@ public void SecondsAgo(int seconds, string expected) [Theory] [InlineData(1, "egy másodperc múlva")] [InlineData(10, "10 másodperc múlva")] - [InlineData(59, "59 másodperc múlva")] - [InlineData(60, "egy perc múlva")] public void SecondsFromNow(int seconds, string expected) { DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); @@ -33,9 +29,6 @@ public void SecondsFromNow(int seconds, string expected) [Theory] [InlineData(1, "egy perce")] [InlineData(10, "10 perce")] - [InlineData(44, "44 perce")] - [InlineData(45, "egy órája")] - [InlineData(120, "2 órája")] public void MinutesAgo(int minutes, string expected) { DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); @@ -44,10 +37,6 @@ public void MinutesAgo(int minutes, string expected) [Theory] [InlineData(1, "egy perc múlva")] [InlineData(10, "10 perc múlva")] - [InlineData(44, "44 perc múlva")] - [InlineData(45, "egy óra múlva")] - [InlineData(119, "egy óra múlva")] - [InlineData(120, "2 óra múlva")] public void MinutesFromNow(int minutes, string expected) { DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); @@ -56,8 +45,6 @@ public void MinutesFromNow(int minutes, string expected) [Theory] [InlineData(1, "egy órája")] [InlineData(10, "10 órája")] - [InlineData(23, "23 órája")] - [InlineData(24, "tegnap")] public void HoursAgo(int hours, string expected) { DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); @@ -66,8 +53,6 @@ public void HoursAgo(int hours, string expected) [Theory] [InlineData(1, "egy óra múlva")] [InlineData(10, "10 óra múlva")] - [InlineData(23, "23 óra múlva")] - [InlineData(24, "holnap")] public void HoursFromNow(int hours, string expected) { DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); @@ -76,8 +61,6 @@ public void HoursFromNow(int hours, string expected) [Theory] [InlineData(1, "tegnap")] [InlineData(10, "10 napja")] - [InlineData(28, "28 napja")] - [InlineData(32, "egy hónapja")] public void DaysAgo(int days, string expected) { DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); @@ -86,8 +69,6 @@ public void DaysAgo(int days, string expected) [Theory] [InlineData(1, "holnap")] [InlineData(10, "10 nap múlva")] - [InlineData(28, "28 nap múlva")] - [InlineData(32, "egy hónap múlva")] public void DaysFromNow(int days, string expected) { DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); @@ -96,8 +77,6 @@ public void DaysFromNow(int days, string expected) [Theory] [InlineData(1, "egy hónapja")] [InlineData(10, "10 hónapja")] - [InlineData(11, "11 hónapja")] - [InlineData(12, "egy éve")] public void MonthsAgo(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); @@ -106,8 +85,6 @@ public void MonthsAgo(int months, string expected) [Theory] [InlineData(1, "egy hónap múlva")] [InlineData(10, "10 hónap múlva")] - [InlineData(11, "11 hónap múlva")] - [InlineData(12, "egy év múlva")] public void MonthsFromNow(int months, string expected) { DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs index 01e8b408c..b81fb4fb7 100644 --- a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -56,17 +56,6 @@ public void Seconds(int seconds, string expected) Assert.Equal(expected, actual); } - [Theory] - [InlineData(2500, "2 másodperc")] - [InlineData(1400, "1 másodperc")] - [InlineData(2, "2 ezredmásodperc")] - [InlineData(1, "1 ezredmásodperc")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } - [Theory] [InlineData(0, 3, "nincs idő")] [InlineData(0, 2, "nincs idő")] From 3e9e978d8260731df47f1c0b7083a0d00f6da9b7 Mon Sep 17 00:00:00 2001 From: gyurisc Date: Sat, 12 Apr 2014 10:02:07 +0200 Subject: [PATCH 10/10] removing further tests --- src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs index b81fb4fb7..37c720629 100644 --- a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -18,7 +18,6 @@ public void Weeks(int days, string expected) } [Theory] - [InlineData(6, "6 nap")] [InlineData(2, "2 nap")] [InlineData(1, "1 nap")] public void Days(int days, string expected) @@ -46,8 +45,6 @@ public void Minutes(int minutes, string expected) } [Theory] - [InlineData(135, "2 perc")] - [InlineData(60, "1 perc")] [InlineData(2, "2 másodperc")] [InlineData(1, "1 másodperc")] public void Seconds(int seconds, string expected)