From 96814cfe53bf88f6c2bbd080f1d57f7ac1fcf557 Mon Sep 17 00:00:00 2001 From: brencuks Date: Fri, 13 Jan 2017 11:39:17 +0200 Subject: [PATCH] Added Sweedish collection formatter --- .../Humanizer.Tests.Shared.projitems | 1 + .../sv/CollectionFormatterTests.cs | 33 +++++++++++++++++++ .../CollectionFormatterRegistry.cs | 1 + 3 files changed, 35 insertions(+) create mode 100644 src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs diff --git a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems index 43e1d7cf2..475f9c8b3 100644 --- a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems +++ b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems @@ -127,6 +127,7 @@ + diff --git a/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs b/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs new file mode 100644 index 000000000..f36619a8b --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/sv/CollectionFormatterTests.cs @@ -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(new[] {1, 2, 3}); + var humanized = "1, 2 och 3"; + Assert.Equal(humanized, collection.Humanize()); + } + + [Fact] + public void OneItem() + { + var collection = new List(new[] {1}); + var humanized = "1"; + Assert.Equal(humanized, collection.Humanize()); + } + + [Fact] + public void TwoItems() + { + var collection = new List(new[] {1, 2}); + var humanized = "1 och 2"; + Assert.Equal(humanized, collection.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs index cc038f54e..4bca43f07 100644 --- a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs +++ b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs @@ -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")); } } } \ No newline at end of file