-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/github_actions/dependabot/fetch…
…-metadata-2.2.0
- Loading branch information
Showing
69 changed files
with
3,304 additions
and
3,123 deletions.
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
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
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
81 changes: 81 additions & 0 deletions
81
...ava/pl/allegro/finance/tradukisto/internal/languages/dutch/DutchLongToWordsConverter.java
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,81 @@ | ||
package pl.allegro.finance.tradukisto.internal.languages.dutch; | ||
|
||
import pl.allegro.finance.tradukisto.internal.GenderAwareIntegerToStringConverter; | ||
import pl.allegro.finance.tradukisto.internal.LongToStringConverter; | ||
import pl.allegro.finance.tradukisto.internal.languages.GenderType; | ||
import pl.allegro.finance.tradukisto.internal.languages.PluralForms; | ||
import pl.allegro.finance.tradukisto.internal.support.Assert; | ||
import pl.allegro.finance.tradukisto.internal.support.NumberChunking; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import static java.util.Collections.reverse; | ||
|
||
public class DutchLongToWordsConverter implements LongToStringConverter { | ||
|
||
private final NumberChunking numberChunking = new NumberChunking(); | ||
|
||
private final GenderAwareIntegerToStringConverter hundredsToWordsConverter; | ||
private final List<PluralForms> pluralForms; | ||
|
||
public DutchLongToWordsConverter( | ||
GenderAwareIntegerToStringConverter hundredsToWordsConverter, | ||
List<PluralForms> pluralForms | ||
) { | ||
this.hundredsToWordsConverter = hundredsToWordsConverter; | ||
this.pluralForms = pluralForms; | ||
} | ||
|
||
@Override | ||
public String asWords(Long value) { | ||
Assert.isTrue(value >= 0, () -> String.format("can't convert negative numbers for value %d", value)); | ||
|
||
List<String> result = new ArrayList<>(); | ||
|
||
long bigNumber = value / 1000000; | ||
long smallNumber = value % 1000000; | ||
|
||
if (bigNumber > 0) { | ||
List<Integer> valueChunks = numberChunking.chunk(bigNumber); | ||
List<PluralForms> formsToUse = getRequiredFormsInReversedOrder(valueChunks.size()); | ||
result.add(joinValueChunksWithForms(valueChunks.iterator(), formsToUse.iterator())); | ||
} | ||
|
||
if (smallNumber > 0) { | ||
result.add(hundredsToWordsConverter.asWords((int) smallNumber, GenderType.NON_APPLICABLE)); | ||
} | ||
|
||
return joinParts(result); | ||
} | ||
|
||
protected List<PluralForms> getRequiredFormsInReversedOrder(int chunks) { | ||
List<PluralForms> formsToUse = new ArrayList<>(pluralForms.subList(0, chunks)); | ||
reverse(formsToUse); | ||
return formsToUse; | ||
} | ||
|
||
protected String joinValueChunksWithForms(Iterator<Integer> chunks, Iterator<PluralForms> formsToUse) { | ||
List<String> result = new ArrayList<>(); | ||
|
||
while (chunks.hasNext() && formsToUse.hasNext()) { | ||
Integer currentChunkValue = chunks.next(); | ||
PluralForms currentForms = formsToUse.next(); | ||
|
||
if (currentChunkValue > 0) { | ||
String words = hundredsToWordsConverter.asWords(currentChunkValue, currentForms.genderType()); | ||
result.add(words); | ||
result.add(currentForms.formFor(currentChunkValue)); | ||
} | ||
} | ||
|
||
return joinParts(result); | ||
} | ||
|
||
protected String joinParts(List<String> result) { | ||
return result.isEmpty() | ||
? hundredsToWordsConverter.asWords(0, pluralForms.get(0).genderType()) | ||
: String.join(" ", result).trim(); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/pl/allegro/finance/tradukisto/internal/languages/kyrgyz/KyrgyzPluralForms.java
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,23 @@ | ||
package pl.allegro.finance.tradukisto.internal.languages.kyrgyz; | ||
|
||
import pl.allegro.finance.tradukisto.internal.languages.GenderType; | ||
import pl.allegro.finance.tradukisto.internal.languages.PluralForms; | ||
|
||
public class KyrgyzPluralForms implements PluralForms { | ||
|
||
private String form; | ||
|
||
public KyrgyzPluralForms(String form) { | ||
this.form = form; | ||
} | ||
|
||
@Override | ||
public String formFor(Integer value) { | ||
return form; | ||
} | ||
|
||
@Override | ||
public GenderType genderType() { | ||
return GenderType.NON_APPLICABLE; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/pl/allegro/finance/tradukisto/internal/languages/kyrgyz/KyrgyzValues.java
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,77 @@ | ||
package pl.allegro.finance.tradukisto.internal.languages.kyrgyz; | ||
|
||
import pl.allegro.finance.tradukisto.internal.BaseValues; | ||
import pl.allegro.finance.tradukisto.internal.languages.GenderForms; | ||
import pl.allegro.finance.tradukisto.internal.languages.PluralForms; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static pl.allegro.finance.tradukisto.internal.support.BaseNumbersBuilder.baseNumbersBuilder; | ||
|
||
public class KyrgyzValues implements BaseValues { | ||
|
||
@Override | ||
public Map<Integer, GenderForms> baseNumbers() { | ||
return baseNumbersBuilder() | ||
.put(0, "нөл") | ||
.put(1, "бир") | ||
.put(2, "эки") | ||
.put(3, "үч") | ||
.put(4, "төрт") | ||
.put(5, "беш") | ||
.put(6, "алты") | ||
.put(7, "жети") | ||
.put(8, "сегиз") | ||
.put(9, "тогуз") | ||
.put(10, "он") | ||
.put(11, "он бир") | ||
.put(12, "он эки") | ||
.put(13, "он үч") | ||
.put(14, "он төрт") | ||
.put(15, "он беш") | ||
.put(16, "он алты") | ||
.put(17, "он жети") | ||
.put(18, "он сегиз") | ||
.put(19, "он тогуз") | ||
.put(20, "жыйырма") | ||
.put(30, "отуз") | ||
.put(40, "кырк") | ||
.put(50, "элүү") | ||
.put(60, "алтымыш") | ||
.put(70, "жетимиш") | ||
.put(80, "сексен") | ||
.put(90, "токсон") | ||
.put(100, "жүз") | ||
.put(200, "эки жүз") | ||
.put(300, "үч жүз") | ||
.put(400, "төрт жүз") | ||
.put(500, "беш жүз") | ||
.put(600, "алты жүз") | ||
.put(700, "жети жүз") | ||
.put(800, "сегиз жүз") | ||
.put(900, "тогуз жүз") | ||
.build(); | ||
} | ||
|
||
@Override | ||
public List<PluralForms> pluralForms() { | ||
return Arrays.asList( | ||
new KyrgyzPluralForms(""), | ||
new KyrgyzPluralForms("миң"), | ||
new KyrgyzPluralForms("миллион"), | ||
new KyrgyzPluralForms("миллиард") | ||
); | ||
} | ||
|
||
@Override | ||
public String currency() { | ||
return "сом"; | ||
} | ||
|
||
@Override | ||
public char twoDigitsNumberSeparator() { | ||
return ' '; | ||
} | ||
} |
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
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
Oops, something went wrong.