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

Added Italian localisation and tests #332

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7a78924
Added initial Resource italian translation
Aug 18, 2014
2b65001
Improved 'xxxFromNow' translations
Aug 18, 2014
107ba30
Added Zero Time italian translation
Aug 18, 2014
5a38abf
L10n: added italian collection formatter
Aug 25, 2014
b84a80b
L10n: added failing italian DateHumanizeTests
Aug 25, 2014
960e46e
L10n: Fix: VS project was missing italian resource file
Aug 25, 2014
1df1d6b
Merge branch 'fix_res_not_added'
Aug 25, 2014
7158e06
L10n: italian DateHumanizeTests now passing
Aug 25, 2014
104a1dc
L10n: italian TimeSpanHumanizeTests passing
Aug 25, 2014
f39506b
L10n: italian CollectionFormatterTests passing
Aug 26, 2014
42a2f7e
L10n: in italian collections avoid last comma
Aug 26, 2014
bcbadfe
L10n: Refactored italian CollectionFormatterTests
Aug 26, 2014
d413bae
Readme: fixed ToOrdinalWords in place of Ordinalize
Aug 26, 2014
fce81bf
Merge branch 'readme_fix_ordinalize'
Aug 26, 2014
eebaabd
L10n: added italian OrdinalizerTests
Aug 26, 2014
3946dee
L10n: italian OrdinalizerTests passing
Aug 26, 2014
55a61f3
L10: italian OrdinalizerTests passing with text input
Aug 26, 2014
793139f
L10n: added initial italian NumberToWordsConverter
Aug 26, 2014
103f6d2
L10n: italian NumberToWordsTests passing for thousand and negative
Aug 26, 2014
d113e6b
L10n: Refactor: removed inner class in ItalianNumberToWordsConverter
Aug 26, 2014
19742d1
L10n: Refactor: added header comments and renamed identifiers.
Aug 26, 2014
43cae6f
L10n: italian NumberToWordsTests passing for simple million numbers
Aug 26, 2014
1ae2ff0
L10n: italian NumberToWordsTests passing for simple billions numbers.
Aug 26, 2014
7409b5c
L10n: italian NumberToWords converter supports ventitrè, trentatrè, etc.
Aug 26, 2014
92c5ca3
L10n: italian NumberToWords passing all ToWords tests
Aug 26, 2014
88f5bae
L10n: italian NumberToWordsTests passing for feminine gender
Aug 26, 2014
f4cca21
L10n: Refactor: italian cardinal number to words logic moved to separ…
Aug 26, 2014
4a7533f
L10n: added initial italian ordinal NumberToWordsConverter
Aug 26, 2014
17e2e12
L10n: italian NumberToWordsTests passing for ordinals up to 30.
Aug 26, 2014
adf3153
L10n: italian NumberToWordsTests passing for ordinals up to 99.
Aug 26, 2014
2d28a62
L10n: italian NumberToWordsTests passing for ordinals up to 201
Aug 26, 2014
28d72e0
L10n: Refactor: move zero logic to NumberCruncher in italian NumberTo…
Aug 26, 2014
2462be2
L10n: italian NumberToWordsTests passing for ordinals up to 900
Aug 26, 2014
200273d
L10n: Refactor: italian ordinal NumberToWords reuses cardinal logic
Aug 26, 2014
2901c67
L10n: italian NumberToWordsTests passing for ordinals up to 10121
Aug 26, 2014
06d7d14
L10n: italian NumberToWordsTests passing for ordinals up to 100000000
Aug 26, 2014
c9cad01
L10n: italian NumberToWordsTests passing for ordinals up to 2 billions
Aug 26, 2014
164f12c
L10n: italian NumberToWordsTests passing for feminine ordinal
Aug 27, 2014
af961ff
L10n: italian NumberToWordsTests passing for masculine ordinal
Aug 28, 2014
ceba64c
Added PR entry in release notes
Aug 28, 2014
8c2f275
Refactor: ItalianCollectionFormatter starts with an array, not enumer…
Sep 1, 2014
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
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ The possible values are `GrammaticalGender.Masculine`, `GrammaticalGender.Femini

```C#
// for Brazilian Portuguese locale
1.ToOrdinalWords(GrammaticalGender.Masculine) => "1º"
1.ToOrdinalWords(GrammaticalGender.Feminine) => "1ª"
1.ToOrdinalWords(GrammaticalGender.Neuter) => "1º"
"2".ToOrdinalWords(GrammaticalGender.Masculine) => "2º"
"2".ToOrdinalWords(GrammaticalGender.Feminine) => "2ª"
"2".ToOrdinalWords(GrammaticalGender.Neuter) => "2º"
1.Ordinalize(GrammaticalGender.Masculine) => "1º"
1.Ordinalize(GrammaticalGender.Feminine) => "1ª"
1.Ordinalize(GrammaticalGender.Neuter) => "1º"
"2".Ordinalize(GrammaticalGender.Masculine) => "2º"
"2".Ordinalize(GrammaticalGender.Feminine) => "2ª"
"2".Ordinalize(GrammaticalGender.Neuter) => "2º"
```

Obviously this only applies to some cultures. For others passing gender in or not passing at all doesn't make any difference in the result.
Expand Down
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [#320](https://github.com/MehdiK/Humanizer/pull/320): Fixed Dehumanize actually humanizing an already dehumanized string
- [#322](https://github.com/MehdiK/Humanizer/pull/322): DefaultFormatter.TimeSpanHumanize throws a more meaningful exception when called with TimeUnits larger than TimeUnit.Week
- [#314](https://github.com/MehdiK/Humanizer/pull/314): Added ByteRate class and supporting members to facilitate calculation of byte transfer rates
- [#332](https://github.com/MehdiK/Humanizer/pull/332): Added Italian localisation and tests: date and time Resources, CollectionFormatter, NumberToWordsConverter (cardinal and ordinal), Ordinalizer

[Commits](https://github.com/MehdiK/Humanizer/compare/v1.28.0...master)

Expand Down
5 changes: 5 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
<Compile Include="Localisation\tr\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\vi\DateHumanizeTests.cs" />
<Compile Include="Localisation\vi\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\it\DateHumanizeTests.cs" />
<Compile Include="Localisation\it\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\it\CollectionFormatterTests.cs" />
<Compile Include="Localisation\it\OrdinalizerTests.cs" />
<Compile Include="Localisation\it\NumberToWordsTests.cs" />
<Compile Include="ResourceKeyTests.cs" />
<Compile Include="RomanNumeralTests.cs" />
<Compile Include="StringExtensionsTests.cs" />
Expand Down
39 changes: 39 additions & 0 deletions src/Humanizer.Tests/Localisation/it/CollectionFormatterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.it
{
public class CollectionFormatterTests : AmbientCulture
{
public CollectionFormatterTests()
: base("it")
{
}

[Fact]
public void OneItem()
{
var collection = new List<int>(new int[] {1});
string humanized = "1";
Assert.Equal(humanized, collection.Humanize());
}

[Fact]
public void TwoItems()
{
var collection = new List<int>(new int[] {1, 2});
string humanized = "1 e 2";
Assert.Equal(humanized, collection.Humanize());
}

[Fact]
public void MoreThanTwoItems()
{
var collection = new List<int>(new int[] {1, 2, 3});
string humanized = "1, 2 e 3";
Assert.Equal(humanized, collection.Humanize());
}
}
}
119 changes: 119 additions & 0 deletions src/Humanizer.Tests/Localisation/it/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using Humanizer.Localisation;
using Xunit;
using Xunit.Extensions;

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

[Theory]
[InlineData(-2, "2 giorni fa")]
[InlineData(-1, "ieri")]
public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(2, "tra 2 giorni")]
[InlineData(1, "domani")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(-2, "2 ore fa")]
[InlineData(-1, "un'ora fa")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(2, "tra 2 ore")]
[InlineData(1, "tra un'ora")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(-2, "2 minuti fa")]
[InlineData(-1, "un minuto fa")]
[InlineData(60, "un'ora fa")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(2, "tra 2 minuti")]
[InlineData(1, "tra un minuto")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(-2, "2 mesi fa")]
[InlineData(-1, "un mese fa")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(2, "tra 2 mesi")]
[InlineData(1, "tra un mese")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(-2, "2 secondi fa")]
[InlineData(-1, "un secondo fa")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(2, "tra 2 secondi")]
[InlineData(1, "tra un secondo")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(-2, "2 anni fa")]
[InlineData(-1, "un anno fa")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

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

[Theory]
[InlineData(0, "adesso")]
public void Now(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
Loading