Skip to content

Commit

Permalink
Merge pull request #143 from mexx/ru-timespan
Browse files Browse the repository at this point in the history
add russian translation for time spans
  • Loading branch information
MehdiK committed Apr 9, 2014
2 parents f6ff2d9 + 8a08b5f commit 2480330
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 1 deletion.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
###In Development
- [#143](https://github.com/MehdiK/Humanizer/pull/143): Added Russian translation for future DateTime, TimeSpan and Now

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

Expand Down
7 changes: 7 additions & 0 deletions src/Humanizer.Tests/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests
Expand Down Expand Up @@ -124,5 +125,11 @@ public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Fact]
public void Now()
{
DateHumanize.Verify("now", 0, TimeUnit.Year, Tense.Future);
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\ru-RU\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sk\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\NumberToWordsTests.cs" />
Expand Down
128 changes: 127 additions & 1 deletion src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.ruRU
Expand Down Expand Up @@ -31,6 +32,28 @@ public void SecondsAgo(int seconds, string expected)
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "через секунду")]
[InlineData(2, "через 2 секунды")]
[InlineData(3, "через 3 секунды")]
[InlineData(4, "через 4 секунды")]
[InlineData(5, "через 5 секунд")]
[InlineData(6, "через 6 секунд")]
[InlineData(10, "через 10 секунд")]
[InlineData(11, "через 11 секунд")]
[InlineData(19, "через 19 секунд")]
[InlineData(20, "через 20 секунд")]
[InlineData(21, "через 21 секунду")]
[InlineData(22, "через 22 секунды")]
[InlineData(23, "через 23 секунды")]
[InlineData(24, "через 24 секунды")]
[InlineData(25, "через 25 секунд")]
[InlineData(40, "через 40 секунд")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "минуту назад")]
[InlineData(2, "2 минуты назад")]
Expand All @@ -53,6 +76,28 @@ public void MinutesAgo(int minutes, string expected)
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "через минуту")]
[InlineData(2, "через 2 минуты")]
[InlineData(3, "через 3 минуты")]
[InlineData(4, "через 4 минуты")]
[InlineData(5, "через 5 минут")]
[InlineData(6, "через 6 минут")]
[InlineData(10, "через 10 минут")]
[InlineData(11, "через 11 минут")]
[InlineData(19, "через 19 минут")]
[InlineData(20, "через 20 минут")]
[InlineData(21, "через 21 минуту")]
[InlineData(22, "через 22 минуты")]
[InlineData(23, "через 23 минуты")]
[InlineData(24, "через 24 минуты")]
[InlineData(25, "через 25 минут")]
[InlineData(40, "через 40 минут")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "час назад")]
[InlineData(2, "2 часа назад")]
Expand All @@ -72,6 +117,25 @@ public void HoursAgo(int hours, string expected)
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "через час")]
[InlineData(2, "через 2 часа")]
[InlineData(3, "через 3 часа")]
[InlineData(4, "через 4 часа")]
[InlineData(5, "через 5 часов")]
[InlineData(6, "через 6 часов")]
[InlineData(10, "через 10 часов")]
[InlineData(11, "через 11 часов")]
[InlineData(19, "через 19 часов")]
[InlineData(20, "через 20 часов")]
[InlineData(21, "через 21 час")]
[InlineData(22, "через 22 часа")]
[InlineData(23, "через 23 часа")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "вчера")]
[InlineData(2, "2 дня назад")]
Expand All @@ -93,6 +157,27 @@ public void DaysAgo(int days, string expected)
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "завтра")]
[InlineData(2, "через 2 дня")]
[InlineData(3, "через 3 дня")]
[InlineData(4, "через 4 дня")]
[InlineData(5, "через 5 дней")]
[InlineData(6, "через 6 дней")]
[InlineData(10, "через 10 дней")]
[InlineData(11, "через 11 дней")]
[InlineData(19, "через 19 дней")]
[InlineData(20, "через 20 дней")]
[InlineData(21, "через 21 день")]
[InlineData(22, "через 22 дня")]
[InlineData(23, "через 23 дня")]
[InlineData(24, "через 24 дня")]
[InlineData(25, "через 25 дней")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "месяц назад")]
[InlineData(2, "2 месяца назад")]
Expand All @@ -106,7 +191,21 @@ public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}


