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 2 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
133 changes: 97 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,123 @@ 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(10, "hace 10 segundos")]
[InlineData(59, "hace 59 segundos")]
[InlineData(60, "hace un minuto")]
public void SecondsAgo(int seconds, string expected)
{
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! :)

Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[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, "un segundo desde ahora")]
[InlineData(10, "10 segundos desde ahora")]
[InlineData(59, "59 segundos desde ahora")]
[InlineData(60, "un minuto desde ahora")]
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(10, "hace 10 minutos")]
[InlineData(44, "hace 44 minutos")]
Copy link
Member

Choose a reason for hiding this comment

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

I had to test all edge cases and boundary values in the base DateTimeHumanize tests. You shouldn't need to test these when you test your translation. Please remove the cases that aren't specific to your translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this instance I should be testing only 1 singular and 1 plural?
Therefore [InlineData(44, "hace 44 minutos")] is redundant?

Am I understanding what you are saying correctly?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think you should only need a singular and a plural. Please apply this to all other tests too. Thanks.

[InlineData(45, "hace una hora")]
[InlineData(119, "hace una hora")]
[InlineData(120, "hace 2 horas")]
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, "un minuto desde ahora")]
[InlineData(10, "10 minutos desde ahora")]
[InlineData(44, "44 minutos desde ahora")]
[InlineData(45, "una hora desde ahora")]
[InlineData(119, "una hora desde ahora")]
[InlineData(120, "2 horas desde ahora")]
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(10, "hace 10 horas")]
[InlineData(23, "hace 23 horas")]
[InlineData(24, "ayer")]
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, "una hora desde ahora")]
[InlineData(10, "10 horas desde ahora")]
[InlineData(23, "23 horas desde ahora")]
[InlineData(24, "mañana")]
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(10, "hace 10 días")]
[InlineData(28, "hace 28 días")]
[InlineData(32, "hace un mes")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "mañana")]
[InlineData(10, "10 días desde ahora")]
[InlineData(28, "28 días desde ahora")]
[InlineData(32, "un mes desde ahora")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

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

[Theory]
[InlineData(1, "un mes desde ahora")]
[InlineData(10, "10 meses desde ahora")]
[InlineData(11, "11 meses desde ahora")]
[InlineData(12, "un año desde ahora")]
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, "un año desde ahora")]
[InlineData(2, "2 años desde ahora")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
39 changes: 39 additions & 0 deletions src/Humanizer/Properties/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,43 @@
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>no hay tiempo</value>
</data>
<data name="DateHumanize_MultipleDaysFromNow" xml:space="preserve">
<value>{0} días desde ahora</value>
</data>
<data name="DateHumanize_MultipleHoursFromNow" xml:space="preserve">
<value>{0} horas desde ahora</value>
</data>
<data name="DateHumanize_MultipleMinutesFromNow" xml:space="preserve">
<value>{0} minutos desde ahora</value>
</data>
<data name="DateHumanize_MultipleMonthsFromNow" xml:space="preserve">
<value>{0} meses desde ahora</value>
</data>
<data name="DateHumanize_MultipleSecondsFromNow" xml:space="preserve">
<value>{0} segundos desde ahora</value>
</data>
<data name="DateHumanize_MultipleYearsFromNow" xml:space="preserve">
<value>{0} años desde ahora</value>
</data>
<data name="DateHumanize_SingleDayFromNow" xml:space="preserve">
<value>mañana</value>
</data>
<data name="DateHumanize_SingleHourFromNow" xml:space="preserve">
<value>una hora desde ahora</value>
</data>
<data name="DateHumanize_SingleMinuteFromNow" xml:space="preserve">
<value>un minuto desde ahora</value>
</data>
<data name="DateHumanize_SingleMonthFromNow" xml:space="preserve">
<value>un mes desde ahora</value>
</data>
<data name="DateHumanize_SingleSecondFromNow" xml:space="preserve">
<value>un segundo desde ahora</value>
</data>
<data name="DateHumanize_SingleYearFromNow" xml:space="preserve">
<value>un año desde ahora</value>
</data>
<data name="DateHumanize_Now" xml:space="preserve">
<value>ahora</value>
</data>
</root>