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

Register Filipino formatter #1098

Merged
merged 1 commit into from
Jul 3, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fa\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fi-FI\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fi-FI\NumberToWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fil-PH\TimeSpanHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fr-BE\DateHumanizeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fr-BE\NumberToWordsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Localisation\fr-BE\TimeSpanHumanizeTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using Xunit;

namespace Humanizer.Tests.Localisation.filPH
{
[UseCulture("fil-PH")]
public class TimeSpanHumanizeTests
{
[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(366, "1 taon")]
[InlineData(731, "2 taon")]
[InlineData(1096, "3 taon")]
[InlineData(4018, "11 taon")]
public void Years(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year));
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(31, "1 buwan")]
[InlineData(61, "2 buwan")]
[InlineData(92, "3 buwan")]
[InlineData(335, "11 buwan")]
public void Months(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Year));
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(7, "1 linggo")]
[InlineData(14, "2 linggo")]
[InlineData(21, "3 linggo")]
[InlineData(77, "11 linggo")]
public void Weeks(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(1, "1 araw")]
[InlineData(2, "2 araw")]
public void Days(int days, string expected)
{
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize());
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(1, "1 oras")]
[InlineData(2, "2 oras")]
public void Hours(int hours, string expected)
{
Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize());
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(1, "1 minuto")]
[InlineData(2, "2 minuto")]
public void Minutes(int minutes, string expected)
{
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize());
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(1, "1 segundo")]
[InlineData(2, "2 segundo")]
public void Seconds(int seconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize());
}

[Theory]
[Trait("Translation", "Google Translate")]
[InlineData(1, "1 millisecond")]
[InlineData(2, "2 milliseconds")]
public void Milliseconds(int milliseconds, string expected)
{
Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize());
}

[Fact]
public void NoTime()
{
Assert.Equal("0 milliseconds", TimeSpan.Zero.Humanize());
}

[Fact]
public void NoTimeToWords()
{
Assert.Equal("walang oras", TimeSpan.Zero.Humanize(toWords: true));
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Configuration/FormatterRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US"))
RegisterDefaultFormatter("es");
RegisterDefaultFormatter("fa");
RegisterDefaultFormatter("fi-FI");
RegisterDefaultFormatter("fil-PH");
RegisterDefaultFormatter("hu");
RegisterDefaultFormatter("hy");
RegisterDefaultFormatter("id");
Expand Down