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 Spanish FromNow strings #146

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###In Development

- [#146](https://github.com/MehdiK/Humanizer/pull/146): Added Spanish translation for future DateTime, TimeSpan and Now
[Commits](https://github.com/MehdiK/Humanizer/compare/v1.18.1...master)

###v1.18.1 - 2014-04-09
Expand Down
109 changes: 73 additions & 36 deletions src/Humanizer.Tests/Localisation/es/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,63 +10,99 @@ 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)
[InlineData(1, "hace un segundo")]
[InlineData(2, "hace 2 segundos")]
public void SecondsAgo(int seconds, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for replacing these! :)


[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)
[InlineData(1, "en un segundo")]
[InlineData(2, "en 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]
[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)
[InlineData(1, "hace un minuto")]
[InlineData(2, "hace 2 minutos")]
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(-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)
[InlineData(1, "en un minuto")]
[InlineData(2, "en 2 minutos")]
public void MinutesFromNow(int minutes, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize());
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[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)
[InlineData(1, "hace una hora")]
[InlineData(2, "hace 2 horas")]
public void HoursAgo(int hours, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize());
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[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)
[InlineData(1, "en una hora")]
[InlineData(2, "en 2 horas")]
public void HoursFromNow(int hours, string expected)
{
Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize());
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "ayer")]
[InlineData(2, "hace 2 días")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "mañana")]
[InlineData(2, "en 2 días")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "hace un mes")]
[InlineData(2, "hace 2 meses")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "en un mes")]
[InlineData(2, "en 2 meses")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "hace un año")]
[InlineData(2, "hace 2 años")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "en un año")]
[InlineData(2, "en 2 años")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
4 changes: 2 additions & 2 deletions src/Humanizer.Tests/Localisation/es/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Humanizer.Tests.Localisation.es
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("es-ES") { }
public TimeSpanHumanizeTests() : base("es-ES") { }

[Fact]
public void TwoWeeks()
Expand Down Expand Up @@ -89,7 +89,7 @@ public void OneMillisecond()
public void NoTime()
{
// This one doesn't make a lot of sense but ... w/e
Assert.Equal("no hay tiempo", TimeSpan.Zero.Humanize());
Assert.Equal("0 segundos", TimeSpan.Zero.Humanize());
}
}
}
41 changes: 40 additions & 1 deletion src/Humanizer/Properties/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,45 @@
<value>una semana</value>
</data>
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>no hay tiempo</value>
<value>0 segundos</value>
</data>
<data name="DateHumanize_MultipleDaysFromNow" xml:space="preserve">
<value>en {0} días</value>
</data>
<data name="DateHumanize_MultipleHoursFromNow" xml:space="preserve">
<value>en {0} horas</value>
</data>
<data name="DateHumanize_MultipleMinutesFromNow" xml:space="preserve">
<value>en {0} minutos</value>
</data>
<data name="DateHumanize_MultipleMonthsFromNow" xml:space="preserve">
<value>en {0} meses</value>
</data>
<data name="DateHumanize_MultipleSecondsFromNow" xml:space="preserve">
<value>en {0} segundos</value>
</data>
<data name="DateHumanize_MultipleYearsFromNow" xml:space="preserve">
<value>en {0} años</value>
</data>
<data name="DateHumanize_SingleDayFromNow" xml:space="preserve">
<value>mañana</value>
</data>
<data name="DateHumanize_SingleHourFromNow" xml:space="preserve">
<value>en una hora</value>
</data>
<data name="DateHumanize_SingleMinuteFromNow" xml:space="preserve">
<value>en un minuto</value>
</data>
<data name="DateHumanize_SingleMonthFromNow" xml:space="preserve">
<value>en un mes</value>
</data>
<data name="DateHumanize_SingleSecondFromNow" xml:space="preserve">
<value>en un segundo</value>
</data>
<data name="DateHumanize_SingleYearFromNow" xml:space="preserve">
<value>en un año</value>
</data>
<data name="DateHumanize_Now" xml:space="preserve">
<value>ahora</value>
</data>
</root>