From 6d0f9970299d1b816540e6f4c81f8a403760d85b Mon Sep 17 00:00:00 2001 From: Jens-Christian Skibakk Date: Tue, 27 May 2014 10:13:35 +0200 Subject: [PATCH 1/2] Added neutral resources for nb --- src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.nb.resx | 234 +++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 src/Humanizer/Properties/Resources.nb.resx diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index 9a584436d..de6eaa08e 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -168,6 +168,7 @@ + diff --git a/src/Humanizer/Properties/Resources.nb.resx b/src/Humanizer/Properties/Resources.nb.resx new file mode 100644 index 000000000..240a6ba25 --- /dev/null +++ b/src/Humanizer/Properties/Resources.nb.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 + + + ett sekund siden + + + {0} sekunder siden + + + ett minutt siden + + + {0} minutter siden + + + en time siden + + + {0} timer siden + + + i går + + + {0} dager siden + + + en måned siden + + + {0} måneder siden + + + ett år siden + + + {0} år siden + + + {0} dager + + + {0} timer + + + {0} millisekunder + + + {0} minutter + + + {0} sekunder + + + en dag + + + en time + + + ett millisekund + + + ett minutt + + + ett sekund + + + ingen tid + + + {0} uker + + + en uke + + + {0} dager fra nå + + + {0} timer fra nå + + + {0} minutter fra nå + + + {0} måneder fra nå + + + {0} sekunder fra nå + + + {0} år fra nå + + + + + + i morgen + + + en time fra nå + + + ett minutt fra nå + + + en måned fra nå + + + ett sekund fra nå + + + ett år fra nå + + \ No newline at end of file From 2e4a78e9e9d4645e488738ddc8f71849171073d2 Mon Sep 17 00:00:00 2001 From: Jens-Christian Skibakk Date: Tue, 27 May 2014 10:34:34 +0200 Subject: [PATCH 2/2] unit tests for neutral language nb --- src/Humanizer.Tests/Humanizer.Tests.csproj | 2 + .../Localisation/nb/DateHumanizeTests.cs | 116 ++++++++++++++++++ .../Localisation/nb/TimeSpanHumanizeTests.cs | 65 ++++++++++ 3 files changed, 183 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs create mode 100644 src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index c206f8c2b..9d2a1d449 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -66,6 +66,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs new file mode 100644 index 000000000..454e23e8e --- /dev/null +++ b/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs @@ -0,0 +1,116 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.nb +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() + : base("nb") + { + } + + [Theory] + [InlineData(-2, "2 dager 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 dager fra nå")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "ett sekund fra nå")] + [InlineData(10, "10 sekunder fra nå")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [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 nå")] + [InlineData(10, "10 timer fra nå")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(-2, "2 minutter siden")] + [InlineData(-1, "ett minutt siden")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "ett minutt fra nå")] + [InlineData(10, "10 minutter fra nå")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [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 nå")] + [InlineData(10, "10 måneder fra nå")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(-2, "2 sekunder siden")] + [InlineData(-1, "ett sekund siden")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(-2, "2 år siden")] + [InlineData(-1, "ett år siden")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "ett år fra nå")] + [InlineData(2, "2 år fra nå")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + [Theory] + [InlineData(0, "nå")] + public void Now(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + } +} diff --git a/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..0654e6bd9 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs @@ -0,0 +1,65 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.nb +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("nb") { } + + [Theory] + [InlineData(7, "en uke")] + [InlineData(14, "2 uker")] + public void Weeks(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "en dag")] + [InlineData(2, "2 dager")] + 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, "ett minutt")] + [InlineData(2, "2 minutter")] + public void Minutes(int minutes, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(1, "ett sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int seconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(1, "ett millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int milliseconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + } + + [Fact] + public void NoTime() + { + Assert.Equal("ingen tid", TimeSpan.Zero.Humanize()); + } + } +} \ No newline at end of file