mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
fix(v2): fix bad theme pluralization rules for some labels (#4304)
* Pluralization test! * Simplify usePluralForm usage with | plural message separator * fix interpolate bug with falsy values like 0 * fix interpolate bug with falsy values like 0 * Order plural forms + allow to not provide the last plural forms if they are not used * fix typo * revert test! * plurals and typo of the SearchPage * update some labels * improve the update-code-translations cli + update translations * pluralize blog reading time label * ensure base.json contains message descriptions: helps the user to provide the translations * remove russian production locale
This commit is contained in:
parent
6c73f51f94
commit
364d4dbf01
16 changed files with 358 additions and 75 deletions
|
@ -53,7 +53,7 @@ export function interpolate<Str extends string, Value extends ReactNode>(
|
|||
|
||||
const value = values?.[key];
|
||||
|
||||
if (value) {
|
||||
if (typeof value !== 'undefined') {
|
||||
const element = React.isValidElement(value)
|
||||
? value
|
||||
: // For non-React elements: basic primitive->string conversion
|
||||
|
|
|
@ -36,6 +36,17 @@ describe('Interpolate', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('placeholders with falsy values', () => {
|
||||
const text = '{number} {string} {boolean}';
|
||||
const values = {
|
||||
number: 0,
|
||||
string: '',
|
||||
boolean: false,
|
||||
};
|
||||
// Do we need to improve the JS type -> String conversion logic here?
|
||||
expect(interpolate(text, values)).toMatchInlineSnapshot(`"0 false"`);
|
||||
});
|
||||
|
||||
test('placeholders with string values mismatch', () => {
|
||||
// Should we emit warnings in such case?
|
||||
const text = 'Hello {name} how are you {unprovidedValue}?';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue