Skip to content

Commit

Permalink
Merge pull request #124 from igorkulman/master
Browse files Browse the repository at this point in the history
added Slovak localization (strings, formatter, tests)
  • Loading branch information
MehdiK committed Apr 4, 2014
2 parents e217c00 + 9d88eb2 commit bd16448
Show file tree
Hide file tree
Showing 7 changed files with 573 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Bytes\ParsingTests.cs" />
<Compile Include="Bytes\ToStringTests.cs" />
<Compile Include="CasingTests.cs" />
<Compile Include="Localisation\sk\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\NumberToWordsTests.cs" />
<Compile Include="Localisation\ar\TimeSpanHumanizeTests.cs" />
Expand All @@ -90,6 +91,7 @@
<Compile Include="Localisation\nl\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\DateHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sk\TimeSpanHumanizeTests.cs" />
<Compile Include="ResourceKeyTests.cs" />
<Compile Include="RomanNumeralTests.cs" />
<Compile Include="StringExtensionsTests.cs" />
Expand Down
168 changes: 168 additions & 0 deletions src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.sk
{
public class DateTimeHumanizeTests : AmbientCulture
{
public DateTimeHumanizeTests()
: base("sk-SK")
{
}

[Theory]
[InlineData(1, "o sekundu")]
[InlineData(2, "o 2 sekundy")]
[InlineData(3, "o 3 sekundy")]
[InlineData(4, "o 4 sekundy")]
[InlineData(5, "o 5 sekúnd")]
[InlineData(6, "o 6 sekúnd")]
[InlineData(10, "o 10 sekúnd")]
public void SecondsFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(number).Humanize());
}

[Theory]
[InlineData(1, "o minútu")]
[InlineData(2, "o 2 minúty")]
[InlineData(3, "o 3 minúty")]
[InlineData(4, "o 4 minúty")]
[InlineData(5, "o 5 minút")]
[InlineData(6, "o 6 minút")]
[InlineData(10, "o 10 minút")]
public void MinutesFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(number).Humanize());
}

[Theory]
[InlineData(1, "o hodinu")]
[InlineData(2, "o 2 hodiny")]
[InlineData(3, "o 3 hodiny")]
[InlineData(4, "o 4 hodiny")]
[InlineData(5, "o 5 hodín")]
[InlineData(6, "o 6 hodín")]
[InlineData(10, "o 10 hodín")]
public void HoursFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddHours(number).Humanize());
}

[Theory]
[InlineData(1, "zajtra")]
[InlineData(2, "o 2 dni")]
[InlineData(3, "o 3 dni")]
[InlineData(4, "o 4 dni")]
[InlineData(9, "o 9 dní")]
[InlineData(10, "o 10 dní")]
public void DayFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddDays(number).Humanize());
}

[Theory]
[InlineData(1, "o mesiac")]
[InlineData(2, "o 2 mesiace")]
[InlineData(3, "o 3 mesiace")]
[InlineData(4, "o 4 mesiace")]
[InlineData(5, "o 5 mesiacov")]
[InlineData(6, "o 6 mesiacov")]
[InlineData(10, "o 10 mesiacov")]
public void MonthsFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMonths(number).Humanize());
}

[Theory]
[InlineData(1, "o rok")]
[InlineData(2, "o 2 roky")]
[InlineData(3, "o 3 roky")]
[InlineData(4, "o 4 roky")]
[InlineData(5, "o 5 rokov")]
[InlineData(6, "o 6 rokov")]
[InlineData(10, "o 10 rokov")]
public void YearsFromNow(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddYears(number).Humanize());
}

[Theory]
[InlineData(1, "pred sekundou")]
[InlineData(2, "pred 2 sekundami")]
[InlineData(3, "pred 3 sekundami")]
[InlineData(4, "pred 4 sekundami")]
[InlineData(5, "pred 5 sekundami")]
[InlineData(6, "pred 6 sekundami")]
[InlineData(10, "pred 10 sekundami")]
public void SecondsAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(-1*number).Humanize());
}

[Theory]
[InlineData(1, "pred minútou")]
[InlineData(2, "pred 2 minútami")]
[InlineData(3, "pred 3 minútami")]
[InlineData(4, "pred 4 minútami")]
[InlineData(5, "pred 5 minútami")]
[InlineData(6, "pred 6 minútami")]
[InlineData(10, "pred 10 minútami")]
public void MinutesAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(-1*number).Humanize());
}

[Theory]
[InlineData(1, "pred hodinou")]
[InlineData(2, "pred 2 hodinami")]
[InlineData(3, "pred 3 hodinami")]
[InlineData(4, "pred 4 hodinami")]
[InlineData(5, "pred 5 hodinami")]
[InlineData(6, "pred 6 hodinami")]
[InlineData(10, "pred 10 hodinami")]
public void HoursAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddHours(-1*number).Humanize());
}

[Theory]
[InlineData(1, "včera")]
[InlineData(2, "pred 2 dňami")]
[InlineData(3, "pred 3 dňami")]
[InlineData(4, "pred 4 dňami")]
[InlineData(9, "pred 9 dňami")]
[InlineData(10, "pred 10 dňami")]
public void DayAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddDays(-1*number).Humanize());
}

