Skip to content

Commit

Permalink
Merge branch 'polish'
Browse files Browse the repository at this point in the history
  • Loading branch information
MehdiK committed Apr 9, 2014
2 parents 6335f47 + 0c2008f commit ae71948
Show file tree
Hide file tree
Showing 8 changed files with 557 additions and 6 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
###In Development
- [#137](https://github.com/MehdiK/Humanizer/pull/137): Fixed grammar error in `nb-NO` resource file & added missing Norwegian resource strings (mainly `DateHumanize_*FromNow`)
- [#135](https://github.com/MehdiK/Humanizer/pull/135): Added Swedish localization (strings, tests)
- [#140](https://github.com/MehdiK/Humanizer/pull/140): Added Polish localization (strings, formatter, tests)

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

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 @@ -79,6 +79,8 @@
<Compile Include="Localisation\cs\DateHumanizeTests.cs" />
<Compile Include="Localisation\cs\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sk\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\NumberToWordsTests.cs" />
Expand Down
168 changes: 168 additions & 0 deletions src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
using Humanizer.Localisation;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.pl
{
public class DateHumanizeTests : AmbientCulture
{
public DateHumanizeTests()
: base("pl")
{
}

[Theory]
[InlineData(1, "za sekundę")]
[InlineData(2, "za 2 sekundy")]
[InlineData(3, "za 3 sekundy")]
[InlineData(4, "za 4 sekundy")]
[InlineData(5, "za 5 sekund")]
[InlineData(6, "za 6 sekund")]
[InlineData(10, "za 10 sekund")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "za minutę")]
[InlineData(2, "za 2 minuty")]
[InlineData(3, "za 3 minuty")]
[InlineData(4, "za 4 minuty")]
[InlineData(5, "za 5 minut")]
[InlineData(6, "za 6 minut")]
[InlineData(10, "za 10 minut")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "za godzinę")]
[InlineData(2, "za 2 godziny")]
[InlineData(3, "za 3 godziny")]
[InlineData(4, "za 4 godziny")]
[InlineData(5, "za 5 godzin")]
[InlineData(6, "za 6 godzin")]
[InlineData(10, "za 10 godzin")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "jutro")]
[InlineData(2, "za 2 dni")]
[InlineData(3, "za 3 dni")]
[InlineData(4, "za 4 dni")]
[InlineData(5, "za 5 dni")]
[InlineData(6, "za 6 dni")]
[InlineData(10, "za 10 dni")]
public void DayFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "za miesiąc")]
[InlineData(2, "za 2 miesiące")]
[InlineData(3, "za 3 miesiące")]
[InlineData(4, "za 4 miesiące")]
[InlineData(5, "za 5 miesięcy")]
[InlineData(6, "za 6 miesięcy")]
[InlineData(10, "za 10 miesięcy")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "za rok")]
[InlineData(2, "za 2 lata")]
[InlineData(3, "za 3 lata")]
[InlineData(4, "za 4 lata")]
[InlineData(5, "za 5 lat")]
[InlineData(6, "za 6 lat")]
[InlineData(10, "za 10 lat")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Theory]
[InlineData(1, "przed sekundą")]
[InlineData(2, "przed 2 sekundami")]
[InlineData(3, "przed 3 sekundami")]
[InlineData(4, "przed 4 sekundami")]
[InlineData(5, "przed 5 sekundami")]
[InlineData(6, "przed 6 sekundami")]
[InlineData(10, "przed 10 sekundami")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "przed minutą")]
[InlineData(2, "przed 2 minutami")]
[InlineData(3, "przed 3 minutami")]
[InlineData(4, "przed 4 minutami")]
[InlineData(5, "przed 5 minutami")]
[InlineData(6, "przed 6 minutami")]
[InlineData(10, "przed 10 minutami")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "przed godziną")]
[InlineData(2, "przed 2 godzinami")]
[InlineData(3, "przed 3 godzinami")]
[InlineData(4, "przed 4 godzinami")]
[InlineData(5, "przed 5 godzinami")]
[InlineData(6, "przed 6 godzinami")]
[InlineData(10, "przed 10 godzinami")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "wczoraj")]
[InlineData(2, "przed 2 dniami")]
[InlineData(3, "przed 3 dniami")]
[InlineData(4, "przed 4 dniami")]
[InlineData(9, "przed 9 dniami")]
[InlineData(10, "przed 10 dniami")]
public void DayAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "przed miesiącem")]
[InlineData(2, "przed 2 miesiącami")]
[InlineData(3, "przed 3 miesiącami")]
[InlineData(4, "przed 4 miesiącami")]
[InlineData(5, "przed 5 miesiącami")]
[InlineData(6, "przed 6 miesiącami")]
[InlineData(10, "przed 10 miesiącami")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "przed rokiem")]
[InlineData(2, "przed 2 laty")]
[InlineData(3, "przed 3 laty")]
[InlineData(4, "przed 4 laty")]
[InlineData(5, "przed 5 laty")]
[InlineData(6, "przed 6 laty")]
[InlineData(10, "przed 10 laty")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
90 changes: 90 additions & 0 deletions src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using Xunit;
using Xunit.Extensions;

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

[Theory]
[InlineData(1, "1 milisekunda")]
[InlineData(2, "2 milisekundy")]
[InlineData(3, "3 milisekundy")]
[InlineData(4, "4 milisekundy")]
[InlineData(5, "5 milisekund")]
[InlineData(6, "6 milisekund")]
[InlineData(10, "10 milisekund")]
public void Milliseconds(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 sekund")]
[InlineData(6, "6 sekund")]
[InlineData(10, "10 sekund")]
public void Seconds(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize());
}

[Theory]
[InlineData(1, "1 minuta")]
[InlineData(2, "2 minuty")]
[InlineData(3, "3 minuty")]
[InlineData(4, "4 minuty")]
[InlineData(5, "5 minut")]
[InlineData(6, "6 minut")]
[InlineData(10, "10 minut")]
public void Minutes(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize());
}

