-
Notifications
You must be signed in to change notification settings - Fork 967
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 #51 from juan-hawa/better_es_lang_support
Added missing spanish translations and tests
- Loading branch information
Showing
4 changed files
with
216 additions
and
3 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
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.es | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() : base("es-ES") { } | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 días")] | ||
[InlineData(-3, "hace 3 días")] | ||
[InlineData(-2, "hace 2 días")] | ||
[InlineData(-1, "ayer")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 horas")] | ||
[InlineData(-3, "hace 3 horas")] | ||
[InlineData(-2, "hace 2 horas")] | ||
[InlineData(-1, "hace una hora")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 minutos")] | ||
[InlineData(-3, "hace 3 minutos")] | ||
[InlineData(-2, "hace 2 minutos")] | ||
[InlineData(-1, "hace un minuto")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 meses")] | ||
[InlineData(-3, "hace 3 meses")] | ||
[InlineData(-2, "hace 2 meses")] | ||
[InlineData(-1, "hace un mes")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 segundos")] | ||
[InlineData(-3, "hace 3 segundos")] | ||
[InlineData(-2, "hace 2 segundos")] | ||
[InlineData(-1, "hace un segundo")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 años")] | ||
[InlineData(-3, "hace 3 años")] | ||
[InlineData(-2, "hace 2 años")] | ||
[InlineData(-1, "hace un año")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NotYet() | ||
{ | ||
Assert.Equal("aún no", 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.es | ||
{ | ||
public class TimeSpanHumanizeExtensionsTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeExtensionsTests() : base("es-ES") { } | ||
|
||
[Fact] | ||
public void TwoWeeks() | ||
{ | ||
Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneWeek() | ||
{ | ||
Assert.Equal("una semana", TimeSpan.FromDays(7).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void SixDays() | ||
{ | ||
Assert.Equal("6 días", TimeSpan.FromDays(6).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoDays() | ||
{ | ||
Assert.Equal("2 días", TimeSpan.FromDays(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneDay() | ||
{ | ||
Assert.Equal("un día", TimeSpan.FromDays(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoHours() | ||
{ | ||
Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneHour() | ||
{ | ||
Assert.Equal("una hora", TimeSpan.FromHours(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoMinutes() | ||
{ | ||
Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneMinute() | ||
{ | ||
Assert.Equal("un minuto", TimeSpan.FromMinutes(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoSeconds() | ||
{ | ||
Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneSecond() | ||
{ | ||
Assert.Equal("un segundo", TimeSpan.FromSeconds(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void TwoMilliseconds() | ||
{ | ||
Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void OneMillisecond() | ||
{ | ||
Assert.Equal("un milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
// This one doesn't make a lot of sense but ... w/e | ||
Assert.Equal("no hay tiempo", 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