[Theory]
[InlineData(1, "pred mesiacom")]
[InlineData(2, "pred 2 mesiacmi")]
[InlineData(3, "pred 3 mesiacmi")]
[InlineData(4, "pred 4 mesiacmi")]
[InlineData(5, "pred 5 mesiacmi")]
[InlineData(6, "pred 6 mesiacmi")]
[InlineData(10, "pred 10 mesiacmi")]
public void MonthsAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMonths(-1*number).Humanize());
}

[Theory]
[InlineData(1, "pred rokom")]
[InlineData(2, "pred 2 rokmi")]
[InlineData(3, "pred 3 rokmi")]
[InlineData(4, "pred 4 rokmi")]
[InlineData(5, "pred 5 rokmi")]
[InlineData(6, "pred 6 rokmi")]
[InlineData(10, "pred 10 rokmi")]
public void YearsAgo(int number, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddYears(-1*number).Humanize());
}
}
}
92 changes: 92 additions & 0 deletions src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.sk
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests()
: base("sk-SK")
{
}

[Theory]
[InlineData(1, "1 milisekunda")]
[InlineData(2, "2 milisekundy")]
[InlineData(3, "3 milisekundy")]
[InlineData(4, "4 milisekundy")]
[InlineData(5, "5 milisekúnd")]
[InlineData(6, "6 milisekúnd")]
[InlineData(10, "10 milisekúnd")]
public void Miliseconds(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize());
}

[Theory]
[InlineData(1, "1 sekunda")]
[InlineData(2, "2 sekundy")]
[InlineData(3, "3 sekundy")]
[InlineData(4, "4 sekundy")]
[InlineData(5, "5 sekúnd")]
[InlineData(6, "6 sekúnd")]
[InlineData(10, "10 sekúnd")]
public void Seconds(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize());
}

[Theory]
[InlineData(1, "1 minúta")]
[InlineData(2, "2 minúty")]
[InlineData(3, "3 minúty")]
[InlineData(4, "4 minúty")]
[InlineData(5, "5 minút")]
[InlineData(6, "6 minút")]
[InlineData(10, "10 minút")]
public void Minutes(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize());
}

[Theory]
[InlineData(1, "1 hodina")]
[InlineData(2, "2 hodiny")]
[InlineData(3, "3 hodiny")]
[InlineData(4, "4 hodiny")]
[InlineData(5, "5 hodín")]
[InlineData(6, "6 hodín")]
[InlineData(10, "10 hodín")]
public void Hours(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromHours(number).Humanize());
}

[Theory]
[InlineData(1, "1 deň")]
[InlineData(2, "2 dni")]
[InlineData(3, "3 dni")]
[InlineData(4, "4 dni")]
[InlineData(5, "5 dní")]
[InlineData(6, "6 dní")]
public void Days(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(number).Humanize());
}

[Theory]
[InlineData(1, "1 týždeň")]
[InlineData(2, "2 týždne")]
[InlineData(3, "3 týždne")]
[InlineData(4, "4 týždne")]
[InlineData(5, "5 týždňov")]
[InlineData(6, "6 týždňov")]
public void Weeks(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize());
}


}
}
1 change: 1 addition & 0 deletions src/Humanizer/Configuration/Configurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class Configurator
{ "ro", () => new RomanianFormatter() },
{ "ru", () => new RussianFormatter() },
{ "ar", () => new ArabicFormatter() },
{ "sk", () => new SlovakFormatter() }
};

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="CasingExtensions.cs" />
<Compile Include="Configuration\Configurator.cs" />
<Compile Include="DateHumanizeExtensions.cs" />
<Compile Include="Localisation\SlovakFormatter.cs" />
<Compile Include="Localisation\TimeUnitTense.cs" />
<Compile Include="TimeSpanHumanizeExtensions.cs" />
<Compile Include="FluentDate\In.SomeTimeFrom.cs">
Expand Down Expand Up @@ -153,12 +154,17 @@
<EmbeddedResource Include="Properties\Resources.es.resx" />
<EmbeddedResource Include="Properties\Resources.el.resx" />
<EmbeddedResource Include="Properties\Resources.ru.resx" />
<EmbeddedResource Include="Properties\Resources.ar.resx" />
<EmbeddedResource Include="Properties\Resources.ar.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.fr.resx" />
<EmbeddedResource Include="Properties\Resources.nl.resx" />
<EmbeddedResource Include="Properties\Resources.resx" />
<EmbeddedResource Include="Properties\Resources.ro.resx" />
<EmbeddedResource Include="Properties\Resources.pt-BR.resx" />
<EmbeddedResource Include="Properties\Resources.sk.resx">
<LastGenOutput>Resources.sk.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
Expand Down
15 changes: 15 additions & 0 deletions src/Humanizer/Localisation/SlovakFormatter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Humanizer.Localisation
{
internal class SlovakFormatter : DefaultFormatter
{
private const string PaucalPostfix = "_Paucal";

protected override string GetResourceKey(string resourceKey, int number)
{
if (number > 1 && number < 5)
return resourceKey + PaucalPostfix;

return resourceKey;
}
}
}
Loading

0 comments on commit bd16448

Please sign in to comment.