Skip to content

Fix Slovenian plural forms for counts such as 11, 12, 13, 21, and 22 - #248

Merged
EvanHahn merged 4 commits into
EvanHahn:mainfrom
zzoraemon043:fix/slovenian-plural-forms
Nov 29, 2026
Merged

EvanHahn merged 4 commits into
EvanHahn:mainfrom
zzoraemon043:fix/slovenian-plural-forms

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Slovenian picks the plural form from the last two digits: 1, 101 singular; 2, 102 dual; 3, 4, 103, 104 plural; everything else (including 11-14 and 21-24) genitive plural. Most sl units checked only the last digit, so:

Input Before After
humanizeDuration(21, { language: "sl" }) 21 milisekunda 21 milisekund
humanizeDuration(11000, { language: "sl" }) 11 sekunda 11 sekund
humanizeDuration(720000, { language: "sl" }) 12 minuti 12 minut
humanizeDuration(780000, { language: "sl" }) 13 minute 13 minut
humanizeDuration(82800000, { language: "sl" }) 23 ure 23 ur
humanizeDuration(28927800000, { language: "sl" }) 11 mesec 11 mesecev
humanizeDuration(662709600000, { language: "sl" }) 21 leto 21 let
12 weeks (units: ["w"]) 12 tedna 12 tednov

Days already used c % 100 === 1; this makes the other units do the same (c % 10 === to c % 100 === in the sl block only). The fractional branches are untouched.

Checks:

  • Every integer from 0 to 1200 for each unit now maps one Intl.PluralRules("sl") category to one word.
  • Fractional counts (0.1, 0.25, 0.5, 0.75 steps up to 250, all units) give the same output as before, and no other language changes.
  • 19 of the 22 new rows in test/definitions/sl.tsv fail on main (101, 102 and 103 years already passed) and all pass with the fix.
  • npm test passes (prettier, eslint, tsc, 34 tests). Changelog and credits updated per CONTRIBUTING.md.

@EvanHahn EvanHahn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you:

  1. Rebase off the latest main.
  2. Update the tests: the changed outputs ("11 tednov", "12 tednov", "22 tednov") and the string tednov are never asserted.

Other than that, this PR looks good to me!

Slovenian picks the form from the last two digits (1 and 101 are
singular, 2 and 102 dual, 3, 4, 103, and 104 plural, the rest genitive
plural), but most units checked the last digit only. That gave "21 leto"
instead of "21 let", "12 minuti" instead of "12 minut", and "13 ure"
instead of "13 ur". Days already used the last two digits.

Fractional counts are unchanged.
@zzoraemon043
zzoraemon043 force-pushed the fix/slovenian-plural-forms branch from 37ca5e4 to 7b73a8a Compare November 25, 2026 15:12
@zzoraemon043

Copy link
Copy Markdown
Contributor Author

Rebased on main. Weeks never get past 4 in the .tsv tests because months take over, so I added test/slovenian.js with units: ["w"]; it asserts "11 tednov", "12 tednov", "22 tednov" and friends, and fails on the old code ("11 teden").

@EvanHahn EvanHahn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks close, but could you move the test in test/slovenian.js into test/languages.js, like what was done in commit 5eac3b8? Make sure to pull the definition of the week variable to the top of the file so DRY that out.

@zzoraemon043

Copy link
Copy Markdown
Contributor Author

Moved it into test/languages.js next to the Croatian test and hoisted week to the top of the file; test/slovenian.js is gone.

@EvanHahn
EvanHahn merged commit c8c41f6 into EvanHahn:main Nov 29, 2026
1 check passed
@EvanHahn

Copy link
Copy Markdown
Owner

This has been deployed in [email protected]. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants