Skip to content
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 future dates to Resources.pt-BR.resx. #261

Merged
merged 4 commits into from
May 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 76 additions & 21 deletions src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

Expand All @@ -9,23 +10,21 @@ public class DateHumanizeTests : AmbientCulture
public DateHumanizeTests() : base("pt-BR") { }

[Theory]
[InlineData(-10, "10 dias atrás")]
[InlineData(-3, "3 dias atrás")]
[InlineData(-2, "2 dias atrás")]
[InlineData(-1, "ontem")]
public void DaysAgo(int days, string expected)
[InlineData(-10, "10 segundos atrás")]
[InlineData(-3, "3 segundos atrás")]
[InlineData(-2, "2 segundos atrás")]
[InlineData(-1, "um segundo atrás")]
public void SecondsAgo(int seconds, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(-10, "10 horas atrás")]
[InlineData(-3, "3 horas atrás")]
[InlineData(-2, "2 horas atrás")]
[InlineData(-1, "uma hora atrás")]
public void HoursAgo(int hours, string expected)
[InlineData(1, "em um segundo")]
[InlineData(2, "em 2 segundos")]
public void SecondsFromNow(int seconds, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize());
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
Expand All @@ -35,7 +34,51 @@ public void HoursAgo(int hours, string expected)
[InlineData(-1, "um minuto atrás")]
public void MinutesAgo(int minutes, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize());
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "em um minuto")]
[InlineData(2, "em 2 minutos")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(-10, "10 horas atrás")]
[InlineData(-3, "3 horas atrás")]
[InlineData(-2, "2 horas atrás")]
[InlineData(-1, "uma hora atrás")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "em uma hora")]
[InlineData(2, "em 2 horas")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(-10, "10 dias atrás")]
[InlineData(-3, "3 dias atrás")]
[InlineData(-2, "2 dias atrás")]
[InlineData(-1, "ontem")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "amanhã")]
[InlineData(2, "em 2 dias")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
Expand All @@ -45,17 +88,15 @@ public void MinutesAgo(int minutes, string expected)
[InlineData(-1, "um mês atrás")]
public void MonthsAgo(int months, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize());
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(-10, "10 segundos atrás")]
[InlineData(-3, "3 segundos atrás")]
[InlineData(-2, "2 segundos atrás")]
[InlineData(-1, "um segundo atrás")]
public void SecondsAgo(int seconds, string expected)
[InlineData(1, "em um mês")]
[InlineData(2, "em 2 meses")]
public void MonthsFromNow(int months, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize());
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
Expand All @@ -65,7 +106,21 @@ public void SecondsAgo(int seconds, string expected)
[InlineData(-1, "um ano atrás")]
public void YearsAgo(int years, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize());
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "em um ano")]
[InlineData(2, "em 2 anos")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Fact]
public void Now()
{
DateHumanize.Verify("agora", 0, TimeUnit.Day, Tense.Future);
}
}
}
5 changes: 2 additions & 3 deletions src/Humanizer/Configuration/Configurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public static LocaliserRegistry<IOrdinalizer> Ordinalizers
{
get { return _ordinalizers; }
}

private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy();


/// <summary>
/// The formatter to be used
/// </summary>
Expand Down Expand Up @@ -72,6 +70,7 @@ internal static IOrdinalizer Ordinalizer
}
}

private static IDateTimeHumanizeStrategy _dateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy();
/// <summary>
/// The strategy to be used for DateTime.Humanize
/// </summary>
Expand Down
39 changes: 39 additions & 0 deletions src/Humanizer/Properties/Resources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,39 +120,75 @@
<data name="DateHumanize_SingleSecondAgo" xml:space="preserve">
<value>um segundo atrás</value>
</data>
<data name="DateHumanize_SingleSecondFromNow" xml:space="preserve">
<value>em um segundo</value>
</data>
<data name="DateHumanize_MultipleSecondsAgo" xml:space="preserve">
<value>{0} segundos atrás</value>
</data>
<data name="DateHumanize_MultipleSecondsFromNow" xml:space="preserve">
<value>em {0} segundos</value>
</data>
<data name="DateHumanize_SingleMinuteAgo" xml:space="preserve">
<value>um minuto atrás</value>
</data>
<data name="DateHumanize_SingleMinuteFromNow" xml:space="preserve">
<value>em um minuto</value>
</data>
<data name="DateHumanize_MultipleMinutesAgo" xml:space="preserve">
<value>{0} minutos atrás</value>
</data>
<data name="DateHumanize_MultipleMinutesFromNow" xml:space="preserve">
<value>em {0} minutos</value>
</data>
<data name="DateHumanize_SingleHourAgo" xml:space="preserve">
<value>uma hora atrás</value>
</data>
<data name="DateHumanize_SingleHourFromNow" xml:space="preserve">
<value>em uma hora</value>
</data>
<data name="DateHumanize_MultipleHoursAgo" xml:space="preserve">
<value>{0} horas atrás</value>
</data>
<data name="DateHumanize_MultipleHoursFromNow" xml:space="preserve">
<value>em {0} horas</value>
</data>
<data name="DateHumanize_SingleDayAgo" xml:space="preserve">
<value>ontem</value>
</data>
<data name="DateHumanize_SingleDayFromNow" xml:space="preserve">
<value>amanhã</value>
</data>
<data name="DateHumanize_MultipleDaysAgo" xml:space="preserve">
<value>{0} dias atrás</value>
</data>
<data name="DateHumanize_MultipleDaysFromNow" xml:space="preserve">
<value>em {0} dias</value>
</data>
<data name="DateHumanize_SingleMonthAgo" xml:space="preserve">
<value>um mês atrás</value>
</data>
<data name="DateHumanize_SingleMonthFromNow" xml:space="preserve">
<value>em um mês</value>
</data>
<data name="DateHumanize_MultipleMonthsFromNow" xml:space="preserve">
<value>em {0} meses</value>
</data>
<data name="DateHumanize_MultipleMonthsAgo" xml:space="preserve">
<value>{0} meses atrás</value>
</data>
<data name="DateHumanize_SingleYearAgo" xml:space="preserve">
<value>um ano atrás</value>
</data>
<data name="DateHumanize_SingleYearFromNow" xml:space="preserve">
<value>em um ano</value>
</data>
<data name="DateHumanize_MultipleYearsAgo" xml:space="preserve">
<value>{0} anos atrás</value>
</data>
<data name="DateHumanize_MultipleYearsFromNow" xml:space="preserve">
<value>em {0} anos</value>
</data>
<data name="TimeSpanHumanize_MultipleDays" xml:space="preserve">
<value>{0} dias</value>
</data>
Expand Down Expand Up @@ -192,4 +228,7 @@
<data name="TimeSpanHumanize_SingleWeek" xml:space="preserve">
<value>1 semana</value>
</data>
<data name="DateHumanize_Now" xml:space="preserve">
<value>agora</value>
</data>
</root>