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

Initial Indonesia localization #141

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
###In Development
[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.15...master)

###v1.20.15 - 2014-04-12
- [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored `ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization
- [#141](https://github.com/MehdiK/Humanizer/pull/141): Added Indonesia localization (strings, tests)
- [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization
- [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize

[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...v1.20.15)
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 @@ -87,6 +87,8 @@
<Compile Include="Localisation\invariant\NumberToWordsTests.cs" />
<Compile Include="Localisation\invariant\ToQuantityTests.cs" />
<Compile Include="Localisation\es\NumberToWordsTests.cs" />
<Compile Include="Localisation\id\DateHumanizeTests.cs" />
<Compile Include="Localisation\id\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\NumberToWordsTests.cs" />
Expand Down
123 changes: 123 additions & 0 deletions src/Humanizer.Tests/Localisation/id/DateHumanizeTests.cs
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)
Copy link
Member

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.

{
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 src/Humanizer.Tests/Localisation/id/TimeSpanHumanizeTests.cs
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")]
Copy link
Member

Choose a reason for hiding this comment

The 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);
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.da.resx" />
<EmbeddedResource Include="Properties\Resources.id.resx" />
<EmbeddedResource Include="Properties\Resources.pl.resx" />
<EmbeddedResource Include="Properties\Resources.cs.resx" />
<EmbeddedResource Include="Properties\Resources.de.resx" />
Expand Down
Loading