The blazing fast lightweight internationalization (i18n) module for javascript
Full Changelog: https://github.com/koala-interactive/frenchkiss.js/compare/v0.3.0...v0.4.0
Full Changelog: https://github.com/koala-interactive/frenchkiss.js/compare/v0.2.0...v0.3.0
params
and locale
to onMissingKey
parameters.It's now possible to use nested key in translations table.
frenchkiss.onMissingKey((key, params, locale) => {
// Send error to your server
sendReport(`Missing the key "${key}" in ${locale} language.`);
// Returns the text you want
return `An error happened (${key})`;
});
A small optimization allowing to get 10% performance boost on table resolution.
It's now possible to use nested key in translations table.
frenchkiss.set('en', {
fruits: {
apple: 'An apple',
banana: 'A banana',
}
});
frenckiss.t('fruits.apple'); // => 'An apple'
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: ceeb4289
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.
Fixed a problem with the interpolation defaulting to an empty string when "0" was given as parameter.