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

Added Swedish collection formatter #612

Merged
merged 1 commit into from
Feb 13, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sr\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sr\NumberToWordsTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sr\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sv\CollectionFormatterTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sv\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\sv\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\tr\DateHumanizeTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using Xunit;

namespace Humanizer.Tests.Localisation.sv
{
[UseCulture("sv-SE")]
public class CollectionFormatterTests
{
[Fact]
public void MoreThanTwoItems()
{
var collection = new List<int>(new[] {1, 2, 3});
var humanized = "1, 2 och 3";
Assert.Equal(humanized, collection.Humanize());
}

[Fact]
public void OneItem()
{
var collection = new List<int>(new[] {1});
var humanized = "1";
Assert.Equal(humanized, collection.Humanize());
}

[Fact]
public void TwoItems()
{
var collection = new List<int>(new[] {1, 2});
var humanized = "1 och 2";
Assert.Equal(humanized, collection.Humanize());
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Configuration/CollectionFormatterRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public CollectionFormatterRegistry()
Register("ro", new DefaultCollectionFormatter("și"));
Register("nn", new DefaultCollectionFormatter("og"));
Register("nb", new DefaultCollectionFormatter("og"));
Register("sv", new DefaultCollectionFormatter("och"));
}
}
}