Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions src/hr-HR.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*
* Key features:
* - Three-form pluralization (one/few/many)
* - Gender: thousands are feminine, millions+ are masculine
* - Gender by scale word: tisuća and the -arda forms (milijarda, bilijarda, ...)
* are feminine; the -un forms (milijun, bilijun, ...) are masculine
* - Irregular hundreds (dvjesto, tristo, etc.)
* - Long scale naming with -ard forms
*/
Expand Down Expand Up @@ -63,7 +64,8 @@ const EURO_FORMS = ['euro', 'eura', 'eura']
const CENT_FORMS = ['cent', 'centa', 'centi']

// Scale words: [singular, few, many]
// Thousands (index 0) are feminine, rest are masculine
// Indexed [scaleIndex - 1]; odd scales (tisuća, milijarda, bilijarda, ...) are
// feminine, the -un forms (milijun, bilijun, ...) masculine
const SCALE_FORMS = [
['tisuća', 'tisuće', 'tisuća'],
['milijun', 'milijuna', 'milijuna'],
Expand Down Expand Up @@ -221,8 +223,8 @@ function buildLargeNumberWords(n, gender) {
else {
const scaleForms = SCALE_FORMS[scaleIndex - 1]
const scaleWord = pluralize(segment, scaleForms)
// Thousands (scaleIndex=1) are feminine, others masculine
const isFeminine = scaleIndex === 1
// tisuća and the -arda forms (milijarda, bilijarda, ...) are feminine; -un words masculine
const isFeminine = scaleIndex % 2 === 1
const segmentWord = isFeminine ? buildSegmentFem(segment) : buildSegmentMasc(segment)
parts.push(segmentWord + ' ' + scaleWord)
}
Expand Down Expand Up @@ -429,15 +431,15 @@ function buildLargeOrdinal(n) {
parts.push(ORDINAL_SCALES[scaleIndex - 1])
}
else {
const isFeminine = scaleIndex === 1
const isFeminine = scaleIndex % 2 === 1 // feminine at odd scales (tisuća, milijarda, ...)
const segmentWord = isFeminine ? buildSegmentFem(segment) : buildSegmentMasc(segment)
parts.push(segmentWord + ' ' + ORDINAL_SCALES[scaleIndex - 1])
}
}
else {
const scaleForms = SCALE_FORMS[scaleIndex - 1]
const scaleWord = pluralize(segment, scaleForms)
const isFeminine = scaleIndex === 1
const isFeminine = scaleIndex % 2 === 1
const segmentWord = isFeminine ? buildSegmentFem(segment) : buildSegmentMasc(segment)
parts.push(segmentWord + ' ' + scaleWord)
}
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/hr-HR.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ export const cardinal = [
[1_000_000, 'jedan milijun'],
[1_000_001, 'jedan milijun jedan'],
[4_000_000, 'četiri milijuna'],
[1_000_000_000, 'jedna milijarda'],
[2_000_000_000, 'dvije milijarde'],
[5_000_000_000, 'pet milijarda'],
[10_000_000_000_000, 'deset bilijuna'],
[100_000_000_000_000, 'sto bilijuna'],
[1_000_000_000_000_000n, 'jedna bilijarda'],
[1_000_000_000_000_000_000n, 'jedan trilijun'],

// Feminine gender tests
Expand Down Expand Up @@ -130,6 +134,10 @@ export const ordinal = [
// Millions
[1000000, 'milijunti'],
[2000000, 'dva milijunti'],

// Billions (milijarda is feminine, like tisuća)
[1_000_000_000, 'milijarditi'],
[2_000_000_000, 'dvije milijarditi'],
]

/**
Expand Down