[Theory]
[InlineData(1, "через месяц")]
[InlineData(2, "через 2 месяца")]
[InlineData(3, "через 3 месяца")]
[InlineData(4, "через 4 месяца")]
[InlineData(5, "через 5 месяцев")]
[InlineData(6, "через 6 месяцев")]
[InlineData(10, "через 10 месяцев")]
[InlineData(11, "через 11 месяцев")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "год назад")]
[InlineData(2, "2 года назад")]
Expand All @@ -126,5 +225,32 @@ public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "через год")]
[InlineData(2, "через 2 года")]
[InlineData(3, "через 3 года")]
[InlineData(4, "через 4 года")]
[InlineData(5, "через 5 лет")]
[InlineData(6, "через 6 лет")]
[InlineData(10, "через 10 лет")]
[InlineData(11, "через 11 лет")]
[InlineData(19, "через 19 лет")]
[InlineData(20, "через 20 лет")]
[InlineData(21, "через 21 год")]
[InlineData(111, "через 111 лет")]
[InlineData(121, "через 121 год")]
[InlineData(222, "через 222 года")]
[InlineData(325, "через 325 лет")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Fact]
public void Now()
{
DateHumanize.Verify("сейчас", 0, TimeUnit.Day, Tense.Past);
}
}
}
127 changes: 127 additions & 0 deletions src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.ruRU
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("ru-RU") { }

[Theory]
[InlineData(7, "одна неделя")]
[InlineData(14, "2 недели")]
[InlineData(21, "3 недели")]
[InlineData(28, "4 недели")]
[InlineData(35, "5 недель")]
[InlineData(77, "11 недель")]
public void Weeks(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[InlineData(1, "один день")]
[InlineData(2, "2 дня")]
[InlineData(3, "3 дня")]
[InlineData(4, "4 дня")]
[InlineData(5, "5 дней")]
[InlineData(6, "6 дней")]
public void Days(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[InlineData(1, "один час")]
[InlineData(2, "2 часа")]
[InlineData(3, "3 часа")]
[InlineData(4, "4 часа")]
[InlineData(5, "5 часов")]
[InlineData(6, "6 часов")]
[InlineData(10, "10 часов")]
[InlineData(11, "11 часов")]
[InlineData(19, "19 часов")]
[InlineData(20, "20 часов")]
[InlineData(21, "21 час")]
[InlineData(22, "22 часа")]
[InlineData(23, "23 часа")]
public void Hours(int hours, string expected)
{
Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize());
}

[Theory]
[InlineData(1, "одна минута")]
[InlineData(2, "2 минуты")]
[InlineData(3, "3 минуты")]
[InlineData(4, "4 минуты")]
[InlineData(5, "5 минут")]
[InlineData(6, "6 минут")]
[InlineData(10, "10 минут")]
[InlineData(11, "11 минут")]
[InlineData(19, "19 минут")]
[InlineData(20, "20 минут")]
[InlineData(21, "21 минута")]
[InlineData(22, "22 минуты")]
[InlineData(23, "23 минуты")]
[InlineData(24, "24 минуты")]
[InlineData(25, "25 минут")]
[InlineData(40, "40 минут")]
public void Minutes(int minutes, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize());
}

[Theory]
[InlineData(1, "одна секунда")]
[InlineData(2, "2 секунды")]
[InlineData(3, "3 секунды")]
[InlineData(4, "4 секунды")]
[InlineData(5, "5 секунд")]
[InlineData(6, "6 секунд")]
[InlineData(10, "10 секунд")]
[InlineData(11, "11 секунд")]
[InlineData(19, "19 секунд")]
[InlineData(20, "20 секунд")]
[InlineData(21, "21 секунда")]
[InlineData(22, "22 секунды")]
[InlineData(23, "23 секунды")]
[InlineData(24, "24 секунды")]
[InlineData(25, "25 секунд")]
[InlineData(40, "40 секунд")]
public void Seconds(int seconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize());
}

[Theory]
[InlineData(1, "одна миллисекунда")]
[InlineData(2, "2 миллисекунды")]
[InlineData(3, "3 миллисекунды")]
[InlineData(4, "4 миллисекунды")]
[InlineData(5, "5 миллисекунд")]
[InlineData(6, "6 миллисекунд")]
[InlineData(10, "10 миллисекунд")]
[InlineData(11, "11 миллисекунд")]
[InlineData(19, "19 миллисекунд")]
[InlineData(20, "20 миллисекунд")]
[InlineData(21, "21 миллисекунда")]
[InlineData(22, "22 миллисекунды")]
[InlineData(23, "23 миллисекунды")]
[InlineData(24, "24 миллисекунды")]
[InlineData(25, "25 миллисекунд")]
[InlineData(40, "40 миллисекунд")]
public void Milliseconds(int milliseconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize());
}

[Fact]
public void NoTime()
{
// This one doesn't make a lot of sense but ... w/e
Assert.Equal("нет времени", TimeSpan.Zero.Humanize());
}
}
}
Loading

0 comments on commit 2480330

Please sign in to comment.