-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from ammachado/pt_BR_support
PT-BR Language support
- Loading branch information
Showing
8 changed files
with
380 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.ptBR | ||
{ | ||
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) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize()); | ||
} | ||
|
||
[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) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "10 minutos atrás")] | ||
[InlineData(-3, "3 minutos atrás")] | ||
[InlineData(-2, "2 minutos atrás")] | ||
[InlineData(-1, "um minuto atrás")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "10 meses atrás")] | ||
[InlineData(-3, "3 meses atrás")] | ||
[InlineData(-2, "2 meses atrás")] | ||
[InlineData(-1, "um mês atrás")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize()); | ||
} | ||
|
||
[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) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "10 anos atrás")] | ||
[InlineData(-3, "3 anos atrás")] | ||
[InlineData(-2, "2 anos atrás")] | ||
[InlineData(-1, "um ano atrás")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NotYet() | ||
{ | ||
Assert.Equal("ainda não", DateTime.UtcNow.AddDays(1).Humanize()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Humanizer.Tests.Localisation.ptBR | ||
{ | ||
public class TimeSpanHumanizeExtensionsTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeExtensionsTests() : base("pt-BR") { } | ||
|
||
[Fact] | ||
public void TwoWeeks() | ||
{ | ||
Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneWeek() | ||
{ | ||
Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void SixDays() | ||
{ | ||
Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoDays() | ||
{ | ||
Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneDay() | ||
{ | ||
Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoHours() | ||
{ | ||
Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneHour() | ||
{ | ||
Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoMinutes() | ||
{ | ||
Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneMinute() | ||
{ | ||
Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoSeconds() | ||
{ | ||
Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneSecond() | ||
{ | ||
Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoMilliseconds() | ||
{ | ||
Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneMillisecond() | ||
{ | ||
Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
// This one doesn't make a lot of sense but ... w/e | ||
Assert.Equal("sem horário", TimeSpan.Zero.Humanize()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.