From bf564c1065a9c6b142c35d07095bcc0c8595da2a Mon Sep 17 00:00:00 2001 From: Max Malook Date: Wed, 9 Apr 2014 19:58:35 +0200 Subject: [PATCH 1/4] add russian translation for time spans --- src/Humanizer.Tests/Humanizer.Tests.csproj | 1 + .../ru-RU/TimeSpanHumanizeTests.cs | 127 ++++++++++++++++++ src/Humanizer/Properties/Resources.ru.resx | 75 +++++++++++ 3 files changed, 203 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 8320b7508..2807049f0 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -81,6 +81,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..d167957c5 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs @@ -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()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.ru.resx b/src/Humanizer/Properties/Resources.ru.resx index 43e49b218..76d578141 100644 --- a/src/Humanizer/Properties/Resources.ru.resx +++ b/src/Humanizer/Properties/Resources.ru.resx @@ -189,4 +189,79 @@ {0} год назад + + {0} дней + + + {0} дня + + + {0} день + + + {0} часов + + + {0} часа + + + {0} час + + + {0} миллисекунд + + + {0} миллисекунды + + + {0} миллисекунда + + + {0} минут + + + {0} минуты + + + {0} минута + + + {0} секунд + + + {0} секунды + + + {0} секунда + + + {0} недель + + + {0} недели + + + {0} неделя + + + один день + + + один час + + + одна миллисекунда + + + одна минута + + + одна секунда + + + одна неделя + + + нет времени + \ No newline at end of file From f2517c5f3cb446c1465ca8348ec47c293b6ec0cc Mon Sep 17 00:00:00 2001 From: Max Malook Date: Wed, 9 Apr 2014 20:17:02 +0200 Subject: [PATCH 2/4] add russian translation for now --- src/Humanizer.Tests/DateHumanizeTests.cs | 7 +++++++ .../Localisation/ru-RU/DateHumanizeTests.cs | 7 +++++++ src/Humanizer/Properties/Resources.ru.resx | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/Humanizer.Tests/DateHumanizeTests.cs b/src/Humanizer.Tests/DateHumanizeTests.cs index b5892e2b9..1eb3b3d50 100644 --- a/src/Humanizer.Tests/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/DateHumanizeTests.cs @@ -1,4 +1,5 @@ using Humanizer.Localisation; +using Xunit; using Xunit.Extensions; namespace Humanizer.Tests @@ -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); + } } } diff --git a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs index 4d9d207cc..277a1466d 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs @@ -1,4 +1,5 @@ using Humanizer.Localisation; +using Xunit; using Xunit.Extensions; namespace Humanizer.Tests.Localisation.ruRU @@ -126,5 +127,11 @@ public void YearsAgo(int years, string expected) { DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); } + + [Fact] + public void Now() + { + DateHumanize.Verify("сейчас", 0, TimeUnit.Day, Tense.Past); + } } } diff --git a/src/Humanizer/Properties/Resources.ru.resx b/src/Humanizer/Properties/Resources.ru.resx index 76d578141..c1c626a61 100644 --- a/src/Humanizer/Properties/Resources.ru.resx +++ b/src/Humanizer/Properties/Resources.ru.resx @@ -189,6 +189,9 @@ {0} год назад + + сейчас + {0} дней From 5c6b538d32ce636539009db1f85f0f4262b537b3 Mon Sep 17 00:00:00 2001 From: Max Malook Date: Wed, 9 Apr 2014 20:21:56 +0200 Subject: [PATCH 3/4] add PR to release notes --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index c43e7cf48..a5de574fc 100644 --- a/release_notes.md +++ b/release_notes.md @@ -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) From 8a08b5f16094432e69fbd30c21448fb75988ba67 Mon Sep 17 00:00:00 2001 From: Max Malook Date: Wed, 9 Apr 2014 20:46:08 +0200 Subject: [PATCH 4/4] add russian translation for future dates --- .../Localisation/ru-RU/DateHumanizeTests.cs | 121 +++++++++++++++++- src/Humanizer/Properties/Resources.ru.resx | 72 +++++++++++ 2 files changed, 192 insertions(+), 1 deletion(-) diff --git a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs index 277a1466d..4c13375c9 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs @@ -32,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 минуты назад")] @@ -54,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 часа назад")] @@ -73,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 дня назад")] @@ -94,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 месяца назад")] @@ -107,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 года назад")] @@ -128,6 +226,27 @@ 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() { diff --git a/src/Humanizer/Properties/Resources.ru.resx b/src/Humanizer/Properties/Resources.ru.resx index c1c626a61..d7841691d 100644 --- a/src/Humanizer/Properties/Resources.ru.resx +++ b/src/Humanizer/Properties/Resources.ru.resx @@ -267,4 +267,76 @@ нет времени + + через {0} дней + + + через {0} дня + + + через {0} день + + + через {0} часов + + + через {0} часа + + + через {0} час + + + через {0} минут + + + через {0} минуты + + + через {0} минуту + + + через {0} месяцев + + + через {0} месяца + + + через {0} месяц + + + через {0} секунд + + + через {0} секунды + + + через {0} секунду + + + через {0} лет + + + через {0} года + + + через {0} год + + + завтра + + + через час + + + через минуту + + + через месяц + + + через секунду + + + через год + \ No newline at end of file