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

Danish translation #144

Closed
wants to merge 4 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: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
###In Development

- [#144](https://github.com/MehdiK/Humanizer/pull/144): Danish localization (strings, tests)

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

###v1.18.1 - 2014-04-09
Expand Down
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
<Compile Include="DateHumanize.cs" />
<Compile Include="Localisation\cs\DateHumanizeTests.cs" />
<Compile Include="Localisation\cs\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\da\DateHumanizeTests.cs" />
<Compile Include="Localisation\da\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\TimeSpanHumanizeTests.cs" />
Expand Down
139 changes: 139 additions & 0 deletions src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using Humanizer.Localisation;
using Xunit.Extensions;

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

[Theory]
[InlineData(-10, "10 dage siden")]
[InlineData(-3, "3 dage siden")]
[InlineData(-2, "2 dage siden")]
[InlineData(-1, "i går")]
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 the redundant spaces from here.

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

[Theory]
[InlineData(1, "i morgen")]
[InlineData(10, "10 dage fra nu")]
[InlineData(28, "28 dage fra nu")]
[InlineData(32, "en måned fra nu")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "et sekund fra nu")]
[InlineData(10, "10 sekunder fra nu")]
[InlineData(59, "59 sekunder fra nu")]
[InlineData(60, "et minut fra nu")]
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")]
[InlineData(-2, "2 timer siden")]
[InlineData(-1, "en time siden")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "en time fra nu")]
[InlineData(10, "10 timer fra nu")]
[InlineData(23, "23 timer fra nu")]
[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 minut siden")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "et minut fra nu")]
[InlineData(10, "10 minutter fra nu")]
[InlineData(44, "44 minutter fra nu")]
[InlineData(45, "en time fra nu")]
[InlineData(119, "en time fra nu")]
[InlineData(120, "2 timer fra nu")]
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")]
[InlineData(-2, "2 måneder siden")]
[InlineData(-1, "en måned siden")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "en måned fra nu")]
[InlineData(10, "10 måneder fra nu")]
[InlineData(11, "11 måneder fra nu")]
[InlineData(12, "et år fra nu")]
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")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(-10, "10 år siden")]
[InlineData(-3, "3 år siden")]
[InlineData(-2, "2 år siden")]
[InlineData(-1, "et år siden")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

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

[Theory]
[InlineData(0, "nu")]
public void Now(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
101 changes: 101 additions & 0 deletions src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using Xunit;
using Xunit.Extensions;

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

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

[Theory]
[InlineData(1, "en dag")]
[InlineData(2, "2 dage")]
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, "et minut")]
[InlineData(2, "2 minutter")]
public void Minutes(int minutes, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize());
}

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

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

[Theory]
[InlineData(0, 3, "ingen tid")]
[InlineData(0, 2, "ingen tid")]
[InlineData(10, 2, "10 millisekunder")]
[InlineData(1400, 2, "1 sekund, 400 millisekunder")]
[InlineData(2500, 2, "2 sekunder, 500 millisekunder")]
[InlineData(120000, 2, "2 minutter")]
[InlineData(62000, 2, "1 minute, 2 sekunder")]
[InlineData(62020, 2, "1 minute, 2 sekunder")]
[InlineData(62020, 3, "1 minute, 2 sekunder, 20 millisekunder")]
[InlineData(3600020, 4, "1 time, 20 millisekunder")]
[InlineData(3600020, 3, "1 time, 20 millisekunder")]
[InlineData(3600020, 2, "1 time, 20 millisekunder")]
[InlineData(3600020, 1, "1 time")]
[InlineData(3603001, 2, "1 time, 3 sekunder")]
[InlineData(3603001, 3, "1 time, 3 sekunder, 1 millisekund")]
[InlineData(86400000, 3, "1 dag")]
[InlineData(86400000, 2, "1 dag")]
[InlineData(86400000, 1, "1 dag")]
[InlineData(86401000, 1, "1 dag")]
[InlineData(86401000, 2, "1 dag, 1 sekund")]
[InlineData(86401200, 2, "1 dag, 1 sekund")]
[InlineData(86401200, 3, "1 dag, 1 sekund, 200 millisekunder")]
[InlineData(1296000000, 1, "2 weeks")]
[InlineData(1296000000, 2, "2 weeks, 1 dag")]
[InlineData(1299600000, 2, "2 weeks, 1 dag")]
[InlineData(1299600000, 3, "2 weeks, 1 dag, 1 time")]
[InlineData(1299630020, 3, "2 weeks, 1 dag, 1 time")]
[InlineData(1299630020, 4, "2 weeks, 1 dag, 1 time, 30 sekunder")]
[InlineData(1299630020, 5, "2 weeks, 1 dag, 1 time, 30 sekunder, 20 millisekunder")]
public void TimeSpanWithPrecesion(int milliseconds, int precesion, 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.

This isn't necessary here. In the main implementation I had to make sure that precisions work but once that's proven and you test your translations, the rest is just the implementation stitching the two together. So please remove this. Thanks.

{
var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion);
Assert.Equal(expected, actual);
}

[Fact]
public void NoTime()
{
Assert.Equal("ingen tid", TimeSpan.Zero.Humanize());
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.da.resx" />
<EmbeddedResource Include="Properties\Resources.pl.resx" />
<EmbeddedResource Include="Properties\Resources.cs.resx" />
<EmbeddedResource Include="Properties\Resources.de.resx" />
Expand Down
Loading