diff --git a/release_notes.md b/release_notes.md index 3bc2f4b6d..dc7bc35e6 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,7 @@ ###In Development +- [#135](https://github.com/MehdiK/Humanizer/pull/135): Swedish localization (strings, tests) + [Commits](https://github.com/MehdiK/Humanizer/compare/v1.17.1...master) ###v1.17.1 - 2014-04-06 diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 444ac46d6..05addc363 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -95,6 +95,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs new file mode 100644 index 000000000..19215ab04 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs @@ -0,0 +1,109 @@ +using Humanizer.Localisation; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.sv +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() + : base("sv-SE") + { + } + + [Theory] + [InlineData(1, "om en sekund")] + [InlineData(2, "om 2 sekunder")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(1, "om en minut")] + [InlineData(2, "om 2 minuter")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [InlineData(1, "om en timme")] + [InlineData(2, "om 2 timmar")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(1, "i morgon")] + [InlineData(2, "om 2 dagar")] + public void DayFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "om en månad")] + [InlineData(2, "om 2 månader")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(1, "om ett år")] + [InlineData(2, "om 2 år")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + [Theory] + [InlineData(1, "en sekund sedan")] + [InlineData(2, "för 2 sekunder sedan")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(1, "en minut sedan")] + [InlineData(2, "för 2 minuter sedan")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "en timme sedan")] + [InlineData(2, "för 2 timmar sedan")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "igår")] + [InlineData(2, "för 2 dagar sedan")] + public void DayAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "en månad sedan")] + [InlineData(2, "för 2 månader sedan")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "ett år sedan")] + [InlineData(2, "för 2 år sedan")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + } +} diff --git a/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..841efd21b --- /dev/null +++ b/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs @@ -0,0 +1,62 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.sv +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() + : base("sv-SE") + { + } + + [Theory] + [InlineData(1, "1 millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); + } + + [Theory] + [InlineData(1, "1 sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); + } + + [Theory] + [InlineData(1, "1 minut")] + [InlineData(2, "2 minuter")] + public void Minutes(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); + } + + [Theory] + [InlineData(1, "1 timma")] + [InlineData(2, "2 timmar")] + public void Hours(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); + } + + [Theory] + [InlineData(1, "1 dag")] + [InlineData(2, "2 dagar")] + public void Days(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); + } + + [Theory] + [InlineData(1, "1 vecka")] + [InlineData(2, "2 veckor")] + public void Weeks(int number, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); + } + } +} diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index d9f49bf8b..eeebc22c6 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -164,6 +164,7 @@ + diff --git a/src/Humanizer/Properties/Resources.sv.resx b/src/Humanizer/Properties/Resources.sv.resx new file mode 100644 index 000000000..5a1fa791c --- /dev/null +++ b/src/Humanizer/Properties/Resources.sv.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 + + + en sekund sedan + + + för {0} sekunder sedan + + + en minut sedan + + + för {0} minuter sedan + + + en timme sedan + + + för {0} timmar sedan + + + igår + + + för {0} dagar sedan + + + en månad sedan + + + för {0} månader sedan + + + ett år sedan + + + för {0} år sedan + + + {0} dagar + + + {0} timmar + + + {0} millisekunder + + + {0} minuter + + + {0} sekunder + + + 1 dag + + + 1 timma + + + 1 millisekund + + + 1 minut + + + 1 sekund + + + ingen tid + + + {0} veckor + + + 1 vecka + + + om {0} dagar + + + om {0} timmar + + + om {0} minuter + + + om {0} månader + + + om {0} sekunder + + + om {0} år + + + nu + + + i morgon + + + om en timme + + + om en minut + + + om en månad + + + om en sekund + + + om ett år + + \ No newline at end of file