[Theory]
[InlineData(1, "1 godzina")]
[InlineData(2, "2 godziny")]
[InlineData(3, "3 godziny")]
[InlineData(4, "4 godziny")]
[InlineData(5, "5 godzin")]
[InlineData(6, "6 godzin")]
[InlineData(10, "10 godzin")]
public void Hours(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromHours(number).Humanize());
}

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

[Theory]
[InlineData(1, "1 tydzień")]
[InlineData(2, "2 tygodnie")]
[InlineData(3, "3 tygodnie")]
[InlineData(4, "4 tygodnie")]
[InlineData(5, "5 tygodni")]
[InlineData(6, "6 tygodni")]
public void Weeks(int number, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(number*7).Humanize());
}
}
}
9 changes: 5 additions & 4 deletions src/Humanizer/Configuration/Configurator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Humanizer.Localisation;
using System;
using System.Collections.Generic;
using System.Globalization;
using Humanizer.Localisation;

namespace Humanizer.Configuration
{
Expand All @@ -10,14 +10,15 @@ namespace Humanizer.Configuration
/// </summary>
public static class Configurator
{
private static readonly IDictionary<string, Func<IFormatter>> FormatterFactories =
private static readonly IDictionary<string, Func<IFormatter>> FormatterFactories =
new Dictionary<string, Func<IFormatter>>(StringComparer.OrdinalIgnoreCase)
{
{ "ro", () => new RomanianFormatter() },
{ "ru", () => new RussianFormatter() },
{ "ar", () => new ArabicFormatter() },
{ "sk", () => new CzechSlovakFormatter() },
{ "cs", () => new CzechSlovakFormatter() }
{ "sk", () => new CzechSlovakPolishFormatter() },
{ "cs", () => new CzechSlovakPolishFormatter() },
{ "pl", () => new CzechSlovakPolishFormatter() }
};

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<Compile Include="CasingExtensions.cs" />
<Compile Include="Configuration\Configurator.cs" />
<Compile Include="DateHumanizeExtensions.cs" />
<Compile Include="Localisation\CzechSlovakFormatter.cs" />
<Compile Include="Localisation\CzechSlovakPolishFormatter.cs" />
<Compile Include="Localisation\Tense.cs" />
<Compile Include="TimeSpanHumanizeExtensions.cs" />
<Compile Include="FluentDate\In.SomeTimeFrom.cs">
Expand Down Expand Up @@ -145,6 +145,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.pl.resx" />
<EmbeddedResource Include="Properties\Resources.cs.resx" />
<EmbeddedResource Include="Properties\Resources.de.resx" />
<EmbeddedResource Include="Properties\Resources.fa.resx" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Humanizer.Localisation
{
internal class CzechSlovakFormatter : DefaultFormatter
internal class CzechSlovakPolishFormatter : DefaultFormatter
{
private const string PaucalPostfix = "_Paucal";

Expand Down
Loading

0 comments on commit ae71948

Please sign in to comment.