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

Japanese Translate #219

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
###In Development
- [#217](https://github.com/Mehdik/Humanizer/pull/217): Changed OrdinalizeExtensions to better accommodate localisations. Added pt-BR and Spanish Ordinalize localisation.
- [#219](https://github.com/Mehdik/Humanizer/pull/219): Added Japanese translation for date and timespan
- [#221](https://github.com/Mehdik/Humanizer/pull/221): Added Russian ordinalizer

[Commits](https://github.com/MehdiK/Humanizer/compare/v1.22.1...master)
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 @@ -98,6 +98,8 @@
<Compile Include="Localisation\id\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\he\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\ja\DateHumanizeTests.cs" />
<Compile Include="Localisation\ja\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nl\NumberToWordsTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
Expand Down
113 changes: 113 additions & 0 deletions src/Humanizer.Tests/Localisation/ja/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

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

[Theory]
[InlineData(1, "1 秒前")]
[InlineData(2, "2 秒前")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "1 秒後")]
[InlineData(2, "2 秒後")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "1 分前")]
[InlineData(2, "2 分前")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "1 分後")]
[InlineData(2, "2 分後")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "1 時間前")]
[InlineData(2, "2 時間前")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "1 時間後")]
[InlineData(2, "2 時間後")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "昨日")]
[InlineData(2, "2 日前")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "明日")]
[InlineData(2, "2 日後")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "先月")]
[InlineData(2, "2 か月前")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "来月")]
[InlineData(2, "2 か月後")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "去年")]
[InlineData(2, "2 年前")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "来年")]
[InlineData(2, "2 年後")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Fact]
public void Now()
{
DateHumanize.Verify("今", 0, TimeUnit.Day, Tense.Past);
}
}
}
65 changes: 65 additions & 0 deletions src/Humanizer.Tests/Localisation/ja/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.ja
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("ja") { }

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

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

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

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

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

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

[Fact]
public void NoTime()
{
Assert.Equal("0 秒", 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 @@ -167,6 +167,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.ja.resx" />
<EmbeddedResource Include="Properties\Resources.bg.resx" />
<EmbeddedResource Include="Properties\Resources.he.resx" />
<EmbeddedResource Include="Properties\Resources.da.resx" />
Expand Down
Loading