-
Notifications
You must be signed in to change notification settings - Fork 967
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
Add resource file for Vietnamese language. #269
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dbae0cf
Add resource file for Vietnamese language.
drakomeep f661aec
Remove the unneeded Resources.vi.designer.cs file.
dotnetjunky a8ff024
Add unit tests for VI language
drakomeep add7501
Update release notes file to include Vietnamese language.
drakomeep 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
107 changes: 107 additions & 0 deletions
107
src/Humanizer.Tests/Localisation/vi/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,107 @@ | ||
using Humanizer.Localisation; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.vi | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() : base("vi") { } | ||
|
||
[Theory] | ||
[InlineData(1, "cách đây một giây")] | ||
[InlineData(10, "cách đây 10 giây")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "một giây nữa")] | ||
[InlineData(10, "10 giây nữa")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "cách đây một phút")] | ||
[InlineData(10, "cách đây 10 phút")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "một phút nữa")] | ||
[InlineData(10, "10 phút nữa")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "cách đây một tiếng")] | ||
[InlineData(10, "cách đây 10 tiếng")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "một tiếng nữa")] | ||
[InlineData(10, "10 tiếng nữa")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "hôm qua")] | ||
[InlineData(10, "cách đây 10 ngày")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ngày mai")] | ||
[InlineData(10, "10 ngày nữa")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "cách đây một tháng")] | ||
[InlineData(10, "cách đây 10 tháng")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "một tháng nữa")] | ||
[InlineData(10, "10 tháng nữa")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "cách đây một năm")] | ||
[InlineData(2, "cách đây 2 năm")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "một năm nữa")] | ||
[InlineData(2, "2 năm nữa")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
|
||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
src/Humanizer.Tests/Localisation/vi/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,114 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.vi | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() : base("vi") { } | ||
|
||
[Theory] | ||
[InlineData(14, "2 tuần")] | ||
[InlineData(7, "1 tuần")] | ||
public void Weeks(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(6, "6 ngày")] | ||
[InlineData(2, "2 ngày")] | ||
[InlineData(1, "1 ngày")] | ||
public void Days(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 giờ")] | ||
[InlineData(1, "1 giờ")] | ||
public void Hours(int hours, string expected) | ||
{ | ||
var actual = TimeSpan.FromHours(hours).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 phút")] | ||
[InlineData(1, "1 phút")] | ||
public void Minutes(int minutes, string expected) | ||
{ | ||
var actual = TimeSpan.FromMinutes(minutes).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(135, "2 phút")] | ||
[InlineData(60, "1 phút")] | ||
[InlineData(2, "2 giây")] | ||
[InlineData(1, "1 giây")] | ||
public void Seconds(int seconds, string expected) | ||
{ | ||
var actual = TimeSpan.FromSeconds(seconds).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2500, "2 giây")] | ||
[InlineData(1400, "1 giây")] | ||
[InlineData(2, "2 phần ngàn giây")] | ||
[InlineData(1, "1 phần ngàn giây")] | ||
public void Milliseconds(int ms, string expected) | ||
{ | ||
var actual = TimeSpan.FromMilliseconds(ms).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 3, "không giờ")] | ||
[InlineData(0, 2, "không giờ")] | ||
[InlineData(10, 2, "10 phần ngàn giây")] | ||
[InlineData(1400, 2, "1 giây, 400 phần ngàn giây")] | ||
[InlineData(2500, 2, "2 giây, 500 phần ngàn giây")] | ||
[InlineData(120000, 2, "2 phút")] | ||
[InlineData(62000, 2, "1 phút, 2 giây")] | ||
[InlineData(62020, 2, "1 phút, 2 giây")] | ||
[InlineData(62020, 3, "1 phút, 2 giây, 20 phần ngàn giây")] | ||
[InlineData(3600020, 4, "1 giờ, 20 phần ngàn giây")] | ||
[InlineData(3600020, 3, "1 giờ, 20 phần ngàn giây")] | ||
[InlineData(3600020, 2, "1 giờ, 20 phần ngàn giây")] | ||
[InlineData(3600020, 1, "1 giờ")] | ||
[InlineData(3603001, 2, "1 giờ, 3 giây")] | ||
[InlineData(3603001, 3, "1 giờ, 3 giây, 1 phần ngàn giây")] | ||
[InlineData(86400000, 3, "1 ngày")] | ||
[InlineData(86400000, 2, "1 ngày")] | ||
[InlineData(86400000, 1, "1 ngày")] | ||
[InlineData(86401000, 1, "1 ngày")] | ||
[InlineData(86401000, 2, "1 ngày, 1 giây")] | ||
[InlineData(86401200, 2, "1 ngày, 1 giây")] | ||
[InlineData(86401200, 3, "1 ngày, 1 giây, 200 phần ngàn giây")] | ||
[InlineData(1296000000, 1, "2 tuần")] | ||
[InlineData(1296000000, 2, "2 tuần, 1 ngày")] | ||
[InlineData(1299600000, 2, "2 tuần, 1 ngày")] | ||
[InlineData(1299600000, 3, "2 tuần, 1 ngày, 1 giờ")] | ||
[InlineData(1299630020, 3, "2 tuần, 1 ngày, 1 giờ")] | ||
[InlineData(1299630020, 4, "2 tuần, 1 ngày, 1 giờ, 30 giây")] | ||
[InlineData(1299630020, 5, "2 tuần, 1 ngày, 1 giờ, 30 giây, 20 phần ngàn giây")] | ||
public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) | ||
{ | ||
var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
var noTime = TimeSpan.Zero; | ||
var actual = noTime.Humanize(); | ||
Assert.Equal("không giờ", actual); | ||
} | ||
} | ||
} |
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
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.
This trips everyone up. You don't need to unit test these: if you're using testing every time unit in isolation, the combination is tested under English tests and will work. I will take them out.