diff --git a/src/index.spec.ts b/src/index.spec.ts index 410ec90..ec83b99 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -345,20 +345,6 @@ describe('i18n', () => { })).toBe('11 пользователей'); }); - it('should throw exception when missing required plural form', () => { - i18n.setLang('ru'); - i18n.registerKeyset('ru', 'app', { - // @ts-ignore - users: {'many': '{{count}} пользователей'} - }); - - expect(() => { - i18n.i18n('app', 'users', { - count: 11, - }) - }).toThrow(new Error(`Missing required plural form 'other' for key 'users'`)); - }); - it('should use `other` form when no other forms are specified', () => { i18n.setLang('ru'); i18n.registerKeyset('ru', 'app', { @@ -583,7 +569,7 @@ describe('registerKeyset', () => { lang: 'en', data: {en: {notification: {hey: 'Hello!'}}}, }); - + expect(() => { i18n.registerKeyset('en', 'notification', { title: 'Hello!' diff --git a/src/plural/general.ts b/src/plural/general.ts index 1d58107..8cc56da 100644 --- a/src/plural/general.ts +++ b/src/plural/general.ts @@ -1,11 +1,7 @@ import type { DeprecatedPluralValue, PluralValue, Pluralizer } from "../types"; import {PluralForm} from '../types'; -export function getPluralViaIntl(key: string, value: PluralValue, count: number, lang: string) { - if (typeof value.other === 'undefined') { - throw new Error(`Missing required plural form 'other' for key '${key}'`); - } - +export function getPluralViaIntl(value: PluralValue, count: number, lang: string) { if (value.zero && count === 0) { return value.zero; } @@ -37,7 +33,7 @@ type FormatPluralArgs = { export function getPluralValue({value, count, lang, pluralizers, log, key}: FormatPluralArgs) { if (!Array.isArray(value)) { - return getPluralViaIntl(key, value, count, lang) || key; + return getPluralViaIntl(value, count, lang) || key; } if (!pluralizers) {