Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swedish localization (strings, tests) #135

Merged
merged 4 commits into from
Apr 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
###In Development

- [#135](https://github.com/MehdiK/Humanizer/pull/135): Swedish localization (strings, tests)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It's cool.


[Commits](https://github.com/MehdiK/Humanizer/compare/v1.17.1...master)

###v1.17.1 - 2014-04-06
Expand Down
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
<Compile Include="Localisation\pt-BR\DateHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sk\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sv\DateHumanizeTests.cs" />
<Compile Include="Localisation\sv\TimeSpanHumanizeTests.cs" />
<Compile Include="ResourceKeyTests.cs" />
<Compile Include="RomanNumeralTests.cs" />
<Compile Include="StringExtensionsTests.cs" />
Expand Down
109 changes: 109 additions & 0 deletions src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -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")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got some weird spacing in here!

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")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in here and a few other tests too!

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);
}
}
}
62 changes: 62 additions & 0 deletions src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<EmbeddedResource Include="Properties\Resources.ro.resx" />
<EmbeddedResource Include="Properties\Resources.pt-BR.resx" />
<EmbeddedResource Include="Properties\Resources.sk.resx" />
<EmbeddedResource Include="Properties\Resources.sv.resx" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
Expand Down
Loading