mirror of
https://github.com/apache/superset.git
synced 2024-09-20 04:29:47 -04:00
3594d09191
Make the translation module less strict and won't crash the app if not configured. |
||
---|---|---|
.. | ||
src | ||
test | ||
package.json | ||
README.md |
@superset-ui/translation
i18n
locales and translation for Superset
SupersetTranslation
Example usage
import { configure, t, tn } from '@superset-ui/translation';
configure({
languagePack: {...},
});
console.log(t('text to be translated'));
console.log(tn('singular text', 'plural text', value));
API
configure({ [languagePack] })
- Initialize the translator
- Initialize with the default language if no
languagePack
is specified.
t(text[, args])
- Translate
text
. - If
args
is provided, substituteargs
into thesprintf
placeholders specified withintext
translation.
For example
t('Hello %(name)s', user);
See sprintf-js for more details on how to define placeholders.
tn(singular, plural, num, [, args])
- Translate and choose between
singular
andplural
based onnum
. - If
args
is provided, substituteargs
into thesprintf
placeholders specified withinsingular
orplural
translations.
For example
tn('%d duck', '%d ducks', 2, 2);
Development
@data-ui/build-config
is used to manage the build configuration for this package including babel
builds, jest testing, eslint, and prettier.