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
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,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);
}
}
}
95 changes: 95 additions & 0 deletions src/Humanizer.Tests/Localisation/ja/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using Xunit;

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

[Fact]
public void TwoWeeks()
Copy link
Member

Choose a reason for hiding this comment

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

Please change these to use Theory instead.

Copy link
Member

Choose a reason for hiding this comment

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

Can see an example here

{
Assert.Equal("2 週間", TimeSpan.FromDays(14).Humanize());
}

[Fact]
public void OneWeek()
{
Assert.Equal("1 週間", TimeSpan.FromDays(7).Humanize());
}

[Fact]
public void SixDays()
{
Assert.Equal("6 日間", TimeSpan.FromDays(6).Humanize());
}

[Fact]
public void TwoDays()
{
Assert.Equal("2 日間", TimeSpan.FromDays(2).Humanize());
}

[Fact]
public void OneDay()
{
Assert.Equal("1 日間", TimeSpan.FromDays(1).Humanize());
}

[Fact]
public void TwoHours()
{
Assert.Equal("2 時間", TimeSpan.FromHours(2).Humanize());
}

[Fact]
public void OneHour()
{
Assert.Equal("1 時間", TimeSpan.FromHours(1).Humanize());
}

[Fact]
public void TwoMinutes()
{
Assert.Equal("2 分間", TimeSpan.FromMinutes(2).Humanize());
}

[Fact]
public void OneMinute()
{
Assert.Equal("1 分間", TimeSpan.FromMinutes(1).Humanize());
}

[Fact]
public void TwoSeconds()
{
Assert.Equal("2 秒間", TimeSpan.FromSeconds(2).Humanize());
}

[Fact]
public void OneSecond()
{
Assert.Equal("1 秒間", TimeSpan.FromSeconds(1).Humanize());
}

[Fact]
public void TwoMilliseconds()
{
Assert.Equal("2 ミリ秒間", TimeSpan.FromMilliseconds(2).Humanize());
}

[Fact]
public void OneMillisecond()
{
Assert.Equal("1 ミリ秒間", TimeSpan.FromMilliseconds(1).Humanize());
}

[Fact]
public void NoTime()
{
// This one doesn't make a lot of sense but ... w/e
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what this says but please change it to say "0 seconds" if it makes sense: see #161

Please remove the comment too.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MehdiK it says "no time" per Google Translate also, I like many others, found NoTime to be a bit confusing.

@yhata based on a previous issue #161 we determined that 0 seconds is a better representation of no time in many languages. If it doesn't make sense to say 0 seconds (0秒間 ?) in Japanese, then another word or phrase would suffice.

Assert.Equal("時間なし", 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 @@ -162,6 +162,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