-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from igorkulman/master
added Slovak localization (strings, formatter, tests)
- Loading branch information
Showing
7 changed files
with
573 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
92
src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.