-
Notifications
You must be signed in to change notification settings - Fork 966
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
Changed the NumberToWords Converter to find the right converter by the language Name as well #174
Closed
+70
−1
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9db1f7d
Changed the NumberToWords Converter to find the right converter by th…
akamud 21d9916
release notes for Pull Request #174
akamud f01facb
Updated the test to show the Converter did not get the default Number…
akamud f4747ae
Merge branch 'french'
MehdiK 5c96a6f
Changed the NumberToWords Converter to find the right converter by th…
akamud 38ec864
release notes for Pull Request #174
akamud 75b03d8
Updated the test to show the Converter did not get the default Number…
akamud 2c84c1e
Added an extra test to show it can correctly resolve pt-BR and pt-PT …
akamud 8f9a477
Merge branch 'feature/to-words-converter-by-name' of https://github.c…
akamud 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
49 changes: 49 additions & 0 deletions
49
src/Humanizer.Tests/Localisation/NumerToWordsFactoryTests.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,49 @@ | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation | ||
{ | ||
public class NumerToWordsFactoryTests | ||
{ | ||
[Theory] | ||
[InlineData("1000000000", 1000000000)] | ||
public void CanGetTwoLetterISOLanguageSpecificFactory(string notExpected, int number) | ||
{ | ||
using (new AmbientCulture("ar")) | ||
{ | ||
string result = number.ToWords(); | ||
Assert.NotEqual(notExpected, result); | ||
} | ||
} | ||
|
||
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 remove redundant spaces. |
||
[Theory] | ||
[InlineData("1000000000", 1000000000)] | ||
public void CanGetRFCStandardLanguageSpecificFactory(string notExpected, int number) | ||
{ | ||
using (new AmbientCulture("pt-BR")) | ||
{ | ||
string result = number.ToWords(); | ||
Assert.NotEqual(notExpected, result); | ||
} | ||
} | ||
|
||
[Theory] | ||
[InlineData(1000000000)] | ||
public void CanGetCorrectRFCStandardLanguageSpecificFactory(int number) | ||
{ | ||
string resultPtBR; | ||
using (new AmbientCulture("pt-BR")) | ||
{ | ||
resultPtBR = number.ToWords(); | ||
} | ||
|
||
string resultPtPT; | ||
using (new AmbientCulture("pt-PT")) | ||
{ | ||
resultPtPT = number.ToWords(); | ||
} | ||
|
||
Assert.NotEqual(resultPtBR, resultPtPT); | ||
} | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.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,12 @@ | ||
using System; | ||
|
||
namespace Humanizer.Localisation.NumberToWords | ||
{ | ||
internal class BrazilianPortugueseNumberToWordsConverter : DefaultNumberToWordsConverter | ||
{ | ||
public override string Convert(int number) | ||
{ | ||
return "not implemented"; | ||
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. This will upset Brazilian users I believe. We need to implement this first. |
||
} | ||
} | ||
} |
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
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.
Please add some tests to verify the logic works for pt-PT and pt-BR.