From 8c6346f857dadcd1f4dbf4fc97c3182be7a2bff5 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 9 Apr 2014 21:37:37 +0100 Subject: [PATCH 1/4] Danish translation --- src/Humanizer.Tests/Humanizer.Tests.csproj | 2 + .../Localisation/da/DateHumanizeTests.cs | 139 +++++++++++ .../Localisation/da/TimeSpanHumanizeTests.cs | 101 ++++++++ src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.da.resx | 234 ++++++++++++++++++ 5 files changed, 477 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs create mode 100644 src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs create mode 100644 src/Humanizer/Properties/Resources.da.resx diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 8320b7508..6848778b0 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -78,6 +78,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs new file mode 100644 index 000000000..0494b416b --- /dev/null +++ b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs @@ -0,0 +1,139 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.da +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() + : base("da") + { + } + + [Theory] + [InlineData(-10, "10 dage siden")] + [InlineData(-3, "3 dage siden")] + [InlineData(-2, "2 dage siden")] + [InlineData(-1, "i går")] + public void DaysAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "i morgen")] + [InlineData(10, "10 dage fra nu")] + [InlineData(28, "28 dage fra nu")] + [InlineData(32, "en måned fra nu")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "et sekund fra nu")] + [InlineData(10, "10 sekunder fra nu")] + [InlineData(59, "59 sekunder fra nu")] + [InlineData(60, "et minut fra nu")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(-10, "10 timer siden")] + [InlineData(-3, "3 timer siden")] + [InlineData(-2, "2 timer siden")] + [InlineData(-1, "en time siden")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "en time fra nu")] + [InlineData(10, "10 timer fra nu")] + [InlineData(23, "23 timer fra nu")] + [InlineData(24, "i morgen")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(-10, "10 minutter siden")] + [InlineData(-3, "3 minutter siden")] + [InlineData(-2, "2 minutter siden")] + [InlineData(-1, "et minut siden")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "et minut fra nu")] + [InlineData(10, "10 minutter fra nu")] + [InlineData(44, "44 minutter fra nu")] + [InlineData(45, "en time fra nu")] + [InlineData(119, "en time fra nu")] + [InlineData(120, "2 timer fra nu")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + [Theory] + [InlineData(-10, "10 måneder siden")] + [InlineData(-3, "3 måneder siden")] + [InlineData(-2, "2 måneder siden")] + [InlineData(-1, "en måned siden")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "en måned fra nu")] + [InlineData(10, "10 måneder fra nu")] + [InlineData(11, "11 måneder fra nu")] + [InlineData(12, "et år fra nu")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(-10, "10 sekunder siden")] + [InlineData(-3, "3 sekunder siden")] + [InlineData(-2, "2 sekunder siden")] + [InlineData(-1, "et sekund siden")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(-10, "10 år siden")] + [InlineData(-3, "3 år siden")] + [InlineData(-2, "2 år siden")] + [InlineData(-1, "et år siden")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "et år fra nu")] + [InlineData(2, "2 år fra nu")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + [Theory] + [InlineData(0, "nu")] + public void Now(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + } +} diff --git a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..b33f3ae15 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs @@ -0,0 +1,101 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.da +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("da") { } + + [Theory] + [InlineData(7, "en uge")] + [InlineData(14, "2 uger")] + public void Weeks(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "en dag")] + [InlineData(2, "2 dage")] + public void Days(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "en time")] + [InlineData(2, "2 timer")] + public void Hours(int hours, string expected) + { + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + } + + [Theory] + [InlineData(1, "et minut")] + [InlineData(2, "2 minutter")] + public void Minutes(int minutes, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(1, "et sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int seconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(1, "et millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int milliseconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + } + + [Theory] + [InlineData(0, 3, "ingen tid")] + [InlineData(0, 2, "ingen tid")] + [InlineData(10, 2, "10 millisekunder")] + [InlineData(1400, 2, "1 sekund, 400 millisekunder")] + [InlineData(2500, 2, "2 sekunder, 500 millisekunder")] + [InlineData(120000, 2, "2 minutter")] + [InlineData(62000, 2, "1 minute, 2 sekunder")] + [InlineData(62020, 2, "1 minute, 2 sekunder")] + [InlineData(62020, 3, "1 minute, 2 sekunder, 20 millisekunder")] + [InlineData(3600020, 4, "1 time, 20 millisekunder")] + [InlineData(3600020, 3, "1 time, 20 millisekunder")] + [InlineData(3600020, 2, "1 time, 20 millisekunder")] + [InlineData(3600020, 1, "1 time")] + [InlineData(3603001, 2, "1 time, 3 sekunder")] + [InlineData(3603001, 3, "1 time, 3 sekunder, 1 millisekund")] + [InlineData(86400000, 3, "1 dag")] + [InlineData(86400000, 2, "1 dag")] + [InlineData(86400000, 1, "1 dag")] + [InlineData(86401000, 1, "1 dag")] + [InlineData(86401000, 2, "1 dag, 1 sekund")] + [InlineData(86401200, 2, "1 dag, 1 sekund")] + [InlineData(86401200, 3, "1 dag, 1 sekund, 200 millisekunder")] + [InlineData(1296000000, 1, "2 weeks")] + [InlineData(1296000000, 2, "2 weeks, 1 dag")] + [InlineData(1299600000, 2, "2 weeks, 1 dag")] + [InlineData(1299600000, 3, "2 weeks, 1 dag, 1 time")] + [InlineData(1299630020, 3, "2 weeks, 1 dag, 1 time")] + [InlineData(1299630020, 4, "2 weeks, 1 dag, 1 time, 30 sekunder")] + [InlineData(1299630020, 5, "2 weeks, 1 dag, 1 time, 30 sekunder, 20 millisekunder")] + public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); + Assert.Equal(expected, actual); + } + + [Fact] + public void NoTime() + { + Assert.Equal("ingen tid", TimeSpan.Zero.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 9a25522ea..bfde34202 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -145,6 +145,7 @@ + diff --git a/src/Humanizer/Properties/Resources.da.resx b/src/Humanizer/Properties/Resources.da.resx new file mode 100644 index 000000000..43107aff9 --- /dev/null +++ b/src/Humanizer/Properties/Resources.da.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 + + + et sekund siden + + + {0} sekunder siden + + + et minut siden + + + {0} minutter siden + + + en time siden + + + {0} timer siden + + + i går + + + {0} dage siden + + + en måned siden + + + {0} måneder siden + + + et år siden + + + {0} år siden + + + {0} dage + + + {0} timer + + + {0} millisekunder + + + {0} minutter + + + {0} sekunder + + + en dag + + + en time + + + et millisekund + + + et minutt + + + et sekund + + + ingen tid + + + {0} uger + + + en uge + + + {0} dage fra nu + + + {0} timer fra nu + + + {0} minutter fra nu + + + {0} måneder fra nu + + + {0} sekunder fra nu + + + {0} år fra nu + + + nu + + + i morgen + + + en time fra nu + + + et minut fra nu + + + en måned fra nu + + + et sekund fra nu + + + et år fra nu + + \ No newline at end of file From b14d02a231fa2428e2cae9c8b367cc72b94e38ca Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 9 Apr 2014 21:41:44 +0100 Subject: [PATCH 2/4] Add pull request to release notes --- release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release_notes.md b/release_notes.md index c43e7cf48..ce007e095 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,7 @@ ###In Development +- [#144](https://github.com/MehdiK/Humanizer/pull/144): Danish localization (strings, tests) + [Commits](https://github.com/MehdiK/Humanizer/compare/v1.18.1...master) ###v1.18.1 - 2014-04-09 From e633ae3380273cea134b15912ab6e8b9cbc09818 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 9 Apr 2014 21:56:10 +0100 Subject: [PATCH 3/4] Fixed language code, spelling errors Was using the wrong language code and fixed some spelling errors. Changes text in TimeSpanWithPrecesion test. --- .../Localisation/da/DateHumanizeTests.cs | 2 +- .../Localisation/da/TimeSpanHumanizeTests.cs | 50 +++++++++---------- src/Humanizer/Properties/Resources.da.resx | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs index 0494b416b..ed7b9d54f 100644 --- a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs @@ -6,7 +6,7 @@ namespace Humanizer.Tests.Localisation.da public class DateHumanizeTests : AmbientCulture { public DateHumanizeTests() - : base("da") + : base("da-DK") { } diff --git a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs index b33f3ae15..66c5ef912 100644 --- a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs @@ -6,7 +6,7 @@ namespace Humanizer.Tests.Localisation.da { public class TimeSpanHumanizeTests : AmbientCulture { - public TimeSpanHumanizeTests() : base("da") { } + public TimeSpanHumanizeTests() : base("da-DK") { } [Theory] [InlineData(7, "en uge")] @@ -60,32 +60,32 @@ public void Milliseconds(int milliseconds, string expected) [InlineData(0, 3, "ingen tid")] [InlineData(0, 2, "ingen tid")] [InlineData(10, 2, "10 millisekunder")] - [InlineData(1400, 2, "1 sekund, 400 millisekunder")] + [InlineData(1400, 2, "et sekund, 400 millisekunder")] [InlineData(2500, 2, "2 sekunder, 500 millisekunder")] [InlineData(120000, 2, "2 minutter")] - [InlineData(62000, 2, "1 minute, 2 sekunder")] - [InlineData(62020, 2, "1 minute, 2 sekunder")] - [InlineData(62020, 3, "1 minute, 2 sekunder, 20 millisekunder")] - [InlineData(3600020, 4, "1 time, 20 millisekunder")] - [InlineData(3600020, 3, "1 time, 20 millisekunder")] - [InlineData(3600020, 2, "1 time, 20 millisekunder")] - [InlineData(3600020, 1, "1 time")] - [InlineData(3603001, 2, "1 time, 3 sekunder")] - [InlineData(3603001, 3, "1 time, 3 sekunder, 1 millisekund")] - [InlineData(86400000, 3, "1 dag")] - [InlineData(86400000, 2, "1 dag")] - [InlineData(86400000, 1, "1 dag")] - [InlineData(86401000, 1, "1 dag")] - [InlineData(86401000, 2, "1 dag, 1 sekund")] - [InlineData(86401200, 2, "1 dag, 1 sekund")] - [InlineData(86401200, 3, "1 dag, 1 sekund, 200 millisekunder")] - [InlineData(1296000000, 1, "2 weeks")] - [InlineData(1296000000, 2, "2 weeks, 1 dag")] - [InlineData(1299600000, 2, "2 weeks, 1 dag")] - [InlineData(1299600000, 3, "2 weeks, 1 dag, 1 time")] - [InlineData(1299630020, 3, "2 weeks, 1 dag, 1 time")] - [InlineData(1299630020, 4, "2 weeks, 1 dag, 1 time, 30 sekunder")] - [InlineData(1299630020, 5, "2 weeks, 1 dag, 1 time, 30 sekunder, 20 millisekunder")] + [InlineData(62000, 2, "et minut, 2 sekunder")] + [InlineData(62020, 2, "et minut, 2 sekunder")] + [InlineData(62020, 3, "et minut, 2 sekunder, 20 millisekunder")] + [InlineData(3600020, 4, "en time, 20 millisekunder")] + [InlineData(3600020, 3, "en time, 20 millisekunder")] + [InlineData(3600020, 2, "en time, 20 millisekunder")] + [InlineData(3600020, 1, "en time")] + [InlineData(3603001, 2, "en time, 3 sekunder")] + [InlineData(3603001, 3, "en time, 3 sekunder, et millisekund")] + [InlineData(86400000, 3, "en dag")] + [InlineData(86400000, 2, "en dag")] + [InlineData(86400000, 1, "en dag")] + [InlineData(86401000, 1, "en dag")] + [InlineData(86401000, 2, "en dag, et sekund")] + [InlineData(86401200, 2, "en dag, et sekund")] + [InlineData(86401200, 3, "en dag, et sekund, 200 millisekunder")] + [InlineData(1296000000, 1, "2 uger")] + [InlineData(1296000000, 2, "2 uger, en dag")] + [InlineData(1299600000, 2, "2 uger, en dag")] + [InlineData(1299600000, 3, "2 uger, en dag, en time")] + [InlineData(1299630020, 3, "2 uger, en dag, en time")] + [InlineData(1299630020, 4, "2 uger, en dag, en time, 30 sekunder")] + [InlineData(1299630020, 5, "2 uger, en dag, en time, 30 sekunder, 20 millisekunder")] public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) { var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); diff --git a/src/Humanizer/Properties/Resources.da.resx b/src/Humanizer/Properties/Resources.da.resx index 43107aff9..ad88dee52 100644 --- a/src/Humanizer/Properties/Resources.da.resx +++ b/src/Humanizer/Properties/Resources.da.resx @@ -178,7 +178,7 @@ et millisekund - et minutt + et minut et sekund From 54715d107c722ab8351176d1d3de05084a6c6166 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 9 Apr 2014 21:59:09 +0100 Subject: [PATCH 4/4] Removed unneeded test + redundant spaces --- .../Localisation/da/DateHumanizeTests.cs | 7 ++-- .../Localisation/da/TimeSpanHumanizeTests.cs | 36 ------------------- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs index ed7b9d54f..cfd9e7fb4 100644 --- a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs @@ -5,16 +5,13 @@ namespace Humanizer.Tests.Localisation.da { public class DateHumanizeTests : AmbientCulture { - public DateHumanizeTests() - : base("da-DK") - { - } + public DateHumanizeTests() : base("da-DK") { } [Theory] [InlineData(-10, "10 dage siden")] [InlineData(-3, "3 dage siden")] [InlineData(-2, "2 dage siden")] - [InlineData(-1, "i går")] + [InlineData(-1, "i går")] public void DaysAgo(int days, string expected) { DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); diff --git a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs index 66c5ef912..b5547b405 100644 --- a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs @@ -56,42 +56,6 @@ public void Milliseconds(int milliseconds, string expected) Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); } - [Theory] - [InlineData(0, 3, "ingen tid")] - [InlineData(0, 2, "ingen tid")] - [InlineData(10, 2, "10 millisekunder")] - [InlineData(1400, 2, "et sekund, 400 millisekunder")] - [InlineData(2500, 2, "2 sekunder, 500 millisekunder")] - [InlineData(120000, 2, "2 minutter")] - [InlineData(62000, 2, "et minut, 2 sekunder")] - [InlineData(62020, 2, "et minut, 2 sekunder")] - [InlineData(62020, 3, "et minut, 2 sekunder, 20 millisekunder")] - [InlineData(3600020, 4, "en time, 20 millisekunder")] - [InlineData(3600020, 3, "en time, 20 millisekunder")] - [InlineData(3600020, 2, "en time, 20 millisekunder")] - [InlineData(3600020, 1, "en time")] - [InlineData(3603001, 2, "en time, 3 sekunder")] - [InlineData(3603001, 3, "en time, 3 sekunder, et millisekund")] - [InlineData(86400000, 3, "en dag")] - [InlineData(86400000, 2, "en dag")] - [InlineData(86400000, 1, "en dag")] - [InlineData(86401000, 1, "en dag")] - [InlineData(86401000, 2, "en dag, et sekund")] - [InlineData(86401200, 2, "en dag, et sekund")] - [InlineData(86401200, 3, "en dag, et sekund, 200 millisekunder")] - [InlineData(1296000000, 1, "2 uger")] - [InlineData(1296000000, 2, "2 uger, en dag")] - [InlineData(1299600000, 2, "2 uger, en dag")] - [InlineData(1299600000, 3, "2 uger, en dag, en time")] - [InlineData(1299630020, 3, "2 uger, en dag, en time")] - [InlineData(1299630020, 4, "2 uger, en dag, en time, 30 sekunder")] - [InlineData(1299630020, 5, "2 uger, en dag, en time, 30 sekunder, 20 millisekunder")] - public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); - Assert.Equal(expected, actual); - } - [Fact] public void NoTime() {