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

Update french resources and add unit tests #155

Closed
wants to merge 6 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
3 changes: 2 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
- [#143](https://github.com/MehdiK/Humanizer/pull/143): Added Russian translation for future DateTime, TimeSpan and Now
- [#144](https://github.com/MehdiK/Humanizer/pull/144): Danish localization (strings, tests)
- [#149](https://github.com/MehdiK/Humanizer/pull/149): Number to words localisation improvements

- [#155](https://github.com/MehdiK/Humanizer/pull/155): French and Belgian French localisation

[Commits](https://github.com/MehdiK/Humanizer/compare/v1.18.1...master)

###v1.18.1 - 2014-04-09
Expand Down
4 changes: 3 additions & 1 deletion src/Humanizer.Tests/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace Humanizer.Tests
{
public class DateHumanizeTests
public class DateHumanizeTests : AmbientCulture
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 this

{
public DateHumanizeTests() : base("en-US") { }

[Theory]
[InlineData(1, "one second ago")]
[InlineData(10, "10 seconds ago")]
Expand Down
4 changes: 4 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
<Compile Include="Localisation\cs\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\da\DateHumanizeTests.cs" />
<Compile Include="Localisation\da\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\fr-BE\DateHumanizeTests.cs" />
<Compile Include="Localisation\fr-BE\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\fr\DateHumanizeTests.cs" />
<Compile Include="Localisation\fr\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\TimeSpanHumanizeTests.cs" />
Expand Down
107 changes: 107 additions & 0 deletions src/Humanizer.Tests/Localisation/fr-BE/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using Humanizer.Localisation;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.frBE
{
public class DateHumanizeTests : AmbientCulture
{
public DateHumanizeTests() : base("fr-BE") { }

[Theory]
[InlineData(1, "il y a une seconde")]
[InlineData(10, "il y a 10 secondes")]
Copy link
Member

Choose a reason for hiding this comment

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

These aren't needed. You should only have a test for single and multiple units. If the many tests on the English locale pass and your translations are correct then the framework will the map the two. Please remove the redundant cases.

public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "dans une seconde")]
[InlineData(10, "dans 10 secondes")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "il y a une minute")]
[InlineData(10, "il y a 10 minutes")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "dans une minute")]
[InlineData(10, "dans 10 minutes")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "il y a une heure")]
[InlineData(10, "il y a 10 heures")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "dans une heure")]
[InlineData(10, "dans 10 heures")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "hier")]
[InlineData(10, "il y a 10 jours")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "demain")]
[InlineData(10, "dans 10 jours")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "il y a un mois")]
[InlineData(10, "il y a 10 mois")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "dans un mois")]
[InlineData(10, "dans 10 mois")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "il y a un an")]
[InlineData(2, "il y a 2 ans")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "dans un an")]
[InlineData(2, "dans 2 ans")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

}
}
73 changes: 73 additions & 0 deletions src/Humanizer.Tests/Localisation/fr-BE/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.frBE
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("fr-BE") { }

[Theory]
[InlineData(14, "2 semaines")]
[InlineData(7, "1 semaine")]
public void Weeks(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(6, "6 jours")]
[InlineData(1, "1 jour")]
public void Days(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 heures")]
[InlineData(1, "1 heure")]
public void Hours(int hours, string expected)
{
var actual = TimeSpan.FromHours(hours).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 minutes")]
[InlineData(1, "1 minute")]
public void Minutes(int minutes, string expected)
{
var actual = TimeSpan.FromMinutes(minutes).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 secondes")]
[InlineData(1, "1 seconde")]
public void Seconds(int seconds, string expected)
{
var actual = TimeSpan.FromSeconds(seconds).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 millisecondes")]
[InlineData(1, "1 milliseconde")]
public void Milliseconds(int ms, string expected)
{
var actual = TimeSpan.FromMilliseconds(ms).Humanize();
Assert.Equal(expected, actual);
}

[Fact]
public void NoTime()
{
var noTime = TimeSpan.Zero;
Copy link
Member

Choose a reason for hiding this comment

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

Can you inline this please?

var actual = noTime.Humanize();
Assert.Equal("pas de temps", actual);
}
}
}
107 changes: 107 additions & 0 deletions src/Humanizer.Tests/Localisation/fr/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using Humanizer.Localisation;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.fr
{
public class DateHumanizeTests : AmbientCulture
{
public DateHumanizeTests() : base("fr") { }

[Theory]
[InlineData(1, "il y a une seconde")]
[InlineData(10, "il y a 10 secondes")]
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, please remove the unnecessary cases.

public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "dans une seconde")]
[InlineData(10, "dans 10 secondes")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "il y a une minute")]
[InlineData(10, "il y a 10 minutes")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "dans une minute")]
[InlineData(10, "dans 10 minutes")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "il y a une heure")]
[InlineData(10, "il y a 10 heures")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "dans une heure")]
[InlineData(10, "dans 10 heures")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "hier")]
[InlineData(10, "il y a 10 jours")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "demain")]
[InlineData(10, "dans 10 jours")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "il y a un mois")]
[InlineData(10, "il y a 10 mois")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "dans un mois")]
[InlineData(10, "dans 10 mois")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "il y a un an")]
[InlineData(2, "il y a 2 ans")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "dans un an")]
[InlineData(2, "dans 2 ans")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

}
}
73 changes: 73 additions & 0 deletions src/Humanizer.Tests/Localisation/fr/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.fr
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("fr") { }

[Theory]
[InlineData(14, "2 semaines")]
[InlineData(7, "1 semaine")]
public void Weeks(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(6, "6 jours")]
[InlineData(1, "1 jour")]
public void Days(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 heures")]
[InlineData(1, "1 heure")]
public void Hours(int hours, string expected)
{
var actual = TimeSpan.FromHours(hours).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 minutes")]
[InlineData(1, "1 minute")]
public void Minutes(int minutes, string expected)
{
var actual = TimeSpan.FromMinutes(minutes).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 secondes")]
[InlineData(1, "1 seconde")]
public void Seconds(int seconds, string expected)
{
var actual = TimeSpan.FromSeconds(seconds).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 millisecondes")]
[InlineData(1, "1 milliseconde")]
public void Milliseconds(int ms, string expected)
{
var actual = TimeSpan.FromMilliseconds(ms).Humanize();
Assert.Equal(expected, actual);
}

[Fact]
public void NoTime()
{
var noTime = TimeSpan.Zero;
var actual = noTime.Humanize();
Assert.Equal("pas de temps", actual);
}
}
}
Loading