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 missing spanish translations and tests #51

Merged
merged 1 commit into from Jan 5, 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
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
<ItemGroup>
<Compile Include="CasingTests.cs" />
<Compile Include="Localisation\DateHumanizeTests.nb-NO.cs" />
<Compile Include="Localisation\es\DateHumanizeTests.cs" />
<Compile Include="Localisation\es\TimeSpanTests.cs" />
<Compile Include="RunnableInDebugModeOnlyAttribute.cs" />
<Compile Include="ToQuantityTests.cs" />
<Compile Include="TransformersTests.cs" />
Expand Down
77 changes: 77 additions & 0 deletions src/Humanizer.Tests/Localisation/es/DateHumanizeTests.cs
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());
}
}
}
95 changes: 95 additions & 0 deletions src/Humanizer.Tests/Localisation/es/TimeSpanTests.cs
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());
}
}
}
45 changes: 42 additions & 3 deletions src/Humanizer/Properties/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DateHumanize_NotYet" xml:space="preserve">
<value>todavía no</value>
<value>aún no</value>
</data>
<data name="DateHumanize_SingleSecondAgo" xml:space="preserve">
<value>hace un segundo</value>
Expand All @@ -145,7 +145,7 @@
<value>hace {0} días</value>
</data>
<data name="DateHumanize_SingleMonthAgo" xml:space="preserve">
<value>hace una mes</value>
<value>hace un mes</value>
</data>
<data name="DateHumanize_MultipleMonthsAgo" xml:space="preserve">
<value>hace {0} meses</value>
Expand All @@ -156,4 +156,43 @@
<data name="DateHumanize_MultipleYearsAgo" xml:space="preserve">
<value>hace {0} años</value>
</data>
</root>
<data name="TimeSpanHumanize_MultipleDays" xml:space="preserve">
<value>{0} días</value>
</data>
<data name="TimeSpanHumanize_MultipleHours" xml:space="preserve">
<value>{0} horas</value>
</data>
<data name="TimeSpanHumanize_MultipleMilliseconds" xml:space="preserve">
<value>{0} milisegundos</value>
</data>
<data name="TimeSpanHumanize_MultipleMinutes" xml:space="preserve">
<value>{0} minutos</value>
</data>
<data name="TimeSpanHumanize_MultipleSeconds" xml:space="preserve">
<value>{0} segundos</value>
</data>
<data name="TimeSpanHumanize_MultipleWeeks" xml:space="preserve">
<value>{0} semanas</value>
</data>
<data name="TimeSpanHumanize_SingleDay" xml:space="preserve">
<value>un día</value>
</data>
<data name="TimeSpanHumanize_SingleHour" xml:space="preserve">
<value>una hora</value>
</data>
<data name="TimeSpanHumanize_SingleMillisecond" xml:space="preserve">
<value>un milisegundo</value>
</data>
<data name="TimeSpanHumanize_SingleMinute" xml:space="preserve">
<value>un minuto</value>
</data>
<data name="TimeSpanHumanize_SingleSecond" xml:space="preserve">
<value>un segundo</value>
</data>
<data name="TimeSpanHumanize_SingleWeek" xml:space="preserve">
<value>una semana</value>
</data>
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>no hay tiempo</value>
</data>
</root>