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

Fixed error in nb-NO resource file, added resource strings and added tests #137

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="DateHumanize.cs" />
<Compile Include="Localisation\cs\DateHumanizeTests.cs" />
<Compile Include="Localisation\cs\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\sk\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\NumberToWordsTests.cs" />
Expand Down
76 changes: 73 additions & 3 deletions src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ public void DaysAgo(int days, string expected)
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "i morgen")]
[InlineData(10, "10 dager fra nå")]
[InlineData(28, "28 dager fra nå")]
[InlineData(32, "en måned fra nå")]
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 adding the tests in. I am also a fan of boundary tests like you've done with 32. Good work.

public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

Copy link
Member

Choose a reason for hiding this comment

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

Please remove redundant empty lines :)


[Theory]
[InlineData(1, "ett sekund fra nå")]
[InlineData(10, "10 sekunder fra nå")]
[InlineData(59, "59 sekunder fra nå")]
[InlineData(60, "ett minutt fra nå")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}


[Theory]
[InlineData(-10, "10 timer siden")]
[InlineData(-3, "3 timer siden")]
Expand All @@ -30,16 +52,38 @@ public void HoursAgo(int hours, string expected)
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}


[Theory]
[InlineData(1, "en time fra nå")]
[InlineData(10, "10 timer fra nå")]
[InlineData(23, "23 timer fra nå")]
[InlineData(24, "i morgen")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(-10, "10 minutter siden")]
[InlineData(-3, "3 minutter siden")]
[InlineData(-2, "2 minutter siden")]
[InlineData(-1, "et minutt siden")]
[InlineData(-1, "ett minutt siden")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "ett minutt fra nå")]
[InlineData(10, "10 minutter fra nå")]
[InlineData(44, "44 minutter fra nå")]
[InlineData(45, "en time fra nå")]
[InlineData(119, "en time fra nå")]
[InlineData(120, "2 timer fra nå")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}
[Theory]
[InlineData(-10, "10 måneder siden")]
[InlineData(-3, "3 måneder siden")]
Expand All @@ -50,11 +94,21 @@ public void MonthsAgo(int months, string expected)
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "en måned fra nå")]
[InlineData(10, "10 måneder fra nå")]
[InlineData(11, "11 måneder fra nå")]
[InlineData(12, "ett år fra nå")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(-10, "10 sekunder siden")]
[InlineData(-3, "3 sekunder siden")]
[InlineData(-2, "2 sekunder siden")]
[InlineData(-1, "et sekund siden")]
[InlineData(-1, "ett sekund siden")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
Expand All @@ -64,10 +118,26 @@ public void SecondsAgo(int seconds, string expected)
[InlineData(-10, "10 år siden")]
[InlineData(-3, "3 år siden")]
[InlineData(-2, "2 år siden")]
[InlineData(-1, "et år siden")]
[InlineData(-1, "ett år siden")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "ett år fra nå")]
[InlineData(2, "2 år fra nå")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Theory]
[InlineData(0, "nå")]
public void Now(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

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

namespace Humanizer.Tests.Localisation.nbNO
{
public class TimeSpanHumanizeTests : 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 translating the TimeSpan resources and for the tests. TimeSpan was added much later to the lib and so it's missing translation for a lot of languages.

{
public TimeSpanHumanizeTests() : base("nb-NO") { }

[Theory]
[InlineData(7, "en uke")]
[InlineData(14, "2 uker")]
public void Weeks(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[InlineData(1, "en dag")]
[InlineData(2, "2 dager")]
public void Days(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[InlineData(1, "en time")]
[InlineData(2, "2 timer")]
public void Hours(int hours, string expected)
{
Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize());
}

[Theory]
[InlineData(1, "ett minutt")]
[InlineData(2, "2 minutter")]
public void Minutes(int minutes, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize());
}

[Theory]
[InlineData(1, "ett sekund")]
[InlineData(2, "2 sekunder")]
public void Seconds(int seconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize());
}

[Theory]
[InlineData(1, "ett millisekund")]
[InlineData(2, "2 millisekunder")]
public void Milliseconds(int milliseconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize());
}

[Fact]
public void NoTime()
{
Assert.Equal("ingen tid", TimeSpan.Zero.Humanize());
}
}
}
51 changes: 45 additions & 6 deletions src/Humanizer/Properties/Resources.nb-NO.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DateHumanize_SingleSecondAgo" xml:space="preserve">
<value>et sekund siden</value>
<value>ett sekund siden</value>
</data>
<data name="DateHumanize_MultipleSecondsAgo" xml:space="preserve">
<value>{0} sekunder siden</value>
</data>
<data name="DateHumanize_SingleMinuteAgo" xml:space="preserve">
<value>et minutt siden</value>
<value>ett minutt siden</value>
</data>
<data name="DateHumanize_MultipleMinutesAgo" xml:space="preserve">
<value>{0} minutter siden</value>
Expand All @@ -148,7 +148,7 @@
<value>{0} måneder siden</value>
</data>
<data name="DateHumanize_SingleYearAgo" xml:space="preserve">
<value>et år siden</value>
<value>ett år siden</value>
</data>
<data name="DateHumanize_MultipleYearsAgo" xml:space="preserve">
<value>{0} år siden</value>
Expand All @@ -175,13 +175,13 @@
<value>en time</value>
</data>
<data name="TimeSpanHumanize_SingleMillisecond" xml:space="preserve">
<value>et millisekund</value>
<value>ett millisekund</value>
</data>
<data name="TimeSpanHumanize_SingleMinute" xml:space="preserve">
<value>et minutt</value>
<value>ett minutt</value>
</data>
<data name="TimeSpanHumanize_SingleSecond" xml:space="preserve">
<value>et sekund</value>
<value>ett sekund</value>
</data>
<data name="TimeSpanHumanize_Zero" xml:space="preserve">
<value>ingen tid</value>
Expand All @@ -192,4 +192,43 @@
<data name="TimeSpanHumanize_SingleWeek" xml:space="preserve">
<value>en uke</value>
</data>
<data name="DateHumanize_MultipleDaysFromNow" xml:space="preserve">
<value>{0} dager fra nå</value>
</data>
<data name="DateHumanize_MultipleHoursFromNow" xml:space="preserve">
<value>{0} timer fra nå</value>
</data>
<data name="DateHumanize_MultipleMinutesFromNow" xml:space="preserve">
<value>{0} minutter fra nå</value>
</data>
<data name="DateHumanize_MultipleMonthsFromNow" xml:space="preserve">
<value>{0} måneder fra nå</value>
</data>
<data name="DateHumanize_MultipleSecondsFromNow" xml:space="preserve">
<value>{0} sekunder fra nå</value>
</data>
<data name="DateHumanize_MultipleYearsFromNow" xml:space="preserve">
<value>{0} år fra nå</value>
</data>
<data name="DateHumanize_Now" xml:space="preserve">
<value>nå</value>
</data>
<data name="DateHumanize_SingleDayFromNow" xml:space="preserve">
<value>i morgen</value>
</data>
<data name="DateHumanize_SingleHourFromNow" xml:space="preserve">
<value>en time fra nå</value>
</data>
<data name="DateHumanize_SingleMinuteFromNow" xml:space="preserve">
<value>ett minutt fra nå</value>
</data>
<data name="DateHumanize_SingleMonthFromNow" xml:space="preserve">
<value>en måned fra nå</value>
</data>
<data name="DateHumanize_SingleSecondFromNow" xml:space="preserve">
<value>ett sekund fra nå</value>
</data>
<data name="DateHumanize_SingleYearFromNow" xml:space="preserve">
<value>ett år fra nå</value>
</data>
</root>