diff --git a/release_notes.md b/release_notes.md index 9808c2fda..8dc9f54f8 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,5 @@ ###In Development + - [#120](https://github.com/MehdiK/Humanizer/pull/120): Added translation for culture 'de' [Commits](https://github.com/MehdiK/Humanizer/compare/v1.15.1...master) diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 61b5dfaae..d0659af4d 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -79,6 +79,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs new file mode 100644 index 000000000..cef1b60f8 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs @@ -0,0 +1,119 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.de +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() : base("de-DE") {} + + [Theory] + [InlineData(-10, "vor 10 Tagen")] + [InlineData(-3, "vor 3 Tagen")] + [InlineData(-2, "vor 2 Tagen")] + [InlineData(-1, "gestern")] + public void DaysAgo(int days, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Tagen")] + [InlineData(1, "morgen")] + public void InDays(int days, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize()); + } + + [Theory] + [InlineData(-10, "vor 10 Stunden")] + [InlineData(-3, "vor 3 Stunden")] + [InlineData(-2, "vor 2 Stunden")] + [InlineData(-1, "vor einer Stunde")] + public void HoursAgo(int hours, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Stunden")] + [InlineData(1, "in einer Stunde")] + public void InHours(int hours, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize()); + } + + [Theory] + [InlineData(-10, "vor 10 Minuten")] + [InlineData(-3, "vor 3 Minuten")] + [InlineData(-2, "vor 2 Minuten")] + [InlineData(-1, "vor einer Minute")] + public void MinutesAgo(int minutes, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Minuten")] + [InlineData(1, "in einer Minute")] + public void InMinutes(int minutes, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(-10, "vor 10 Monaten")] + [InlineData(-3, "vor 3 Monaten")] + [InlineData(-2, "vor 2 Monaten")] + [InlineData(-1, "vor einem Monat")] + public void MonthsAgo(int months, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Monaten")] + [InlineData(1, "in einem Monat")] + public void InMonths(int months, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize()); + } + + [Theory] + [InlineData(-10, "vor 10 Sekunden")] + [InlineData(-3, "vor 3 Sekunden")] + [InlineData(-2, "vor 2 Sekunden")] + [InlineData(-1, "vor einer Sekunde")] + public void SecondsAgo(int seconds, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Sekunden")] + [InlineData(1, "in einer Sekunde")] + public void InSeconds(int seconds, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(-10, "vor 10 Jahren")] + [InlineData(-3, "vor 3 Jahren")] + [InlineData(-2, "vor 2 Jahren")] + [InlineData(-1, "vor einem Jahr")] + public void YearsAgo(int years, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize()); + } + + [Theory] + [InlineData(2, "in 2 Jahren")] + [InlineData(1, "in einem Jahr")] + public void InYears(int years, string expected) + { + Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize()); + } + } +} diff --git a/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..9ffd12b56 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs @@ -0,0 +1,70 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.de +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("de-DE") {} + + [Theory] + [InlineData(7, "Eine Woche")] + [InlineData(14, "2 Wochen")] + [InlineData(21, "3 Wochen")] + [InlineData(77, "11 Wochen")] + public void Weeks(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + + [Theory] + [InlineData(1, "Ein Tag")] + [InlineData(2, "2 Tage")] + public void Days(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "Eine Stunde")] + [InlineData(2, "2 Stunden")] + public void Hours(int hours, string expected) + { + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + } + + [Theory] + [InlineData(1, "Eine Minute")] + [InlineData(2, "2 Minuten")] + public void Minutes(int minutes, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + } + + + [Theory] + [InlineData(1, "Eine Sekunde")] + [InlineData(2, "2 Sekunden")] + public void Seconds(int seconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(1, "Eine Millisekunde")] + [InlineData(2, "2 Millisekunden")] + 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("Keine Zeit", TimeSpan.Zero.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index e58bc7aea..f45626c98 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -149,6 +149,7 @@ + diff --git a/src/Humanizer/Properties/Resources.de.resx b/src/Humanizer/Properties/Resources.de.resx new file mode 100644 index 000000000..715aadf70 --- /dev/null +++ b/src/Humanizer/Properties/Resources.de.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 + + + vor einer Sekunde + + + vor {0} Sekunden + + + vor einer Minute + + + vor {0} Minuten + + + vor einer Stunde + + + vor {0} Stunden + + + gestern + + + vor {0} Tagen + + + vor einem Monat + + + vor {0} Monaten + + + vor einem Jahr + + + vor {0} Jahren + + + {0} Tage + + + {0} Stunden + + + {0} Millisekunden + + + {0} Minuten + + + {0} Sekunden + + + Ein Tag + + + Eine Stunde + + + Eine Millisekunde + + + Eine Minute + + + Eine Sekunde + + + Keine Zeit + + + {0} Wochen + + + Eine Woche + + + in {0} Tagen + + + in {0} Stunden + + + in {0} Minuten + + + in {0} Monaten + + + in {0} Sekunden + + + in {0} Jahren + + + jetzt + + + morgen + + + in einer Stunde + + + in einer Minute + + + in einem Monat + + + in einer Sekunde + + + in einem Jahr + + \ No newline at end of file