Skip to content

Commit d4deba3

Browse files
brianfunkclaude
andcommitted
fix(it): handle cento elision before otto/ottanta
Italian drops the trailing "o" in cento/duecento/etc. before words starting with "o" (otto=8, ottanta=80-89). 108 is "centotto" not "centootto", 180 is "centottanta" not "centoottanta". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6031073 commit d4deba3

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

languages/it.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const tenment = (n, g) => hundment(n, g) % 100;
3535
const hundredIt = (n) => {
3636
if (n < 100 || n >= 1000) return '';
3737
const h = Math.floor(n / 100);
38+
const remainder = n % 100;
39+
// Elision: drop trailing 'o' before otto (8) and ottanta (80-89)
40+
if (remainder >= 80 && remainder <= 89 || remainder === 8) {
41+
return IT_HUNDREDS[h].slice(0, -1);
42+
}
3843
return IT_HUNDREDS[h];
3944
};
4045

test/index.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,12 +1184,22 @@ describe('italian', () => {
11841184
expect(italian(42)).toBe('quarantadue');
11851185
});
11861186

1187-
it('handles elision rules', () => {
1187+
it('handles tens elision rules', () => {
11881188
expect(italian(21)).toBe('ventuno');
11891189
expect(italian(28)).toBe('ventotto');
11901190
expect(italian(23)).toBe('ventitré');
11911191
});
11921192

1193+
it('handles cento elision before otto/ottanta', () => {
1194+
expect(italian(108)).toBe('centotto');
1195+
expect(italian(180)).toBe('centottanta');
1196+
expect(italian(188)).toBe('centottantotto');
1197+
expect(italian(208)).toBe('duecentotto');
1198+
expect(italian(280)).toBe('duecentottanta');
1199+
expect(italian(808)).toBe('ottocentotto');
1200+
expect(italian(880)).toBe('ottocentottanta');
1201+
});
1202+
11931203
it('converts thousands', () => {
11941204
expect(italian(1000)).toBe('mille');
11951205
expect(italian(2000)).toBe('duemila');

0 commit comments

Comments
 (0)