Skip to content

Version 0.0.8

Compare
Choose a tag to compare
@vthibault vthibault released this 02 Mar 15:09
· 54 commits to master since this release

🐛 Fixed plural expression checks prioritization

In plural expression, direct checks will always be executed before plural categories.
Therefore, in the following example, the =0 will always have a higher priority than the one.

There {N,plural,one{is one cat} =0{is no cat} other{are {N} cats}} here.

Source: ceeb428

✨ Introduce onMissingVariable feature

It's now possible to detect if a specific translation is called with missing properties and how to handle it.
This function is called only on interpolation variables as there are some intended use with SELECT/PLURAL expressions.

Source: #8

frenchkiss.set('en', {
  hello: 'Hello {name} !',
});

frenchkiss.t('hello'); // => 'Hello  !' // Default it returns an empty string.

// -- Handle it now ---

frenchkiss.onMissingVariable((variable, key, language) => {
  // Send error to your server
  sendReport(`Missing the variable "${variable}" in ${language}->${key}.`);

  // Returns the text you want
  return `[missing:${variable}]`;
});

frenchkiss.t('hello'); // => 'Hello [missing:name] !'

Note: this functions is not cached and could be called multiple times.