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 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..cfd9e7fb4 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs @@ -0,0 +1,136 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.da +{ + public class DateHumanizeTests : AmbientCulture + { + 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")] + 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..b5547b405 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs @@ -0,0 +1,65 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.da +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("da-DK") { } + + [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()); + } + + [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..ad88dee52 --- /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 minut + + + 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