-
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 pull request #28 from aleksandarni/master
Support for Serbian language (latin)
- Loading branch information
Showing
7 changed files
with
195 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ Supported languages | |
* Russian | ||
* Slovak | ||
* Ukrainian | ||
* Serbian (latin) | ||
|
||
Usage | ||
----- | ||
|
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
78 changes: 78 additions & 0 deletions
78
src/main/java/pl/allegro/finance/tradukisto/internal/languages/serbian/SerbianValues.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,78 @@ | ||
package pl.allegro.finance.tradukisto.internal.languages.serbian; | ||
|
||
import pl.allegro.finance.tradukisto.internal.BaseValues; | ||
import pl.allegro.finance.tradukisto.internal.languages.GenderForms; | ||
import pl.allegro.finance.tradukisto.internal.languages.GenderType; | ||
import pl.allegro.finance.tradukisto.internal.languages.PluralForms; | ||
import pl.allegro.finance.tradukisto.internal.languages.SlavonicPluralForms; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static pl.allegro.finance.tradukisto.internal.languages.GenderForms.genderForms; | ||
import static pl.allegro.finance.tradukisto.internal.support.BaseNumbersBuilder.baseNumbersBuilder; | ||
|
||
public class SerbianValues implements BaseValues { | ||
@Override | ||
public Map<Integer, GenderForms> baseNumbers() { | ||
return baseNumbersBuilder() | ||
.put(0, "nula") | ||
.put(1, genderForms("jedan", "jedna", "jedan", "jedan")) | ||
.put(2, genderForms("dva", "dve", "dve", "dva")) | ||
.put(3, "tri") | ||
.put(4, "četiri") | ||
.put(5, "pet") | ||
.put(6, "šest") | ||
.put(7, "sedam") | ||
.put(8, "osam") | ||
.put(9, "devet") | ||
.put(10, "deset") | ||
.put(11, "jedanaest") | ||
.put(12, "dvanaest") | ||
.put(13, "trinaest") | ||
.put(14, "četrnaest") | ||
.put(15, "petnaest") | ||
.put(16, "šestnaest") | ||
.put(17, "sedamnaest") | ||
.put(18, "osamnaest") | ||
.put(19, "devetnaest") | ||
.put(20, "dvadeset") | ||
.put(30, "trideset") | ||
.put(40, "četrdeset") | ||
.put(50, "pedeset") | ||
.put(60, "šezdeset") | ||
.put(70, "sedamdeset") | ||
.put(80, "osamdeset") | ||
.put(90, "devedeset") | ||
.put(100, "sto") | ||
.put(200, "dvesta") | ||
.put(300, "trista") | ||
.put(400, "četristo") | ||
.put(500, "petsto") | ||
.put(600, "šeststo") | ||
.put(700, "sedamsto") | ||
.put(800, "osamsto") | ||
.put(900, "devetsto") | ||
.build(); | ||
} | ||
|
||
@Override | ||
public List<PluralForms> pluralForms() { | ||
return Arrays.asList( | ||
new SlavonicPluralForms("", "", ""), | ||
new SlavonicPluralForms("hiljada", "hiljade", "hiljada", GenderType.FEMININE), | ||
new SlavonicPluralForms("milion", "miliona", "miliona", GenderType.MASCULINE), | ||
new SlavonicPluralForms("milijarda", "milijarde", "milijardi", GenderType.FEMININE)); | ||
} | ||
|
||
@Override | ||
public String currency() { | ||
return "RSD"; | ||
} | ||
|
||
@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
100 changes: 100 additions & 0 deletions
100
.../groovy/pl/allegro/finance/tradukisto/internal/languages/serbian/SerbianValuesTest.groovy
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,100 @@ | ||
package pl.allegro.finance.tradukisto.internal.languages.serbian | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
import static pl.allegro.finance.tradukisto.internal.Container.serbianContainer | ||
|
||
class SerbianValuesTest extends Specification { | ||
|
||
static converter = serbianContainer().getNumbersConverter() | ||
|
||
@Unroll | ||
def "should convert #value to '#words' in Serbian"() { | ||
expect: | ||
converter.asWords(value) == words | ||
|
||
where: | ||
value | words | ||
0 | "nula" | ||
1 | "jedan" | ||
2 | "dva" | ||
3 | "tri" | ||
4 | "četiri" | ||
5 | "pet" | ||
6 | "šest" | ||
7 | "sedam" | ||
8 | "osam" | ||
9 | "devet" | ||
|
||
11 | "jedanaest" | ||
12 | "dvanaest" | ||
13 | "trinaest" | ||
14 | "četrnaest" | ||
15 | "petnaest" | ||
16 | "šestnaest" | ||
17 | "sedamnaest" | ||
18 | "osamnaest" | ||
19 | "devetnaest" | ||
|
||
10 | "deset" | ||
20 | "dvadeset" | ||
30 | "trideset" | ||
40 | "četrdeset" | ||
50 | "pedeset" | ||
60 | "šezdeset" | ||
70 | "sedamdeset" | ||
80 | "osamdeset" | ||
90 | "devedeset" | ||
|
||
21 | "dvadeset jedan" | ||
37 | "trideset sedam" | ||
43 | "četrdeset tri" | ||
58 | "pedeset osam" | ||
69 | "šezdeset devet" | ||
76 | "sedamdeset šest" | ||
82 | "osamdeset dva" | ||
95 | "devedeset pet" | ||
|
||
100 | "sto" | ||
200 | "dvesta" | ||
300 | "trista" | ||
400 | "četristo" | ||
500 | "petsto" | ||
600 | "šeststo" | ||
700 | "sedamsto" | ||
800 | "osamsto" | ||
900 | "devetsto" | ||
|
||
111 | "sto jedanaest" | ||
272 | "dvesta sedamdeset dva" | ||
387 | "trista osamdeset sedam" | ||
448 | "četristo četrdeset osam" | ||
569 | "petsto šezdeset devet" | ||
625 | "šeststo dvadeset pet" | ||
782 | "sedamsto osamdeset dva" | ||
895 | "osamsto devedeset pet" | ||
999 | "devetsto devedeset devet" | ||
|
||
1_000 | "jedna hiljada" | ||
2_000 | "dve hiljade" | ||
5_000 | "pet hiljada" | ||
7_634 | "sedam hiljada šeststo trideset četiri" | ||
24_190 | "dvadeset četiri hiljade sto devedeset" | ||
653_000 | "šeststo pedeset tri hiljade" | ||
123_454 | "sto dvadeset tri hiljade četristo pedeset četiri" | ||
700_000 | "sedamsto hiljada" | ||
999_999 | "devetsto devedeset devet hiljada devetsto devedeset devet" | ||
|
||
1_000_000 | "jedan milion" | ||
2_000_000 | "dva miliona" | ||
5_000_000 | "pet miliona" | ||
23_437_219 | "dvadeset tri miliona četristo trideset sedam hiljada dvesta devetnaest" | ||
100_000_000 | "sto miliona" | ||
123_456_789 | "sto dvadeset tri miliona četristo pedeset šest hiljada sedamsto osamdeset devet" | ||
|
||
1_000_000_000 | "jedna milijarda" | ||
Integer.MAX_VALUE | "dve milijarde sto četrdeset sedam miliona četristo osamdeset tri hiljade šeststo četrdeset sedam" | ||
|
||
} | ||
} |