Skip to content

Commit

Permalink
Merge pull request #435 from jvanrhyn/master
Browse files Browse the repository at this point in the history
Add Afrikaans localization
  • Loading branch information
MehdiK committed Jun 29, 2015
2 parents 33208c3 + 908fdbc commit 89487b4
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<Compile Include="CollectionHumanizeTests.cs" />
<Compile Include="DateTimeOffsetHumanizeTests.cs" />
<Compile Include="EnumHumanizeWithCustomDescriptionPropertyNamesTests.cs" />
<Compile Include="Localisation\af\DateHumanizeTests.cs" />
<Compile Include="Localisation\af\NumberToWordsTests.cs" />
<Compile Include="Localisation\af\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\bg\DateHumanizeTests.cs" />
<Compile Include="Localisation\bg\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\bn-BD\DateHumanizeTests.cs" />
Expand Down
117 changes: 117 additions & 0 deletions src/Humanizer.Tests/Localisation/af/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using System;
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.af
{
public class DateHumanizeTests : AmbientCulture
{
public DateHumanizeTests() : base("af") { }

[Theory]
[InlineData(2, "2 dae gelede")]
[InlineData(1, "gister")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(2, "2 ure gelede")]
[InlineData(1, "1 uur terug")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(2, "2 minute terug")]
[InlineData(1, "1 minuut terug")]
[InlineData(60, "1 uur terug")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(2, "2 maande gelede")]
[InlineData(1, "1 maand gelede")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(2, "2 sekondes terug")]
[InlineData(1, "1 sekonde terug")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(2, "2 jaar gelede")]
[InlineData(1, "1 jaar gelede")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(2, "oor 2 dae")]
[InlineData(1, "môre")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(2, "oor 2 ure")]
[InlineData(1, "oor 1 uur")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(2, "oor 2 minute")]
[InlineData(1, "oor 1 minuut")]
[InlineData(60, "oor 1 uur")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(2, "oor 2 maande")]
[InlineData(1, "oor 1 maand")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(2, "oor 2 sekondes")]
[InlineData(1, "oor 1 sekonde")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(2, "oor 2 jaar")]
[InlineData(1, "oor 1 jaar")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

[Theory]
[InlineData(0, "nou")]
public void RightNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}
}
}
115 changes: 115 additions & 0 deletions src/Humanizer.Tests/Localisation/af/NumberToWordsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System.Globalization;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.af
{
public class AfrikaansNumberToWordsTests : AmbientCulture
{
public AfrikaansNumberToWordsTests()
: base("af")
{
}

[InlineData(1, "een")]
[InlineData(10, "tien")]
[InlineData(11, "elf")]
[InlineData(20, "twintig")]
[InlineData(122, "een honderd twee en twintig")]
[InlineData(3501, "drie duisend vyf honderd en een")]
[InlineData(100, "een honderd")]
[InlineData(1000, "een duisend")]
[InlineData(100000, "een honderd duisend")]
[InlineData(1000000, "een miljoen")]
[InlineData(10000000, "tien miljoen")]
[InlineData(100000000, "een honderd miljoen")]
[InlineData(1000000000, "een miljard")]
[InlineData(111, "een honderd en elf")]
[InlineData(1111, "een duisend een honderd en elf")]
[InlineData(111111, "een honderd en elf duisend een honderd en elf")]
[InlineData(1111111, "een miljoen een honderd en elf duisend een honderd en elf")]
[InlineData(11111111, "elf miljoen een honderd en elf duisend een honderd en elf")]
[InlineData(111111111, "een honderd en elf miljoen een honderd en elf duisend een honderd en elf")]
[InlineData(1111111111, "een miljard een honderd en elf miljoen een honderd en elf duisend een honderd en elf")]
[InlineData(123, "een honderd drie en twintig")]
[InlineData(1234, "een duisend twee honderd vier en dertig")]
[InlineData(12345, "twaalf duisend drie honderd vyf en veertig")]
[InlineData(123456, "een honderd drie en twintig duisend vier honderd ses en vyftig")]
[InlineData(1234567, "een miljoen twee honderd vier en dertig duisend vyf honderd sewe en sestig")]
[InlineData(12345678, "twaalf miljoen drie honderd vyf en veertig duisend ses honderd agt en sewentig")]
[InlineData(123456789, "een honderd drie en twintig miljoen vier honderd ses en vyftig duisend sewe honderd nege en tagtig")]
[InlineData(1234567890, "een miljard twee honderd vier en dertig miljoen vyf honderd sewe en sestig duisend agt honderd en negentig")]
[Theory]
public void ToWords(int number, string expected)
{
Assert.Equal(expected, number.ToWords());
}

[Theory]
[InlineData(0, "nulste")]
[InlineData(1, "eerste")]
[InlineData(2, "tweede")]
[InlineData(3, "derde")]
[InlineData(4, "vierde")]
[InlineData(5, "vyfde")]
[InlineData(6, "sesde")]
[InlineData(7, "sewende")]
[InlineData(8, "agste")]
[InlineData(9, "negende")]
[InlineData(10, "tiende")]
[InlineData(11, "elfde")]
[InlineData(12, "twaalfde")]
[InlineData(13, "dertiende")]
[InlineData(14, "veertiende")]
[InlineData(15, "vyftiende")]
[InlineData(16, "sestiende")]
[InlineData(17, "sewentiende")]
[InlineData(18, "agtiende")]
[InlineData(19, "negentiende")]
[InlineData(20, "twintigste")]
[InlineData(21, "een en twintigste")]
[InlineData(22, "twee en twintigste")]
[InlineData(30, "dertigste")]
[InlineData(40, "veertigste")]
[InlineData(50, "vyftigste")]
[InlineData(60, "sestigste")]
[InlineData(70, "sewentigste")]
[InlineData(80, "tagtigste")]
[InlineData(90, "negentigste")]
[InlineData(95, "vyf en negentigste")]
[InlineData(96, "ses en negentigste")]
[InlineData(100, "honderdste")]
[InlineData(112, "honderd en twaalfde")]
[InlineData(120, "honderd en twintigste")]
[InlineData(121, "honderd een en twintigste")]
[InlineData(1000, "duisendste")]
[InlineData(1001, "duisend en eerste")]
[InlineData(1021, "duisend een en twintigste")]
[InlineData(10000, "tien duisendste")]
[InlineData(10121, "tien duisend een honderd een en twintigste")]
[InlineData(100000, "honderd duisendste")]
[InlineData(1000000, "miljoenste")]
public void ToOrdinalWords(int number, string words)
{
Assert.Equal(words, number.ToOrdinalWords());
}

[Theory]
[InlineData(11, "en-US", "eleven")]
[InlineData(22, "ar", "اثنان و عشرون")]
[InlineData(40, "ru", "сорок")]
public void ToWords_CanSpecifyCultureExplicitly(int number, string culture, string expected)
{
Assert.Equal(expected, number.ToWords(new CultureInfo(culture)));
}

[Theory]
[InlineData(1021, "en-US", "thousand and twenty-first")]
[InlineData(21, "ar", "الحادي و العشرون")]
[InlineData(1112, "ru", "одна тысяча сто двенадцатый")]
public void ToOrdinalWords_CanSpecifyCultureExplicitly(int number, string culture, string expected)
{
Assert.Equal(expected, number.ToOrdinalWords(new CultureInfo(culture)));
}
}
}
94 changes: 94 additions & 0 deletions src/Humanizer.Tests/Localisation/af/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using Xunit;

