Skip to content

Commit

Permalink
Merge branch 'norwegian'
Browse files Browse the repository at this point in the history
  • Loading branch information
MehdiK committed Apr 9, 2014
2 parents 2119bc2 + fb2d3d7 commit 6335f47
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 11 deletions.
4 changes: 2 additions & 2 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###In Development

- [#135](https://github.com/MehdiK/Humanizer/pull/135): Swedish localization (strings, tests)
- [#137](https://github.com/MehdiK/Humanizer/pull/137): Fixed grammar error in `nb-NO` resource file & added missing Norwegian resource strings (mainly `DateHumanize_*FromNow`)
- [#135](https://github.com/MehdiK/Humanizer/pull/135): Added Swedish localization (strings, tests)

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

Expand Down
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
72 changes: 69 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,26 @@ 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å")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[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 +50,37 @@ 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 +91,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 +115,25 @@ 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
{
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>

0 comments on commit 6335f47

Please sign in to comment.