0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 09:33:54 +01:00

Ensure the ngettext (JS) util emulates the Django global if not present

Follow up from #9617
This commit is contained in:
LB Johnston 2022-11-08 08:02:50 +10:00 committed by LB (Ben Johnston)
parent 0000ed88f7
commit 55f5cad7f2
2 changed files with 4 additions and 3 deletions

View File

@ -30,8 +30,9 @@ describe('gettext', () => {
}); });
describe('ngettext', () => { describe('ngettext', () => {
it('should return the first param if Django ngettext is not loaded', () => { it('should emulate the Django ngettext function if it is not loaded', () => {
expect(ngettext('One bird', 'Many birds', 2)).toEqual('One bird'); expect(ngettext('One bird', 'Many birds', 1)).toEqual('One bird');
expect(ngettext('One bird', 'Many birds', 2)).toEqual('Many birds');
}); });
it('should call the global Django util if loaded', () => { it('should call the global Django util if loaded', () => {

View File

@ -48,7 +48,7 @@ export function ngettext(
return djangoNgettext(singular, plural, count); return djangoNgettext(singular, plural, count);
} }
return singular; return count === 1 ? singular : plural;
} }
/** /**