namespace Humanizer.Tests.Localisation.af
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("af") { }

[Fact]
public void TwoWeeks()
{
Assert.Equal("2 weke", TimeSpan.FromDays(14).Humanize());
}

[Fact]
public void OneWeek()
{
Assert.Equal("1 week", TimeSpan.FromDays(7).Humanize());
}

[Fact]
public void SixDays()
{
Assert.Equal("6 dae", TimeSpan.FromDays(6).Humanize());
}

[Fact]
public void TwoDays()
{
Assert.Equal("2 dae", TimeSpan.FromDays(2).Humanize());
}

[Fact]
public void OneDay()
{
Assert.Equal("1 dag", TimeSpan.FromDays(1).Humanize());
}

[Fact]
public void TwoHours()
{
Assert.Equal("2 ure", TimeSpan.FromHours(2).Humanize());
}

[Fact]
public void OneHour()
{
Assert.Equal("1 uur", TimeSpan.FromHours(1).Humanize());
}

[Fact]
public void TwoMinutes()
{
Assert.Equal("2 minute", TimeSpan.FromMinutes(2).Humanize());
}

[Fact]
public void OneMinute()
{
Assert.Equal("1 minuut", TimeSpan.FromMinutes(1).Humanize());
}

[Fact]
public void TwoSeconds()
{
Assert.Equal("2 sekondes", TimeSpan.FromSeconds(2).Humanize());
}

[Fact]
public void OneSecond()
{
Assert.Equal("1 sekond", TimeSpan.FromSeconds(1).Humanize());
}

[Fact]
public void TwoMilliseconds()
{
Assert.Equal("2 millisekondes", TimeSpan.FromMilliseconds(2).Humanize());
}

[Fact]
public void OneMillisecond()
{
Assert.Equal("1 millisekond", TimeSpan.FromMilliseconds(1).Humanize());
}

[Fact]
public void NoTime()
{
Assert.Equal("geen tyd", TimeSpan.Zero.Humanize());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal class NumberToWordsConverterRegistry : LocaliserRegistry<INumberToWords
public NumberToWordsConverterRegistry()
: base((culture) => new DefaultNumberToWordsConverter(culture))
{
Register("af", new AfrikaansNumberToWordsConverter());
Register("en", new EnglishNumberToWordsConverter());
Register("ar", new ArabicNumberToWordsConverter());
Register("fa", new FarsiNumberToWordsConverter());
Expand Down
3 changes: 2 additions & 1 deletion src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Configuration\NumberToWordsConverterRegistry.cs" />
<Compile Include="Configuration\OrdinalizerRegistry.cs" />
<Compile Include="Localisation\Formatters\UkrainianFormatter.cs" />
<Compile Include="Localisation\NumberToWords\AfrikaansNumberToWordsConverter.cs" />
<Compile Include="Localisation\NumberToWords\BanglaNumberToWordsConverter.cs" />
<Compile Include="Localisation\NumberToWords\BrazilianPortugueseNumberToWordsConverter.cs" />
<Compile Include="GrammaticalCase.cs" />
Expand Down Expand Up @@ -243,7 +244,7 @@
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetPortable)' == 'false' ">
<ItemGroup Condition=" '$(TargetPortable)' == 'false' ">
<Reference Include="System" />
</ItemGroup>
<Import Condition=" '$(TargetPortable)' == 'false' " Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Loading

0 comments on commit 89487b4

Please sign in to comment.