-
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
Initial Indonesia localization #141
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dee8128
Initial Indonesia localization
soeleman e8b510c
Fix Miss InlineData
soeleman 787af22
Fix Test MonthsFromNow and YearsFromNow
soeleman 63024fb
Update release_notes.md for pull 141
soeleman f3349e4
Merge conflict release_notes.md.
soeleman 5b377b8
Adding relevan test on Localization
soeleman 5be7113
Fix conflict on Humanizer.csproj
soeleman 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
123 changes: 123 additions & 0 deletions
123
src/Humanizer.Tests/Localisation/id/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,123 @@ | ||
using Humanizer.Localisation; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.id | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() : base("id-ID") { } | ||
|
||
[Theory] | ||
[InlineData(-1, "sedetik yang lalu")] | ||
[InlineData(120, "2 menit yang lalu")] | ||
[InlineData(90, "semenit yang lalu")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "sedetik dari sekarang")] | ||
[InlineData(60, "semenit dari sekarang")] | ||
[InlineData(120, "2 menit dari sekarang")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "semenit yang lalu")] | ||
[InlineData(15, "15 menit yang lalu")] | ||
[InlineData(45, "sejam yang lalu")] | ||
[InlineData(150, "2 jam yang lalu")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "semenit dari sekarang")] | ||
[InlineData(15, "15 menit dari sekarang")] | ||
[InlineData(45, "sejam dari sekarang")] | ||
[InlineData(150, "2 jam dari sekarang")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "sejam yang lalu")] | ||
[InlineData(10, "10 jam yang lalu")] | ||
[InlineData(24, "kemarin")] | ||
[InlineData(48, "2 hari yang lalu")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "sejam dari sekarang")] | ||
[InlineData(10, "10 jam dari sekarang")] | ||
[InlineData(24, "besok")] | ||
[InlineData(48, "2 hari dari sekarang")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "kemarin")] | ||
[InlineData(15, "15 hari yang lalu")] | ||
[InlineData(38, "sebulan yang lalu")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "besok")] | ||
[InlineData(10, "10 hari dari sekarang")] | ||
[InlineData(32, "sebulan dari sekarang")] | ||
[InlineData(80, "2 bulan dari sekarang")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "sebulan yang lalu")] | ||
[InlineData(10, "10 bulan yang lalu")] | ||
[InlineData(12, "setahun yang lalu")] | ||
[InlineData(32, "2 tahun yang lalu")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "sebulan dari sekarang")] | ||
[InlineData(8, "8 bulan dari sekarang")] | ||
[InlineData(12, "setahun dari sekarang")] | ||
[InlineData(26, "2 tahun dari sekarang")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-1, "setahun yang lalu")] | ||
[InlineData(-2, "2 tahun yang lalu")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-1, "setahun dari sekarang")] | ||
[InlineData(-5, "5 tahun dari sekarang")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/Humanizer.Tests/Localisation/id/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,79 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.id | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() : base("id-ID") { } | ||
|
||
[Theory] | ||
[InlineData(-7, "waktu kosong")] | ||
[InlineData(7, "1 minggu")] | ||
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. Please add test cases for multiple units for TimeSpan too; e.g. 2 weeks. |
||
[InlineData(21, "3 minggu")] | ||
[InlineData(367, "52 minggu")] | ||
public void Weeks(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(3, "3 hari")] | ||
[InlineData(8, "1 minggu")] | ||
public void Days(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(12, "12 jam")] | ||
[InlineData(24, "1 hari")] | ||
[InlineData(25, "1 hari")] | ||
public void Hours(int hours, string expected) | ||
{ | ||
var actual = TimeSpan.FromHours(hours).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 menit")] | ||
[InlineData(60, "1 jam")] | ||
[InlineData(120, "2 jam")] | ||
public void Minutes(int minutes, string expected) | ||
{ | ||
var actual = TimeSpan.FromMinutes(minutes).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "1 detik")] | ||
[InlineData(60, "1 menit")] | ||
[InlineData(150, "2 menit")] | ||
public void Seconds(int seconds, string expected) | ||
{ | ||
var actual = TimeSpan.FromSeconds(seconds).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 milidetik")] | ||
[InlineData(2500, "2 detik")] | ||
[InlineData(65000, "1 menit")] | ||
public void Milliseconds(int ms, string expected) | ||
{ | ||
var actual = TimeSpan.FromMilliseconds(ms).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
var noTime = TimeSpan.Zero; | ||
var actual = noTime.Humanize(); | ||
Assert.Equal("waktu kosong", 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.
These tests are quite excessive for localisations. I had to write a lot of tests here because all edge cases and boundary values had to be tested for the implementation. Once that's verified, which happens here, all you need to do is to verify your translations; so I think in your case you only need a couple of test cases per time unit. Please remove all the rest. Check out de and es tests to see how much coverage is needed.