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:
parent
0000ed88f7
commit
55f5cad7f2
@ -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', () => {
|
||||||
|
@ -48,7 +48,7 @@ export function ngettext(
|
|||||||
return djangoNgettext(singular, plural, count);
|
return djangoNgettext(singular, plural, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return singular;
|
return count === 1 ? singular : plural;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user