-
Notifications
You must be signed in to change notification settings - Fork 967
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 Czech localization (strings, formatter, tests) #130
Changes from 4 commits
13a4ec9
1111fa1
973cea0
0f1e5e7
cd20304
52f8d31
d81d7dd
b96d2f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.cs | ||
{ | ||
public class DateTimeHumanizeTests : AmbientCulture | ||
{ | ||
public DateTimeHumanizeTests() | ||
: base("cs-CZ") | ||
{ | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "za sekundu")] | ||
[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 number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "za minutu")] | ||
[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 number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "za hodinu")] | ||
[InlineData(2, "za 2 hodiny")] | ||
[InlineData(3, "za 3 hodiny")] | ||
[InlineData(4, "za 4 hodiny")] | ||
[InlineData(5, "za 5 hodin")] | ||
[InlineData(6, "za 6 hodin")] | ||
[InlineData(10, "za 10 hodin")] | ||
public void HoursFromNow(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddHours(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "zítra")] | ||
[InlineData(2, "za 2 dny")] | ||
[InlineData(3, "za 3 dny")] | ||
[InlineData(4, "za 4 dny")] | ||
[InlineData(9, "za 9 dnů")] | ||
[InlineData(10, "za 10 dnů")] | ||
public void DayFromNow(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddDays(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "za měsíc")] | ||
[InlineData(2, "za 2 měsíce")] | ||
[InlineData(3, "za 3 měsíce")] | ||
[InlineData(4, "za 4 měsíce")] | ||
[InlineData(5, "za 5 měsíců")] | ||
[InlineData(6, "za 6 měsíců")] | ||
[InlineData(10, "za 10 měsíců")] | ||
public void MonthsFromNow(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMonths(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "za rok")] | ||
[InlineData(2, "za 2 roky")] | ||
[InlineData(3, "za 3 roky")] | ||
[InlineData(4, "za 4 roky")] | ||
[InlineData(5, "za 5 let")] | ||
[InlineData(6, "za 6 let")] | ||
[InlineData(10, "za 10 let")] | ||
public void YearsFromNow(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddYears(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "před sekundou")] | ||
[InlineData(2, "před 2 sekundami")] | ||
[InlineData(3, "před 3 sekundami")] | ||
[InlineData(4, "před 4 sekundami")] | ||
[InlineData(5, "před 5 sekundami")] | ||
[InlineData(6, "před 6 sekundami")] | ||
[InlineData(10, "před 10 sekundami")] | ||
public void SecondsAgo(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(-1 * number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "před minutou")] | ||
[InlineData(2, "před 2 minutami")] | ||
[InlineData(3, "před 3 minutami")] | ||
[InlineData(4, "před 4 minutami")] | ||
[InlineData(5, "před 5 minutami")] | ||
[InlineData(6, "před 6 minutami")] | ||
[InlineData(10, "před 10 minutami")] | ||
public void MinutesAgo(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(-1 * number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "před hodinou")] | ||
[InlineData(2, "před 2 hodinami")] | ||
[InlineData(3, "před 3 hodinami")] | ||
[InlineData(4, "před 4 hodinami")] | ||
[InlineData(5, "před 5 hodinami")] | ||
[InlineData(6, "před 6 hodinami")] | ||
[InlineData(10, "před 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, "před 2 dny")] | ||
[InlineData(3, "před 3 dny")] | ||
[InlineData(4, "před 4 dny")] | ||
[InlineData(9, "před 9 dny")] | ||
[InlineData(10, "před 10 dny")] | ||
public void DayAgo(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddDays(-1 * number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "před měsícem")] | ||
[InlineData(2, "před 2 měsíci")] | ||
[InlineData(3, "před 3 měsíci")] | ||
[InlineData(4, "před 4 měsíci")] | ||
[InlineData(5, "před 5 měsíci")] | ||
[InlineData(6, "před 6 měsíci")] | ||
[InlineData(10, "před 10 měsíci")] | ||
public void MonthsAgo(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMonths(-1 * number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "před rokem")] | ||
[InlineData(2, "před 2 lety")] | ||
[InlineData(3, "před 3 lety")] | ||
[InlineData(4, "před 4 lety")] | ||
[InlineData(5, "před 5 lety")] | ||
[InlineData(6, "před 6 lety")] | ||
[InlineData(10, "před 10 lety")] | ||
public void YearsAgo(int number, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddYears(-1 * number).Humanize()); | ||
} | ||
} | ||
} |
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.cs | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() | ||
: base("cs-CZ") | ||
{ | ||
} | ||
|
||
[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 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 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 hodina")] | ||
[InlineData(2, "2 hodiny")] | ||
[InlineData(3, "3 hodiny")] | ||
[InlineData(4, "4 hodiny")] | ||
[InlineData(5, "5 hodin")] | ||
[InlineData(6, "6 hodin")] | ||
[InlineData(10, "10 hodin")] | ||
public void Hours(int number, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 den")] | ||
[InlineData(2, "2 dny")] | ||
[InlineData(3, "3 dny")] | ||
[InlineData(4, "4 dny")] | ||
[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ýden")] | ||
[InlineData(2, "2 týdny")] | ||
[InlineData(3, "3 týdny")] | ||
[InlineData(4, "4 týdny")] | ||
[InlineData(5, "5 týdnů")] | ||
[InlineData(6, "6 týdnů")] | ||
public void Weeks(int number, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the redundant spaces. |
||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ | |
<Compile Include="CasingExtensions.cs" /> | ||
<Compile Include="Configuration\Configurator.cs" /> | ||
<Compile Include="DateHumanizeExtensions.cs" /> | ||
<Compile Include="Localisation\CzechFormatter.cs" /> | ||
<Compile Include="Localisation\SlovakFormatter.cs" /> | ||
<Compile Include="Localisation\TimeUnitTense.cs" /> | ||
<Compile Include="TimeSpanHumanizeExtensions.cs" /> | ||
|
@@ -150,6 +151,7 @@ | |
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Properties\Resources.cs.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.de.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.nb-NO.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.af.resx" /> | ||
|
@@ -158,17 +160,13 @@ | |
<EmbeddedResource Include="Properties\Resources.es.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.el.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.ru.resx" /> | ||
<EmbeddedResource Include="Properties\Resources.ar.resx"> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.ar.resx" /> | ||
<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> | ||
<EmbeddedResource Include="Properties\Resources.sk.resx" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for removing these |
||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Humanizer.Localisation | ||
{ | ||
internal class CzechFormatter : DefaultFormatter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as SlovakyFormatter. Should we merge the two (say |
||
{ | ||
private const string PaucalPostfix = "_Paucal"; | ||
|
||
protected override string GetResourceKey(string resourceKey, int number) | ||
{ | ||
if (number > 1 && number < 5) | ||
return resourceKey + PaucalPostfix; | ||
|
||
return resourceKey; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is misspelled. Should be
Milliseconds
. Oh, the same is on your previous PR.