-
Notifications
You must be signed in to change notification settings - Fork 966
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
Adds Chinese localisation #357
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/Humanizer.Tests/Localisation/zh-CHS/DateHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using Humanizer.Localisation; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.zhCHS | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() : base("zh-CHS") { } | ||
|
||
[Theory] | ||
[InlineData(-2, "2 天前")] | ||
[InlineData(-1, "昨天")] | ||
[InlineData(1, "昨天")] | ||
[InlineData(0, "今天")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 天后")] | ||
[InlineData(-1, "明天")] | ||
[InlineData(1, "明天")] | ||
[InlineData(0, "今天")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 小时前")] | ||
[InlineData(-1, "1 小时前")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 小时后")] | ||
[InlineData(1, "1 小时后")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 分钟前")] | ||
[InlineData(-1, "1 分钟前")] | ||
[InlineData(60, "1 小时前")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 分钟后")] | ||
[InlineData(1, "1 分钟后")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 个月前")] | ||
[InlineData(-1, "1 个月前")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 个月后")] | ||
[InlineData(1, "1 个月后")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 秒钟前")] | ||
[InlineData(-1, "1 秒钟前")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 秒钟后")] | ||
[InlineData(1, "1 秒钟后")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 年前")] | ||
[InlineData(-1, "去年")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 年后")] | ||
[InlineData(1, "明年")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/Humanizer.Tests/Localisation/zh-CHS/TimeSpanHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.zhCHS | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() : base("zh-CHS") { } | ||
|
||
[Theory] | ||
[InlineData(7, "1 周")] | ||
[InlineData(14, "2 周")] | ||
[InlineData(21, "3 周")] | ||
[InlineData(77, "11 周")] | ||
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() | ||
{ | ||
// This one doesn't make a lot of sense but ... w/e | ||
Assert.Equal("没有时间", TimeSpan.Zero.Humanize()); | ||
} | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
src/Humanizer.Tests/Localisation/zh-CHT/DateHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using Humanizer.Localisation; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.zhCHT | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() : base("zh-CHT") { } | ||
|
||
[Theory] | ||
[InlineData(-2, "2 天前")] | ||
[InlineData(-1, "昨天")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same in this class with negative values. |
||
[InlineData(1, "昨天")] | ||
[InlineData(0, "今天")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 天後")] | ||
[InlineData(-1, "明天")] | ||
[InlineData(1, "明天")] | ||
[InlineData(0, "今天")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 小時前")] | ||
[InlineData(-1, "1 小時前")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 小時後")] | ||
[InlineData(1, "1 小時後")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 分鐘前")] | ||
[InlineData(-1, "1 分鐘前")] | ||
[InlineData(60, "1 小時前")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 分鐘後")] | ||
[InlineData(1, "1 分鐘後")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 個月前")] | ||
[InlineData(-1, "1 個月前")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 個月後")] | ||
[InlineData(1, "1 個月後")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 秒鐘前")] | ||
[InlineData(-1, "1 秒鐘前")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 秒鐘後")] | ||
[InlineData(1, "1 秒鐘後")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-2, "2 年前")] | ||
[InlineData(-1, "去年")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 年後")] | ||
[InlineData(1, "明年")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/Humanizer.Tests/Localisation/zh-CHT/TimeSpanHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.zhCHT | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() : base("zh-CHT") { } | ||
|
||
[Theory] | ||
[InlineData(7, "1 周")] | ||
[InlineData(14, "2 周")] | ||
[InlineData(21, "3 周")] | ||
[InlineData(77, "11 周")] | ||
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() | ||
{ | ||
// This one doesn't make a lot of sense but ... w/e | ||
Assert.Equal("沒有時間", TimeSpan.Zero.Humanize()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have values for -1 and 1? In fact there shouldn't be any negative test cases as they're all changed to absolute in
Verify
. Please remove the duplicate 1/-1s and change the negative cases to positive. Thanks